فهرست منبع

0.0.45.beta23

kongzue 3 سال پیش
والد
کامیت
46b0cf3ec2

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

@@ -24,6 +24,7 @@ import com.kongzue.dialogx.interfaces.DialogConvertViewInterface;
 import com.kongzue.dialogx.interfaces.DialogLifecycleCallback;
 import com.kongzue.dialogx.interfaces.DialogXStyle;
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
+import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener;
 import com.kongzue.dialogx.interfaces.ScrollController;
@@ -59,6 +60,7 @@ public class BottomDialog extends BaseDialog {
     protected OnDialogButtonClickListener<BottomDialog> otherButtonClickListener;
     protected BOOLEAN privateCancelable;
     protected boolean bkgInterceptTouch = true;
+    protected OnBackgroundMaskClickListener<BottomDialog> onBackgroundMaskClickListener;
     
     protected TextInfo titleTextInfo;
     protected TextInfo messageTextInfo;
@@ -485,7 +487,9 @@ public class BottomDialog extends BaseDialog {
                     boxRoot.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View v) {
-                            doDismiss(v);
+                            if (onBackgroundMaskClickListener == null || !onBackgroundMaskClickListener.onClick(me, v)) {
+                                doDismiss(v);
+                            }
                         }
                     });
                 } else {
@@ -1000,4 +1004,13 @@ public class BottomDialog extends BaseDialog {
         this.bkgInterceptTouch = bkgInterceptTouch;
         return this;
     }
+    
+    public OnBackgroundMaskClickListener<BottomDialog> getOnBackgroundMaskClickListener() {
+        return (OnBackgroundMaskClickListener<BottomDialog>) onBackgroundMaskClickListener;
+    }
+    
+    public BottomDialog setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<BottomDialog> onBackgroundMaskClickListener) {
+        this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
+        return this;
+    }
 }

+ 10 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomMenu.java

@@ -17,6 +17,7 @@ import com.kongzue.dialogx.interfaces.DialogLifecycleCallback;
 import com.kongzue.dialogx.interfaces.DialogXStyle;
 import com.kongzue.dialogx.interfaces.MenuItemTextInfoInterceptor;
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
+import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener;
 import com.kongzue.dialogx.interfaces.OnIconChangeCallBack;
@@ -1125,4 +1126,13 @@ public class BottomMenu extends BottomDialog {
         this.bkgInterceptTouch = bkgInterceptTouch;
         return this;
     }
+    
+    public OnBackgroundMaskClickListener<BottomDialog> getOnBackgroundMaskClickListener() {
+        return onBackgroundMaskClickListener;
+    }
+    
+    public BottomMenu setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<BottomDialog> onBackgroundMaskClickListener) {
+        this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
+        return this;
+    }
 }

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

@@ -21,6 +21,7 @@ import com.kongzue.dialogx.interfaces.DialogConvertViewInterface;
 import com.kongzue.dialogx.interfaces.DialogLifecycleCallback;
 import com.kongzue.dialogx.interfaces.DialogXStyle;
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
+import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.util.views.DialogXBaseRelativeLayout;
 import com.kongzue.dialogx.util.views.MaxRelativeLayout;
@@ -55,6 +56,7 @@ public class CustomDialog extends BaseDialog {
     protected int maskColor = Color.TRANSPARENT;
     protected BOOLEAN privateCancelable;
     protected boolean bkgInterceptTouch = true;
+    protected OnBackgroundMaskClickListener<CustomDialog> onBackgroundMaskClickListener;
     
     protected View baseView;
     protected int alignViewGravity = -1;                                    //指定菜单相对 baseView 的位置
@@ -340,7 +342,9 @@ public class CustomDialog extends BaseDialog {
                     boxRoot.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View v) {
-                            doDismiss(v);
+                            if (onBackgroundMaskClickListener == null || !onBackgroundMaskClickListener.onClick(me, v)) {
+                                doDismiss(v);
+                            }
                         }
                     });
                 } else {
@@ -758,4 +762,13 @@ public class CustomDialog extends BaseDialog {
         refreshUI();
         return this;
     }
+    
+    public OnBackgroundMaskClickListener<CustomDialog> getOnBackgroundMaskClickListener() {
+        return onBackgroundMaskClickListener;
+    }
+    
+    public CustomDialog setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<CustomDialog> onBackgroundMaskClickListener) {
+        this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
+        return this;
+    }
 }

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

@@ -20,6 +20,7 @@ import com.kongzue.dialogx.interfaces.DialogConvertViewInterface;
 import com.kongzue.dialogx.interfaces.DialogLifecycleCallback;
 import com.kongzue.dialogx.interfaces.DialogXStyle;
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
+import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.OnSafeInsetsChangeListener;
 import com.kongzue.dialogx.interfaces.ScrollController;
@@ -46,6 +47,7 @@ public class FullScreenDialog extends BaseDialog {
     protected boolean hideZoomBackground;
     
     protected DialogLifecycleCallback<FullScreenDialog> dialogLifecycleCallback;
+    protected OnBackgroundMaskClickListener<FullScreenDialog> onBackgroundMaskClickListener;
     
     protected FullScreenDialog me = this;
     
@@ -261,7 +263,9 @@ public class FullScreenDialog extends BaseDialog {
                 boxRoot.setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View v) {
-                        doDismiss(v);
+                        if (onBackgroundMaskClickListener == null || !onBackgroundMaskClickListener.onClick(me, v)) {
+                            doDismiss(v);
+                        }
                     }
                 });
             } else {
@@ -526,4 +530,13 @@ public class FullScreenDialog extends BaseDialog {
         this.dialogImplMode = dialogImplMode;
         return this;
     }
+    
+    public OnBackgroundMaskClickListener<FullScreenDialog> getOnBackgroundMaskClickListener() {
+        return onBackgroundMaskClickListener;
+    }
+    
+    public FullScreenDialog setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<FullScreenDialog> onBackgroundMaskClickListener) {
+        this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
+        return this;
+    }
 }

+ 10 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/InputDialog.java

@@ -8,6 +8,7 @@ import androidx.annotation.ColorRes;
 import com.kongzue.dialogx.DialogX;
 import com.kongzue.dialogx.R;
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
+import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.OnInputDialogButtonClickListener;
 import com.kongzue.dialogx.util.InputInfo;
@@ -586,4 +587,13 @@ public class InputDialog extends MessageDialog {
         this.bkgInterceptTouch = bkgInterceptTouch;
         return this;
     }
+    
+    public OnBackgroundMaskClickListener<MessageDialog> getOnBackgroundMaskClickListener() {
+        return  onBackgroundMaskClickListener;
+    }
+
+    public InputDialog setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<MessageDialog> onBackgroundMaskClickListener) {
+        this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
+        return this;
+    }
 }

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

@@ -30,6 +30,7 @@ import com.kongzue.dialogx.interfaces.DialogConvertViewInterface;
 import com.kongzue.dialogx.interfaces.DialogLifecycleCallback;
 import com.kongzue.dialogx.interfaces.DialogXStyle;
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
+import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener;
 import com.kongzue.dialogx.interfaces.OnInputDialogButtonClickListener;
@@ -61,7 +62,8 @@ public class MessageDialog extends BaseDialog {
     protected int customEnterAnimResId;
     protected int customExitAnimResId;
     
-    private DialogLifecycleCallback<MessageDialog> dialogLifecycleCallback;
+    protected DialogLifecycleCallback<MessageDialog> dialogLifecycleCallback;
+    protected OnBackgroundMaskClickListener<MessageDialog> onBackgroundMaskClickListener;
     
     protected MessageDialog() {
         super();
@@ -649,7 +651,9 @@ public class MessageDialog extends BaseDialog {
                     boxRoot.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View v) {
-                            doDismiss(v);
+                            if (onBackgroundMaskClickListener == null || !onBackgroundMaskClickListener.onClick(me, v)) {
+                                doDismiss(v);
+                            }
                         }
                     });
                 } else {
@@ -1135,4 +1139,13 @@ public class MessageDialog extends BaseDialog {
         this.bkgInterceptTouch = bkgInterceptTouch;
         return this;
     }
+    
+    public OnBackgroundMaskClickListener<MessageDialog> getOnBackgroundMaskClickListener() {
+        return (OnBackgroundMaskClickListener<MessageDialog>) onBackgroundMaskClickListener;
+    }
+    
+    public MessageDialog setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<MessageDialog> onBackgroundMaskClickListener) {
+        this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
+        return this;
+    }
 }

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

@@ -26,6 +26,7 @@ import com.kongzue.dialogx.interfaces.BaseDialog;
 import com.kongzue.dialogx.interfaces.DialogConvertViewInterface;
 import com.kongzue.dialogx.interfaces.DialogLifecycleCallback;
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
+import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.OnIconChangeCallBack;
 import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
@@ -56,6 +57,7 @@ public class PopMenu extends BaseDialog {
     protected boolean bkgInterceptTouch = true;
     protected OnBindView<PopMenu> onBindView;                               //自定义布局
     protected DialogLifecycleCallback<PopMenu> dialogLifecycleCallback;     //对话框生命周期
+    protected OnBackgroundMaskClickListener<PopMenu> onBackgroundMaskClickListener;
     protected View dialogView;
     protected List<CharSequence> menuList;
     protected DialogImpl dialogImpl;
@@ -563,7 +565,9 @@ public class PopMenu extends BaseDialog {
                     boxRoot.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View v) {
-                            doDismiss(v);
+                            if (onBackgroundMaskClickListener == null || !onBackgroundMaskClickListener.onClick(me, v)) {
+                                doDismiss(v);
+                            }
                         }
                     });
                 } else {
@@ -902,4 +906,13 @@ public class PopMenu extends BaseDialog {
         this.bkgInterceptTouch = bkgInterceptTouch;
         return this;
     }
+    
+    public OnBackgroundMaskClickListener<PopMenu> getOnBackgroundMaskClickListener() {
+        return onBackgroundMaskClickListener;
+    }
+    
+    public PopMenu setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<PopMenu> onBackgroundMaskClickListener) {
+        this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
+        return this;
+    }
 }

+ 13 - 5
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopTip.java

@@ -72,7 +72,7 @@ public class PopTip extends BaseDialog {
     
     protected TextInfo messageTextInfo;
     protected TextInfo buttonTextInfo = new TextInfo().setBold(true);
-    protected int[] bodyMargin = new int[4];
+    protected int[] bodyMargin = new int[]{-1, -1, -1, -1};
     
     protected PopTip() {
         super();
@@ -462,10 +462,6 @@ public class PopTip extends BaseDialog {
             RelativeLayout.LayoutParams rlp;
             rlp = ((RelativeLayout.LayoutParams) boxBody.getLayoutParams());
             if (align == null) align = DialogXStyle.PopTipSettings.ALIGN.BOTTOM;
-            rlp.leftMargin = bodyMargin[0];
-            rlp.topMargin = bodyMargin[1];
-            rlp.rightMargin = bodyMargin[2];
-            rlp.bottomMargin = bodyMargin[3];
             switch (align) {
                 case TOP:
                     rlp.removeRule(RelativeLayout.CENTER_IN_PARENT);
@@ -584,6 +580,13 @@ public class PopTip extends BaseDialog {
                 boxBody.setOnClickListener(null);
                 boxBody.setClickable(false);
             }
+            
+            RelativeLayout.LayoutParams rlp = ((RelativeLayout.LayoutParams) boxBody.getLayoutParams());
+            if (bodyMargin[0] != -1) rlp.leftMargin = bodyMargin[0];
+            if (bodyMargin[1] != -1) rlp.topMargin = bodyMargin[1];
+            if (bodyMargin[2] != -1) rlp.rightMargin = bodyMargin[2];
+            if (bodyMargin[3] != -1) rlp.bottomMargin = bodyMargin[3];
+            boxBody.setLayoutParams(rlp);
         }
         
         @Override
@@ -983,26 +986,31 @@ public class PopTip extends BaseDialog {
         bodyMargin[1] = top;
         bodyMargin[2] = right;
         bodyMargin[3] = bottom;
+        refreshUI();
         return this;
     }
     
     public PopTip setMarginLeft(int left) {
         bodyMargin[0] = left;
+        refreshUI();
         return this;
     }
     
     public PopTip setMarginTop(int top) {
         bodyMargin[1] = top;
+        refreshUI();
         return this;
     }
     
     public PopTip setMarginRight(int right) {
         bodyMargin[2] = right;
+        refreshUI();
         return this;
     }
     
     public PopTip setMarginBottom(int bottom) {
         bodyMargin[3] = bottom;
+        refreshUI();
         return this;
     }
     

+ 10 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/TipDialog.java

@@ -3,6 +3,7 @@ package com.kongzue.dialogx.dialogs;
 import android.app.Activity;
 
 import com.kongzue.dialogx.DialogX;
+import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
 
 /**
  * @author: Kongzue
@@ -171,4 +172,13 @@ public class TipDialog extends WaitDialog {
         this.bkgInterceptTouch = bkgInterceptTouch;
         return this;
     }
+    
+    public OnBackgroundMaskClickListener<WaitDialog> getOnBackgroundMaskClickListener() {
+        return onBackgroundMaskClickListener;
+    }
+    
+    public TipDialog setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<WaitDialog> onBackgroundMaskClickListener) {
+        this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
+        return this;
+    }
 }

+ 15 - 2
DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java

@@ -24,6 +24,7 @@ import com.kongzue.dialogx.interfaces.BaseDialog;
 import com.kongzue.dialogx.interfaces.DialogConvertViewInterface;
 import com.kongzue.dialogx.interfaces.DialogLifecycleCallback;
 import com.kongzue.dialogx.interfaces.OnBackPressedListener;
+import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.ProgressViewInterface;
 import com.kongzue.dialogx.util.TextInfo;
@@ -69,7 +70,8 @@ public class WaitDialog extends BaseDialog {
     protected int maskColor = -1;
     protected BOOLEAN privateCancelable;
     
-    private DialogLifecycleCallback<WaitDialog> dialogLifecycleCallback;
+    protected DialogLifecycleCallback<WaitDialog> dialogLifecycleCallback;
+    protected OnBackgroundMaskClickListener<WaitDialog> onBackgroundMaskClickListener;
     
     protected WaitDialog() {
         super();
@@ -468,7 +470,9 @@ public class WaitDialog extends BaseDialog {
                     boxRoot.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View v) {
-                            doDismiss(v);
+                            if (onBackgroundMaskClickListener == null || !onBackgroundMaskClickListener.onClick(WaitDialog.this, v)) {
+                                doDismiss(v);
+                            }
                         }
                     });
                 } else {
@@ -972,4 +976,13 @@ public class WaitDialog extends BaseDialog {
         this.bkgInterceptTouch = bkgInterceptTouch;
         return this;
     }
+    
+    public OnBackgroundMaskClickListener<WaitDialog> getOnBackgroundMaskClickListener() {
+        return onBackgroundMaskClickListener;
+    }
+    
+    public WaitDialog setOnBackgroundMaskClickListener(OnBackgroundMaskClickListener<WaitDialog> onBackgroundMaskClickListener) {
+        this.onBackgroundMaskClickListener = onBackgroundMaskClickListener;
+        return this;
+    }
 }

+ 14 - 0
DialogX/src/main/java/com/kongzue/dialogx/interfaces/OnBackgroundMaskClickListener.java

@@ -0,0 +1,14 @@
+package com.kongzue.dialogx.interfaces;
+
+import android.view.View;
+
+/**
+ * @author: Kongzue
+ * @github: https://github.com/kongzue/
+ * @homepage: http://kongzue.com/
+ * @mail: myzcxhh@live.cn
+ * @createTime: 2022/7/8 16:27
+ */
+public interface OnBackgroundMaskClickListener<D extends BaseDialog> {
+    boolean onClick(D dialog, View v);
+}

+ 1 - 1
gradle.properties

@@ -19,5 +19,5 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.45.beta22
+BUILD_VERSION=0.0.45.beta23
 BUILD_VERSION_INT=44