Skip to content

Commit 7d3fc6d

Browse files
Merge pull request #149 from fractalwrench/master
Update docs
2 parents cd95bd9 + 0fbbf41 commit 7d3fc6d

6 files changed

Lines changed: 81 additions & 39 deletions

File tree

AndroidBootstrap/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apply from: 'push.gradle'
33

44
android {
55
compileSdkVersion 23
6-
buildToolsVersion "23.0.1"
6+
buildToolsVersion "23.0.2"
77

88
defaultConfig {
99
minSdkVersion 11
@@ -14,6 +14,6 @@ android {
1414
}
1515

1616
dependencies {
17-
compile 'com.android.support:support-annotations:23.1.1'
18-
compile 'com.android.support:support-v4:23.1.1'
17+
compile 'com.android.support:support-annotations:23.2.0'
18+
compile 'com.android.support:support-v4:23.2.0'
1919
}

AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapDropDown.java

Lines changed: 68 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
import java.io.Serializable;
3434
import java.util.regex.Pattern;
3535

36+
/**
37+
* BootstrapButtons are buttons which provide contextual menus, styled with BootstrapBrand colors,
38+
* roundable corners, and an 'outlineable' mode.
39+
*/
3640
public class BootstrapDropDown extends AwesomeTextView implements View.OnClickListener, RoundableView, OutlineableView, PopupWindow.OnDismissListener {
3741

3842
private static final String TAG = "com.beardedhen.androidbootstrap.BootstrapDropDown";
@@ -99,7 +103,8 @@ private void initialise(AttributeSet attrs) {
99103
dropdownData = getContext().getResources().getStringArray(dataOrdinal);
100104
bootstrapSize = DefaultBootstrapSize.fromAttributeValue(sizeOrdinal).scaleFactor();
101105
itemHeight = a.getDimensionPixelSize(R.styleable.BootstrapDropDown_itemHeight, (int) DimenUtils.pixelsFromDpResource(getContext(), R.dimen.bootstrap_dropdown_default_item_height));
102-
} finally {
106+
}
107+
finally {
103108
a.recycle();
104109
}
105110

@@ -134,8 +139,9 @@ private void createDropDown() {
134139

135140
if (longestStringWidth < getMeasuredWidth()) {
136141
dropdownWindow.setWidth(DimenUtils.dpToPixels(getMeasuredWidth()));
137-
} else {
138-
dropdownWindow.setWidth((int)longestStringWidth + DimenUtils.dpToPixels(8));
142+
}
143+
else {
144+
dropdownWindow.setWidth((int) longestStringWidth + DimenUtils.dpToPixels(8));
139145
}
140146
}
141147

@@ -163,8 +169,9 @@ private ScrollView createDropDownView() {
163169
@Override
164170
public void onClick(View v) {
165171
dropdownWindow.dismiss();
166-
if (onDropDownItemClickListener != null)
172+
if (onDropDownItemClickListener != null) {
167173
onDropDownItemClickListener.onItemClick(dropdownView, v, v.getId());
174+
}
168175
}
169176
});
170177

@@ -173,15 +180,18 @@ public void onClick(View v) {
173180
childView.setTextSize((baselineDropDownViewFontSize - 2F) * bootstrapSize);
174181
childView.setClickable(false);
175182
childView.setTextColor(getResources().getColor(R.color.bootstrap_gray_light));
176-
} else if (Pattern.matches(SEARCH_REGEX_SEPARATOR, text)) {
183+
}
184+
else if (Pattern.matches(SEARCH_REGEX_SEPARATOR, text)) {
177185
childView = new DividerView(getContext());
178186
childView.setClickable(false);
179187
childView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 3));
180-
} else if (Pattern.matches(SEARCH_REGEX_DISABLED, text)) {
188+
}
189+
else if (Pattern.matches(SEARCH_REGEX_DISABLED, text)) {
181190
childView.setEnabled(false);
182191
childView.setId(clickableChildCounter++);
183192
childView.setText(text.replaceFirst(REPLACE_REGEX_DISABLED, ""));
184-
} else {
193+
}
194+
else {
185195
childView.setText(text);
186196
childView.setId(clickableChildCounter++);
187197
}
@@ -217,7 +227,7 @@ private void updateDropDownState() {
217227

218228
setCompoundDrawablesWithIntrinsicBounds(null, null,
219229
BootstrapDrawableFactory.bootstrapDropDownArrow(getContext(),
220-
DimenUtils.dpToPixels(8 *bootstrapSize),
230+
DimenUtils.dpToPixels(8 * bootstrapSize),
221231
DimenUtils.dpToPixels(12 * bootstrapSize),
222232
expandDirection,
223233
showOutline,
@@ -240,7 +250,8 @@ private void updateDropDownState() {
240250

241251
if (Build.VERSION.SDK_INT >= 16) {
242252
setBackground(bg);
243-
} else {
253+
}
254+
else {
244255
setBackgroundDrawable(bg);
245256
}
246257

@@ -290,6 +301,11 @@ private void cleanData() {
290301
dropdownData = cleanArray;
291302
}
292303

304+
/**
305+
* Sets a listener which will be called when an item is clicked in the dropdown.
306+
*
307+
* @param onDropDownItemClickListener the listener
308+
*/
293309
public void setOnDropDownItemClickListener(OnDropDownItemClickListener onDropDownItemClickListener) {
294310
this.onDropDownItemClickListener = onDropDownItemClickListener;
295311
}
@@ -302,10 +318,20 @@ public void setOnDropDownItemClickListener(OnDropDownItemClickListener onDropDow
302318
return roundedCorners;
303319
}
304320

321+
/**
322+
* Gets the direction in which the dropdown expands.
323+
*
324+
* @return the direction
325+
*/
305326
public ExpandDirection getExpandDirection() {
306327
return expandDirection;
307328
}
308329

330+
/**
331+
* Retrieves the data used to populate the dropdown.
332+
*
333+
* @return a string array of values
334+
*/
309335
public String[] getDropdownData() {
310336
return dropdownData;
311337
}
@@ -320,11 +346,21 @@ public String[] getDropdownData() {
320346
updateDropDownState();
321347
}
322348

349+
/**
350+
* Sets the direction in which the dropdown should expand.
351+
*
352+
* @param expandDirection the direction
353+
*/
323354
public void setExpandDirection(ExpandDirection expandDirection) {
324355
this.expandDirection = expandDirection;
325356
updateDropDownState();
326357
}
327358

359+
/**
360+
* Sets the String values which should be used to populate the menu displayed in the dropdown.
361+
*
362+
* @param dropdownData an array of string values.
363+
*/
328364
public void setDropdownData(String[] dropdownData) {
329365
this.dropdownData = dropdownData;
330366
createDropDown();
@@ -337,17 +373,20 @@ public void setDropdownData(String[] dropdownData) {
337373
}
338374

339375
@Override public void onClick(View v) {
340-
if (clickListener != null) clickListener.onClick(v);
376+
if (clickListener != null) {
377+
clickListener.onClick(v);
378+
}
341379
//using 8dip on axisX offset to make dropdown view visually be at start of dropdown itself
342380
//using 4dip on axisY offset to make space between dropdown view and dropdown itself
343381
//all offsets are necessary because of the dialog_holo_light_frame to display correctly on screen(shadow was made by inset)
344382
int gravity;
345383
int axisXOffset;
346384
if (dropDownViewWidth + getX() > screenWidth) {
347-
gravity = Gravity.TOP|Gravity.RIGHT;
385+
gravity = Gravity.TOP | Gravity.RIGHT;
348386
axisXOffset = DimenUtils.dpToPixels(8);
349-
} else {
350-
gravity = Gravity.TOP|Gravity.LEFT;
387+
}
388+
else {
389+
gravity = Gravity.TOP | Gravity.LEFT;
351390
axisXOffset = -DimenUtils.dpToPixels(8);
352391
}
353392
int axisYOffset = DimenUtils.dpToPixels(4);
@@ -401,22 +440,33 @@ public void setDropdownData(String[] dropdownData) {
401440
this.clickListener = clickListener;
402441
}
403442

443+
/**
444+
* A listener which provides methods relating to {@link BootstrapDropDown}
445+
*/
404446
public interface OnDropDownItemClickListener {
447+
448+
/**
449+
* Called when an item is clicked in a {@link BootstrapDropDown}
450+
*
451+
* @param parent the parent viewgroup
452+
* @param v the view
453+
* @param id the id
454+
*/
405455
void onItemClick(ViewGroup parent, View v, int id);
406456
}
407457

408-
private class DividerView extends TextView {
458+
private static class DividerView extends TextView {
409459

410-
private Paint mPaint;
460+
private final Paint paint;
411461

412462
public DividerView(Context context) {
413463
super(context);
414-
mPaint = new Paint();
415-
mPaint.setColor(getResources().getColor(R.color.bootstrap_dropdown_divider));
464+
paint = new Paint();
465+
paint.setColor(getResources().getColor(R.color.bootstrap_dropdown_divider));
416466
}
417467

418468
@Override protected void onDraw(Canvas canvas) {
419-
canvas.drawLine(0, 1, canvas.getWidth(), 1, mPaint);
469+
canvas.drawLine(0, 1, canvas.getWidth(), 1, paint);
420470
super.onDraw(canvas);
421471
}
422472
}

AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapWell.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import com.beardedhen.androidbootstrap.utils.ColorUtils;
1212
import com.beardedhen.androidbootstrap.utils.DimenUtils;
1313

14+
/**
15+
* BootstrapWells are used as a container layout for other views, typically text.
16+
*/
1417
public class BootstrapWell extends FrameLayout {
1518

1619
private float bootstrapSize;
@@ -35,7 +38,6 @@ private void initialise(AttributeSet attrs) {
3538

3639
try {
3740
int sizeOrdinal = a.getInt(R.styleable.BootstrapButton_bootstrapSize, -1);
38-
3941
bootstrapSize = DefaultBootstrapSize.fromAttributeValue(sizeOrdinal).scaleFactor();
4042
}
4143
finally {

AndroidBootstrap/src/main/res/values/attrs.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,5 @@
124124
<attr name="bootstrapSize"/>
125125
</declare-styleable>
126126

127-
<declare-styleable name="BootstrapDropDown">
128-
<attr name="bootstrapExpandDirection"/>
129-
<attr name="dropdownResource"/>
130-
<attr name="showOutline"/>
131-
<attr name="roundedCorners"/>
132-
<attr name="bootstrapBrand"/>
133-
<attr name="bootstrapSize"/>
134-
<attr name="itemHeight"/>
135-
</declare-styleable>
136-
137127
</resources>
138128

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
VERSION_NAME=2.0.1
2-
VERSION_CODE=201
1+
VERSION_NAME=2.1.0
2+
VERSION_CODE=210
33
GROUP=com.beardedhen
44

55
POM_DESCRIPTION=Bootstrap style widgets for Android, with Glyph Icons

sample/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 23
5-
buildToolsVersion "23.0.1"
5+
buildToolsVersion "23.0.2"
66

77
defaultConfig {
88
applicationId "com.fractalwrench.androidbootstrap.sample"
99
minSdkVersion 11
1010
targetSdkVersion 23
11-
versionCode 1
12-
versionName "1.0"
11+
versionCode 210
12+
versionName "2.1.0"
1313
}
1414
lintOptions {
1515
disable 'InvalidPackage'
@@ -29,6 +29,6 @@ dependencies {
2929
compile project (':AndroidBootstrap') // replace with Maven dependency in your app
3030

3131
compile 'com.jakewharton:butterknife:7.0.1'
32-
compile 'com.android.support:appcompat-v7:23.1.1'
33-
compile 'com.android.support:support-annotations:23.1.1'
32+
compile 'com.android.support:appcompat-v7:23.2.0'
33+
compile 'com.android.support:support-annotations:23.2.0'
3434
}

0 commit comments

Comments
 (0)