Browse Source

Release 0.4.6

Aidan Follestad 10 years ago
parent
commit
7d885bba7d

+ 35 - 45
README.md

@@ -6,6 +6,11 @@ The code you see below is also found in the sample project. You can download a A
 
 ### What's New
 
+###### Version 0.4.6
+
+> 1. Some fixes thanks to a pull request from [hzsweers](https://github.com/hzsweers), see the [pull request here](https://github.com/afollestad/material-dialogs/pull/124).
+> 2. The ability to force the action buttons to be stacked (see the [Misc.](#misc) section).
+
 ###### Version 0.4.5
 
 > 1. Crash fix for Huawei devices
@@ -60,7 +65,7 @@ Easily reference the library in your Android projects using this dependency in y
 
 ```Groovy
 dependencies {
-    compile 'com.afollestad:material-dialogs:0.4.5'
+    compile 'com.afollestad:material-dialogs:0.4.6'
 }
 ```
 
@@ -299,49 +304,6 @@ it to display the action buttons below your list, however this is only useful in
 
 ---
 
-### Comprehensive Listener APIs
-
-There are many listeners available, and they can all be used independently to give you fine-grained control
-over the behavior of the dialog.
-
-```java
-new MaterialDialog.Builder(this)
-        .title(R.string.complex)
-        .positiveText("Yes")
-        .negativeText("No")
-        .neutralText("Maybe")
-        .items(R.array.socialNetworks)
-        .itemsCallbackSingleChoice(0, new MaterialDialog.ListCallback() {
-            @Override
-            public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
-                Toast.makeText(MainActivity.this, "Clicked " + text, Toast.LENGTH_SHORT).show();
-            }
-        })
-        .callback(new MaterialDialog.FullCallback() {
-            @Override
-            public void onNeutral(MaterialDialog dialog) {
-                Toast.makeText(MainActivity.this, "Maybe", Toast.LENGTH_SHORT).show();
-            }
-
-            @Override
-            public void onNegative(MaterialDialog dialog) {
-                Toast.makeText(MainActivity.this, "No", Toast.LENGTH_SHORT).show();
-            }
-
-            @Override
-            public void onPositive(MaterialDialog dialog) {
-                Toast.makeText(MainActivity.this, "Yes", Toast.LENGTH_SHORT).show();
-            }
-        })
-        .cancelListener(new DialogInterface.OnCancelListener() {
-            @Override
-            public void onCancel(DialogInterface dialog) {
-                Toast.makeText(MainActivity.this, "Canceled", Toast.LENGTH_SHORT).show();
-            }
-        })
-        .show();
-```
-
 If you want to preselect item(s), pass an array of indices in place of null in `itemsCallbackSingleChoice()`.
 For an example, `new Integer[] { 2, 5 }`. If `autoDismiss` is turned off, then you must manually
 dismiss the dialog in the callback. Auto dismiss is on by default. When action buttons are not added, the
@@ -488,7 +450,26 @@ You can directly setup show/cancel/dismiss listeners from the `Builder` rather t
 `MaterialDialog` instance:
 
 ```java
-
+new MaterialDialog.Builder(this)
+    .title("Use Google's Location Services?")
+    .content("Let Google help apps determine location. This means sending anonymous location data to Google, even when no apps are running.")
+    .positiveText("Agree")
+    .showListener(new DialogInterface.OnShowListener() {
+        @Override
+        public void onShow(DialogInterface dialog) {
+        }
+    })
+    .cancelListener(new DialogInterface.OnCancelListener() {
+        @Override
+        public void onCancel(DialogInterface dialog) {
+        }
+    })
+    .dismissListener(new DialogInterface.OnDismissListener() {
+        @Override
+        public void onDismiss(DialogInterface dialog) {
+        }
+    })
+    .show();
 ```
 
 ---
@@ -546,3 +527,12 @@ MaterialDialog dialog new MaterialDialog.Builder(this)
         .typeface(titleAndActions, contentAndListItems)
         .show();
 ```
+
+If you want to force the dialog action buttons to be stacked (override the stacking algorithm):
+
+```java
+MaterialDialog dialog new MaterialDialog.Builder(this)
+        // ... other initialization
+        .forceStacking(true)
+        .show();
+```

+ 2 - 2
library/build.gradle

@@ -9,7 +9,7 @@ android {
         minSdkVersion 8
         targetSdkVersion 21
         versionCode 1
-        versionName "0.4.5"
+        versionName "0.4.6"
     }
     lintOptions {
         abortOnError false
@@ -26,7 +26,7 @@ publish {
     userOrg = 'drummer-aidan'
     groupId = 'com.afollestad'
     artifactId = 'material-dialogs'
-    version = '0.4.5'
+    version = '0.4.6'
     description = 'A library for implementing Material design styled dialogs across all versions of Android.'
     website = 'https://github.com/afollestad/material-dialogs'
     issueTracker = "${website}/issues"

+ 12 - 0
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -83,6 +83,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
     private ListAdapter adapter;
     private ListType listType;
     private List<Integer> selectedIndicesList;
+    private boolean forceStacking;
 
     protected static ContextThemeWrapper getTheme(Builder builder) {
         TypedArray a = builder.context.getTheme().obtainStyledAttributes(new int[]{R.attr.md_dark_theme});
@@ -440,7 +441,12 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
     private void checkIfStackingNeeded() {
         if (numberOfActionButtons() <= 1) {
             return;
+        } else if (forceStacking) {
+            isStacked = true;
+            invalidateActions();
+            return;
         }
+
         final int maxWidth = calculateMaxButtonWidth();
         isStacked = false;
 
@@ -652,6 +658,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         private OnDismissListener dismissListener;
         private OnCancelListener cancelListener;
         private OnShowListener showListener;
+        protected boolean forceStacking;
 
         public Builder(@NonNull Context context) {
             this.context = context;
@@ -946,6 +953,11 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
             return this;
         }
 
+        public Builder forceStacking(boolean stacked) {
+            this.forceStacking = stacked;
+            return this;
+        }
+
         public MaterialDialog build() {
             MaterialDialog dialog = new MaterialDialog(this);
             if (this.showListener != null) {

+ 2 - 2
sample/build.gradle

@@ -8,8 +8,8 @@ android {
         applicationId "com.afollestad.materialdialogssample"
         minSdkVersion 11
         targetSdkVersion 21
-        versionCode 50
-        versionName "0.4.5"
+        versionCode 51
+        versionName "0.4.6"
     }
     buildTypes {
 //        release {

BIN
sample/sample.apk