kongzue преди 4 години
родител
ревизия
c019487936

+ 6 - 7
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomDialog.java

@@ -172,7 +172,7 @@ public class BottomDialog extends BaseDialog {
          * 记录这个值的目的是,当用户向下滑动时,判断情况该回到这个位置还是关闭对话框,
          * 并阻止当内容高度已经完全显示时的继续向上滑动操作。
          */
-        public float bkgEnterAimY;
+        public float bkgEnterAimY = -1;
         
         @Override
         public void init() {
@@ -266,20 +266,19 @@ public class BottomDialog extends BaseDialog {
             scrollView.post(new Runnable() {
                 @Override
                 public void run() {
-                    bkg.setY(boxBkg.getHeight());
                     if (bkg.isChildScrollViewCanScroll() && bottomDialogMaxHeight != 0) {
                         if (bottomDialogMaxHeight <= 1) {
                             bkgEnterAimY = boxBkg.getHeight() - bkg.getHeight() * bottomDialogMaxHeight;
                         } else {
-                            bkgEnterAimY = boxBkg.getHeight() - bottomDialogMaxHeight - boxBkg.getPaddingBottom();
+                            bkgEnterAimY = boxBkg.getHeight() - bottomDialogMaxHeight;
                         }
                     } else {
-                        bkgEnterAimY = boxBkg.getHeight() - bkg.getHeight() - boxBkg.getPaddingBottom();
+                        bkgEnterAimY = boxBkg.getHeight() - bkg.getHeight();
                     }
-                    Animation enterAnim = AnimationUtils.loadAnimation(getContext(), R.anim.anim_dialogx_bottom_enter);
+                    ObjectAnimator enterAnim = ObjectAnimator.ofFloat(bkg, "y", boxBkg.getHeight(), bkgEnterAimY);
                     enterAnim.setInterpolator(new DecelerateInterpolator(2f));
                     enterAnim.setDuration(500);
-                    bkg.startAnimation(enterAnim);
+                    enterAnim.start();
                     boxRoot.animate().setDuration(enterAnim.getDuration()).alpha(1f).setInterpolator(new DecelerateInterpolator()).setDuration(100).setListener(null);
                 }
             });
@@ -289,7 +288,7 @@ public class BottomDialog extends BaseDialog {
             @Override
             public void onGlobalLayout() {
                 if (boxContent != null) {
-                    float oldY = bkgEnterAimY;
+                    float oldY = bkgEnterAimY == -1 ? boxContent.getHeight() : bkgEnterAimY;
                     if (bkg.isChildScrollViewCanScroll() && bottomDialogMaxHeight != 0) {
                         if (bottomDialogMaxHeight <= 1) {
                             bkgEnterAimY = boxBkg.getHeight() - bkg.getHeight() * bottomDialogMaxHeight;

+ 163 - 0
DialogX/src/main/java/com/kongzue/dialogx/style/BuildStyle.java

@@ -0,0 +1,163 @@
+package com.kongzue.dialogx.style;
+
+import com.kongzue.dialogx.R;
+import com.kongzue.dialogx.interfaces.DialogXStyle;
+
+/**
+ * @author: Kongzue
+ * @github: https://github.com/kongzue/
+ * @homepage: http://kongzue.com/
+ * @mail: myzcxhh@live.cn
+ * @createTime: 2020/10/11 12:26
+ */
+public class BuildStyle implements DialogXStyle {
+    public static BuildStyle style() {
+        return new BuildStyle();
+    }
+    
+    @Override
+    public int layout(boolean light) {
+        return light ? R.layout.layout_dialogx_material : R.layout.layout_dialogx_material_dark;
+    }
+    
+    @Override
+    public int enterAnimResId() {
+        return R.anim.anim_dialogx_default_enter;
+    }
+    
+    @Override
+    public int exitAnimResId() {
+        return R.anim.anim_dialogx_default_exit;
+    }
+    
+    @Override
+    public int[] verticalButtonOrder() {
+        return new int[]{BUTTON_OK, BUTTON_OTHER, BUTTON_CANCEL};
+    }
+    
+    @Override
+    public int[] horizontalButtonOrder() {
+        return new int[]{BUTTON_OTHER, SPACE, BUTTON_CANCEL, BUTTON_OK};
+    }
+    
+    @Override
+    public int splitWidthPx() {
+        return 1;
+    }
+    
+    @Override
+    public int splitColorRes(boolean light) {
+        return 0;
+    }
+    
+    @Override
+    public BlurBackgroundSetting messageDialogBlurSettings() {
+        return null;
+    }
+    
+    @Override
+    public HorizontalButtonRes overrideHorizontalButtonRes() {
+        return new HorizontalButtonRes() {
+            @Override
+            public int overrideHorizontalOkButtonBackgroundRes(int visibleButtonCount, boolean light) {
+                return light ? R.drawable.button_dialogx_material_light : R.drawable.button_dialogx_material_night;
+            }
+            
+            @Override
+            public int overrideHorizontalCancelButtonBackgroundRes(int visibleButtonCount, boolean light) {
+                return light ? R.drawable.button_dialogx_material_light : R.drawable.button_dialogx_material_night;
+            }
+            
+            @Override
+            public int overrideHorizontalOtherButtonBackgroundRes(int visibleButtonCount, boolean light) {
+                return light ? R.drawable.button_dialogx_material_light : R.drawable.button_dialogx_material_night;
+            }
+        };
+    }
+    
+    @Override
+    public VerticalButtonRes overrideVerticalButtonRes() {
+        return new VerticalButtonRes() {
+            @Override
+            public int overrideVerticalOkButtonBackgroundRes(int visibleButtonCount, boolean light) {
+                return light ? R.drawable.button_dialogx_material_light : R.drawable.button_dialogx_material_night;
+            }
+            
+            @Override
+            public int overrideVerticalCancelButtonBackgroundRes(int visibleButtonCount, boolean light) {
+                return light ? R.drawable.button_dialogx_material_light : R.drawable.button_dialogx_material_night;
+            }
+            
+            @Override
+            public int overrideVerticalOtherButtonBackgroundRes(int visibleButtonCount, boolean light) {
+                return light ? R.drawable.button_dialogx_material_light : R.drawable.button_dialogx_material_night;
+            }
+        };
+    }
+    
+    @Override
+    public WaitTipRes overrideWaitTipRes() {
+        return new WaitTipRes() {
+            @Override
+            public boolean blurBackground() {
+                return false;
+            }
+            
+            @Override
+            public int overrideBackgroundColorRes(boolean light) {
+                return 0;
+            }
+            
+            @Override
+            public int overrideTextColorRes(boolean light) {
+                return light ? R.color.white : R.color.black;
+            }
+        };
+    }
+    
+    @Override
+    public BottomDialogRes overrideBottomDialogRes() {
+        return new BottomDialogRes() {
+            
+            @Override
+            public boolean touchSlide() {
+                return true;
+            }
+            
+            @Override
+            public int overrideDialogLayout(boolean light) {
+                return light ? R.layout.layout_dialogx_bottom_material : R.layout.layout_dialogx_bottom_material_dark;
+            }
+            
+            @Override
+            public int overrideMenuDividerDrawableRes(boolean light) {
+                return light ? R.drawable.rect_dialogx_material_menu_split_divider : R.drawable.rect_dialogx_material_menu_split_divider_night;
+            }
+            
+            @Override
+            public int overrideMenuDividerHeight(boolean light) {
+                return 1;
+            }
+            
+            @Override
+            public int overrideMenuTextColor(boolean light) {
+                return light?R.color.black90:R.color.white90;
+            }
+            
+            @Override
+            public float overrideBottomDialogMaxHeight() {
+                return 0.6f;
+            }
+            
+            @Override
+            public int overrideMenuCancelButtonBackgroundRes(boolean b) {
+                return 0;
+            }
+            
+            @Override
+            public int overrideMenuItemLayout(boolean b, int i, int i1) {
+                return R.layout.item_dialogx_material_bottom_menu_normal_text;
+            }
+        };
+    }
+}

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

@@ -167,9 +167,4 @@ public class MaterialStyle implements DialogXStyle {
     
         };
     }
-    
-    private int dip2px(float dpValue) {
-        final float scale = Resources.getSystem().getDisplayMetrics().density;
-        return (int) (dpValue * scale + 0.5f);
-    }
 }

+ 7 - 0
DialogX/src/main/res/values/colors.xml

@@ -34,4 +34,11 @@
     <color name="dialogxWaitBkgLight">#CCF4F5F6</color>
     <color name="dialogxWaitBkgDark">#D1161616</color>
 
+    <color name="dialogxKongzueLightOkButtonBkgColor">#E1E9F1</color>
+    <color name="dialogxKongzueLightOkButtonBkgColorPress">#CEDAE6</color>
+    <color name="dialogxKongzueLightOtherButtonBkgColor">#F4F5F6</color>
+    <color name="dialogxKongzueLightOtherButtonBkgColorPress">#E6E8EA</color>
+    <color name="dialogxKongzueDarkBkgColor">#181818</color>
+    <color name="dialogxKongzueDarkButtonBkgColor">#272727</color>
+    <color name="dialogxKongzueDarkButtonBkgColorPress">#33363B</color>
 </resources>

+ 1 - 0
DialogXKongzueStyle/src/main/res/values/colors.xml

@@ -31,6 +31,7 @@
     <color name="white10">#1Affffff</color>
 
     <color name="dialogxColorBlue">#2196F3</color>
+
     <color name="dialogxKongzueLightOkButtonBkgColor">#E1E9F1</color>
     <color name="dialogxKongzueLightOkButtonBkgColorPress">#CEDAE6</color>
     <color name="dialogxKongzueLightOtherButtonBkgColor">#F4F5F6</color>

+ 22 - 7
app/src/main/java/com/kongzue/dialogxdemo/MainActivity.java

@@ -33,6 +33,7 @@ import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener;
 import com.kongzue.dialogx.interfaces.OnIconChangeCallBack;
 import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
+import com.kongzue.dialogx.style.BuildStyle;
 import com.kongzue.dialogx.style.IOSStyle;
 import com.kongzue.dialogx.style.KongzueStyle;
 import com.kongzue.dialogx.style.MIUIStyle;
@@ -120,7 +121,7 @@ public class MainActivity extends BaseActivity {
     
     @Override
     public void initDatas(JumpParameter parameter) {
-        DialogX.globalStyle = IOSStyle.style();
+        DialogX.globalStyle = BuildStyle.style();
     }
     
     //用于模拟进度提示
@@ -183,10 +184,12 @@ public class MainActivity extends BaseActivity {
         btnSelectDialog.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                new MessageDialog("多选对话框", "移动App会将它从主屏幕移除并保留其所有数据。", "删除App", "取消", "移至App资源库")
-                        .setButtonOrientation(LinearLayout.VERTICAL)
-                        .setOkTextInfo(new TextInfo().setFontColor(Color.parseColor("#EB5545")))
-                        .show();
+                MessageDialog messageDialog = new MessageDialog("多选对话框", "移除App会将它从主屏幕移除并保留其所有数据。", "删除App", "取消", "移至App资源库")
+                        .setButtonOrientation(LinearLayout.VERTICAL);
+                if (!rdoMiui.isChecked()){
+                    messageDialog.setOkTextInfo(new TextInfo().setFontColor(Color.parseColor("#EB5545")));
+                }
+                messageDialog.show();
             }
         });
         
@@ -200,7 +203,13 @@ public class MainActivity extends BaseActivity {
         btnWaitDialog.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                WaitDialog.show("Please Wait!");
+                WaitDialog.show("Please Wait!").setOnBackPressedListener(new OnBackPressedListener() {
+                    @Override
+                    public boolean onBackPressed() {
+                        toast("按下返回");
+                        return false;
+                    }
+                });
                 runDelayed(new Runnable() {
                     @Override
                     public void run() {
@@ -213,7 +222,13 @@ public class MainActivity extends BaseActivity {
         btnWaitAndTipDialog.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                WaitDialog.show("Please Wait!");
+                WaitDialog.show("Please Wait!").setOnBackPressedListener(new OnBackPressedListener() {
+                    @Override
+                    public boolean onBackPressed() {
+                        toast("按下返回");
+                        return false;
+                    }
+                });
                 runDelayed(new Runnable() {
                     @Override
                     public void run() {