Browse Source

Stacked gravity only applied to stacked buttons. Quick fix release 0.6.2.3.

Aidan Follestad 10 years ago
parent
commit
612cf7c8c4

+ 2 - 2
library/build.gradle

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

+ 21 - 17
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -712,11 +712,13 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
             positiveButton.setTag(POSITIVE);
             positiveButton.setOnClickListener(this);
 
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
-                //noinspection ResourceType
-                positiveTextView.setTextAlignment(gravityToAlignment(mBuilder.btnStackedGravity));
-            } else {
-                positiveTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
+            if (isStacked) {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+                    //noinspection ResourceType
+                    positiveTextView.setTextAlignment(gravityToAlignment(mBuilder.btnStackedGravity));
+                } else {
+                    positiveTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
+                }
             }
         } else {
             positiveButton.setVisibility(View.GONE);
@@ -734,11 +736,13 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
             neutralButton.setTag(NEUTRAL);
             neutralButton.setOnClickListener(this);
 
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
-                //noinspection ResourceType
-                neutralTextView.setTextAlignment(gravityToAlignment(mBuilder.btnStackedGravity));
-            } else {
-                neutralTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
+            if (isStacked) {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+                    //noinspection ResourceType
+                    neutralTextView.setTextAlignment(gravityToAlignment(mBuilder.btnStackedGravity));
+                } else {
+                    neutralTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
+                }
             }
         } else {
             neutralButton.setVisibility(View.GONE);
@@ -756,13 +760,6 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
             negativeButton.setTag(NEGATIVE);
             negativeButton.setOnClickListener(this);
 
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
-                //noinspection ResourceType
-                negativeTextView.setTextAlignment(gravityToAlignment(mBuilder.btnStackedGravity));
-            } else {
-                negativeTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
-            }
-
             if (!isStacked) {
                 RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                         RelativeLayout.LayoutParams.WRAP_CONTENT, (int) getContext().getResources().getDimension(R.dimen.md_button_height));
@@ -780,6 +777,13 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
                     }
                 }
                 negativeButton.setLayoutParams(params);
+            } else {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+                    //noinspection ResourceType
+                    negativeTextView.setTextAlignment(gravityToAlignment(mBuilder.btnStackedGravity));
+                } else {
+                    negativeTextView.setGravity(gravityIntToGravity(mBuilder.btnStackedGravity));
+                }
             }
         } else {
             negativeButton.setVisibility(View.GONE);

+ 2 - 2
sample/build.gradle

@@ -8,8 +8,8 @@ android {
         applicationId "com.afollestad.materialdialogssample"
         minSdkVersion 14
         targetSdkVersion 21
-        versionCode 74
-        versionName "0.6.2.2"
+        versionCode 75
+        versionName "0.6.2.3"
     }
     lintOptions {
         abortOnError false

BIN
sample/sample.apk