浏览代码

pre 0.0.51.beta1
- 修复使用 MaterialYouStyle 主题时按钮背景颜色不随对话框背景颜色改变的问题

Kongzue 7 月之前
父节点
当前提交
98ba5af617

二进制
DialogX/libs/DialogXInterface.jar


+ 5 - 3
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomDialog.java

@@ -519,9 +519,11 @@ public class BottomDialog extends BaseDialog implements DialogXBaseBottomDialog
             boxRoot.setRootPadding(screenPaddings[0], screenPaddings[1], screenPaddings[2], screenPaddings[3]);
             if (backgroundColor != null) {
                 tintColor(bkg, backgroundColor);
-                tintColor(btnSelectOther, backgroundColor);
-                tintColor(btnSelectNegative, backgroundColor);
-                tintColor(btnSelectPositive, backgroundColor);
+                if (style.tintButtonBackground()){
+                    tintColor(btnSelectOther, backgroundColor);
+                    tintColor(btnSelectNegative, backgroundColor);
+                    tintColor(btnSelectPositive, backgroundColor);
+                }
 
                 if (blurViews != null) {
                     for (View blurView : blurViews) {

+ 1 - 1
DialogX/src/main/java/com/kongzue/dialogx/dialogs/MessageDialog.java

@@ -583,7 +583,7 @@ public class MessageDialog extends BaseDialog {
             boxRoot.setRootPadding(screenPaddings[0], screenPaddings[1], screenPaddings[2], screenPaddings[3]);
             if (backgroundColor != null) {
                 tintColor(bkg, backgroundColor);
-                if (style instanceof MaterialStyle) {
+                if (style.tintButtonBackground()) {
                     tintColor(btnSelectOther, backgroundColor);
                     tintColor(btnSelectNegative, backgroundColor);
                     tintColor(btnSelectPositive, backgroundColor);

+ 5 - 0
DialogX/src/main/java/com/kongzue/dialogx/style/MaterialStyle.java

@@ -328,4 +328,9 @@ public class MaterialStyle extends DialogXStyle {
             return 0;
         }
     }
+
+    @Override
+    public boolean tintButtonBackground() {
+        return true;
+    }
 }

+ 7 - 1
DialogXInterface/src/main/java/com/kongzue/dialogx/interfaces/DialogXStyle.java

@@ -8,7 +8,7 @@ public abstract class DialogXStyle {
      * DialogXStyle 版本
      * 相关文档请参阅:https://github.com/kongzue/DialogX/wiki/%E8%87%AA%E5%AE%9A%E4%B9%89-DialogX-%E4%B8%BB%E9%A2%98
      */
-    public static final int styleVer = 5;
+    public static final int styleVer = 6;
     
     /**
      * 按钮类型常量
@@ -601,4 +601,10 @@ public abstract class DialogXStyle {
             return null;
         }
     }
+
+    /**
+     * 是否需要在设置对话框背景色时对按钮背景也进行染色
+     * @return false 不进行染色
+     */
+    public boolean tintButtonBackground(){return false;}
 }

+ 5 - 0
DialogXMaterialYou/src/main/java/com/kongzue/dialogxmaterialyou/style/MaterialYouStyle.java

@@ -328,4 +328,9 @@ public class MaterialYouStyle extends DialogXStyle {
             return false;
         }
     }
+
+    @Override
+    public boolean tintButtonBackground() {
+        return true;
+    }
 }

+ 1 - 13
app/src/main/java/com/kongzue/dialogxdemo/activity/MainActivity.java

@@ -495,19 +495,7 @@ public class MainActivity extends BaseActivity {
                                 tip("onDismiss");
                             }
                         })
-                        .onShow(new DialogXRunnable<MessageDialog>() {
-                            @Override
-                            public void run(MessageDialog dialog) {
-                                dialog.getDialogImpl().btnSelectPositive
-                                        .post(new Runnable() {
-                                            @Override
-                                            public void run() {
-                                                dialog.getDialogImpl().btnSelectPositive
-                                                        .setBackgroundColor(Color.GREEN);
-                                            }
-                                        });
-                            }
-                        })
+                        .setBackgroundColor(Color.RED)
                         .setTitleIcon(R.mipmap.img_demo_avatar).setOkButton(new OnDialogButtonClickListener<MessageDialog>() {
                             @Override
                             public boolean onClick(MessageDialog baseDialog, View v) {