From 53c44528964216bc92a8862c3aa6a537094d28de Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 26 Feb 2016 20:26:07 +0000 Subject: [PATCH 1/2] update docs for dropdown and well --- AndroidBootstrap/build.gradle | 2 +- .../androidbootstrap/BootstrapDropDown.java | 86 +++++++++++++++---- .../androidbootstrap/BootstrapWell.java | 3 + .../src/main/res/values/attrs.xml | 10 --- sample/build.gradle | 4 +- 5 files changed, 74 insertions(+), 31 deletions(-) diff --git a/AndroidBootstrap/build.gradle b/AndroidBootstrap/build.gradle index f86726f..e95d653 100644 --- a/AndroidBootstrap/build.gradle +++ b/AndroidBootstrap/build.gradle @@ -3,7 +3,7 @@ apply from: 'push.gradle' android { compileSdkVersion 23 - buildToolsVersion "23.0.1" + buildToolsVersion "23.0.2" defaultConfig { minSdkVersion 11 diff --git a/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapDropDown.java b/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapDropDown.java index 788b0f9..b3bb630 100644 --- a/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapDropDown.java +++ b/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapDropDown.java @@ -33,6 +33,10 @@ import java.io.Serializable; import java.util.regex.Pattern; +/** + * BootstrapButtons are buttons which provide contextual menus, styled with BootstrapBrand colors, + * roundable corners, and an 'outlineable' mode. + */ public class BootstrapDropDown extends AwesomeTextView implements View.OnClickListener, RoundableView, OutlineableView, PopupWindow.OnDismissListener { private static final String TAG = "com.beardedhen.androidbootstrap.BootstrapDropDown"; @@ -99,7 +103,8 @@ private void initialise(AttributeSet attrs) { dropdownData = getContext().getResources().getStringArray(dataOrdinal); bootstrapSize = DefaultBootstrapSize.fromAttributeValue(sizeOrdinal).scaleFactor(); itemHeight = a.getDimensionPixelSize(R.styleable.BootstrapDropDown_itemHeight, (int) DimenUtils.pixelsFromDpResource(getContext(), R.dimen.bootstrap_dropdown_default_item_height)); - } finally { + } + finally { a.recycle(); } @@ -134,8 +139,9 @@ private void createDropDown() { if (longestStringWidth < getMeasuredWidth()) { dropdownWindow.setWidth(DimenUtils.dpToPixels(getMeasuredWidth())); - } else { - dropdownWindow.setWidth((int)longestStringWidth + DimenUtils.dpToPixels(8)); + } + else { + dropdownWindow.setWidth((int) longestStringWidth + DimenUtils.dpToPixels(8)); } } @@ -163,8 +169,9 @@ private ScrollView createDropDownView() { @Override public void onClick(View v) { dropdownWindow.dismiss(); - if (onDropDownItemClickListener != null) + if (onDropDownItemClickListener != null) { onDropDownItemClickListener.onItemClick(dropdownView, v, v.getId()); + } } }); @@ -173,15 +180,18 @@ public void onClick(View v) { childView.setTextSize((baselineDropDownViewFontSize - 2F) * bootstrapSize); childView.setClickable(false); childView.setTextColor(getResources().getColor(R.color.bootstrap_gray_light)); - } else if (Pattern.matches(SEARCH_REGEX_SEPARATOR, text)) { + } + else if (Pattern.matches(SEARCH_REGEX_SEPARATOR, text)) { childView = new DividerView(getContext()); childView.setClickable(false); childView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 3)); - } else if (Pattern.matches(SEARCH_REGEX_DISABLED, text)) { + } + else if (Pattern.matches(SEARCH_REGEX_DISABLED, text)) { childView.setEnabled(false); childView.setId(clickableChildCounter++); childView.setText(text.replaceFirst(REPLACE_REGEX_DISABLED, "")); - } else { + } + else { childView.setText(text); childView.setId(clickableChildCounter++); } @@ -217,7 +227,7 @@ private void updateDropDownState() { setCompoundDrawablesWithIntrinsicBounds(null, null, BootstrapDrawableFactory.bootstrapDropDownArrow(getContext(), - DimenUtils.dpToPixels(8 *bootstrapSize), + DimenUtils.dpToPixels(8 * bootstrapSize), DimenUtils.dpToPixels(12 * bootstrapSize), expandDirection, showOutline, @@ -240,7 +250,8 @@ private void updateDropDownState() { if (Build.VERSION.SDK_INT >= 16) { setBackground(bg); - } else { + } + else { setBackgroundDrawable(bg); } @@ -290,6 +301,11 @@ private void cleanData() { dropdownData = cleanArray; } + /** + * Sets a listener which will be called when an item is clicked in the dropdown. + * + * @param onDropDownItemClickListener the listener + */ public void setOnDropDownItemClickListener(OnDropDownItemClickListener onDropDownItemClickListener) { this.onDropDownItemClickListener = onDropDownItemClickListener; } @@ -302,10 +318,20 @@ public void setOnDropDownItemClickListener(OnDropDownItemClickListener onDropDow return roundedCorners; } + /** + * Gets the direction in which the dropdown expands. + * + * @return the direction + */ public ExpandDirection getExpandDirection() { return expandDirection; } + /** + * Retrieves the data used to populate the dropdown. + * + * @return a string array of values + */ public String[] getDropdownData() { return dropdownData; } @@ -320,11 +346,21 @@ public String[] getDropdownData() { updateDropDownState(); } + /** + * Sets the direction in which the dropdown should expand. + * + * @param expandDirection the direction + */ public void setExpandDirection(ExpandDirection expandDirection) { this.expandDirection = expandDirection; updateDropDownState(); } + /** + * Sets the String values which should be used to populate the menu displayed in the dropdown. + * + * @param dropdownData an array of string values. + */ public void setDropdownData(String[] dropdownData) { this.dropdownData = dropdownData; createDropDown(); @@ -337,17 +373,20 @@ public void setDropdownData(String[] dropdownData) { } @Override public void onClick(View v) { - if (clickListener != null) clickListener.onClick(v); + if (clickListener != null) { + clickListener.onClick(v); + } //using 8dip on axisX offset to make dropdown view visually be at start of dropdown itself //using 4dip on axisY offset to make space between dropdown view and dropdown itself //all offsets are necessary because of the dialog_holo_light_frame to display correctly on screen(shadow was made by inset) int gravity; int axisXOffset; if (dropDownViewWidth + getX() > screenWidth) { - gravity = Gravity.TOP|Gravity.RIGHT; + gravity = Gravity.TOP | Gravity.RIGHT; axisXOffset = DimenUtils.dpToPixels(8); - } else { - gravity = Gravity.TOP|Gravity.LEFT; + } + else { + gravity = Gravity.TOP | Gravity.LEFT; axisXOffset = -DimenUtils.dpToPixels(8); } int axisYOffset = DimenUtils.dpToPixels(4); @@ -401,22 +440,33 @@ public void setDropdownData(String[] dropdownData) { this.clickListener = clickListener; } + /** + * A listener which provides methods relating to {@link BootstrapDropDown} + */ public interface OnDropDownItemClickListener { + + /** + * Called when an item is clicked in a {@link BootstrapDropDown} + * + * @param parent the parent viewgroup + * @param v the view + * @param id the id + */ void onItemClick(ViewGroup parent, View v, int id); } - private class DividerView extends TextView { + private static class DividerView extends TextView { - private Paint mPaint; + private final Paint paint; public DividerView(Context context) { super(context); - mPaint = new Paint(); - mPaint.setColor(getResources().getColor(R.color.bootstrap_dropdown_divider)); + paint = new Paint(); + paint.setColor(getResources().getColor(R.color.bootstrap_dropdown_divider)); } @Override protected void onDraw(Canvas canvas) { - canvas.drawLine(0, 1, canvas.getWidth(), 1, mPaint); + canvas.drawLine(0, 1, canvas.getWidth(), 1, paint); super.onDraw(canvas); } } diff --git a/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapWell.java b/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapWell.java index f6270fe..986eab8 100644 --- a/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapWell.java +++ b/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapWell.java @@ -11,6 +11,9 @@ import com.beardedhen.androidbootstrap.utils.ColorUtils; import com.beardedhen.androidbootstrap.utils.DimenUtils; +/** + * BootstrapWells are used as a container layout for other views, typically text. + */ public class BootstrapWell extends FrameLayout { private float bootstrapSize; diff --git a/AndroidBootstrap/src/main/res/values/attrs.xml b/AndroidBootstrap/src/main/res/values/attrs.xml index 29d5bd7..4f0ba45 100644 --- a/AndroidBootstrap/src/main/res/values/attrs.xml +++ b/AndroidBootstrap/src/main/res/values/attrs.xml @@ -124,15 +124,5 @@ - - - - - - - - - - diff --git a/sample/build.gradle b/sample/build.gradle index be672cb..19e5c9e 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -2,14 +2,14 @@ apply plugin: 'com.android.application' android { compileSdkVersion 23 - buildToolsVersion "23.0.1" + buildToolsVersion "23.0.2" defaultConfig { applicationId "com.fractalwrench.androidbootstrap.sample" minSdkVersion 11 targetSdkVersion 23 versionCode 1 - versionName "1.0" + versionName "1.0.0" } lintOptions { disable 'InvalidPackage' From 0fbbf41ece9228631bbaf03525ae2d8c0c163f8d Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 26 Feb 2016 20:53:20 +0000 Subject: [PATCH 2/2] up version --- AndroidBootstrap/build.gradle | 4 ++-- .../com/beardedhen/androidbootstrap/BootstrapWell.java | 1 - gradle.properties | 4 ++-- sample/build.gradle | 8 ++++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/AndroidBootstrap/build.gradle b/AndroidBootstrap/build.gradle index e95d653..85aac85 100644 --- a/AndroidBootstrap/build.gradle +++ b/AndroidBootstrap/build.gradle @@ -14,6 +14,6 @@ android { } dependencies { - compile 'com.android.support:support-annotations:23.1.1' - compile 'com.android.support:support-v4:23.1.1' + compile 'com.android.support:support-annotations:23.2.0' + compile 'com.android.support:support-v4:23.2.0' } diff --git a/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapWell.java b/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapWell.java index 986eab8..ea3c19d 100644 --- a/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapWell.java +++ b/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/BootstrapWell.java @@ -38,7 +38,6 @@ private void initialise(AttributeSet attrs) { try { int sizeOrdinal = a.getInt(R.styleable.BootstrapButton_bootstrapSize, -1); - bootstrapSize = DefaultBootstrapSize.fromAttributeValue(sizeOrdinal).scaleFactor(); } finally { diff --git a/gradle.properties b/gradle.properties index 77a66ac..c1a973c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -VERSION_NAME=2.0.1 -VERSION_CODE=201 +VERSION_NAME=2.1.0 +VERSION_CODE=210 GROUP=com.beardedhen POM_DESCRIPTION=Bootstrap style widgets for Android, with Glyph Icons diff --git a/sample/build.gradle b/sample/build.gradle index 19e5c9e..8dbd524 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.fractalwrench.androidbootstrap.sample" minSdkVersion 11 targetSdkVersion 23 - versionCode 1 - versionName "1.0.0" + versionCode 210 + versionName "2.1.0" } lintOptions { disable 'InvalidPackage' @@ -29,6 +29,6 @@ dependencies { compile project (':AndroidBootstrap') // replace with Maven dependency in your app compile 'com.jakewharton:butterknife:7.0.1' - compile 'com.android.support:appcompat-v7:23.1.1' - compile 'com.android.support:support-annotations:23.1.1' + compile 'com.android.support:appcompat-v7:23.2.0' + compile 'com.android.support:support-annotations:23.2.0' }