Ver Fonte

0.0.47.beta1

kongzue há 2 anos atrás
pai
commit
099f3ed4fb

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

@@ -333,7 +333,7 @@ public class BottomDialog extends BaseDialog {
                     
                     isShow = true;
                     preShow = false;
-    
+                    
                     lifecycle.setCurrentState(Lifecycle.State.CREATED);
                     getDialogLifecycleCallback().onShow(me);
                     
@@ -438,7 +438,7 @@ public class BottomDialog extends BaseDialog {
                         if (onBackPressedListener.onBackPressed(me)) {
                             dismiss();
                         }
-                    }else{
+                    } else {
                         if (isCancelable()) {
                             dismiss();
                         }
@@ -470,6 +470,7 @@ public class BottomDialog extends BaseDialog {
             if (boxRoot == null || getTopActivity() == null) {
                 return;
             }
+            boxRoot.setRootPadding(screenPaddings[0], screenPaddings[1], screenPaddings[2], screenPaddings[3]);
             if (backgroundColor != -1) {
                 tintColor(bkg, backgroundColor);
                 if (blurView != null && cancelBlurView != null) {
@@ -661,7 +662,7 @@ public class BottomDialog extends BaseDialog {
                             } else if (bottomDialogMaxHeight > 1) {
                                 customDialogTop = boxBkg.getHeight() - bottomDialogMaxHeight;
                             }
-                            boxBkg.setPadding(0,0,0, (int) customDialogTop);
+                            boxBkg.setPadding(0, 0, 0, (int) customDialogTop);
                         }
                         
                         //上移动画
@@ -1175,4 +1176,16 @@ public class BottomDialog extends BaseDialog {
         this.dialogXAnimImpl = dialogXAnimImpl;
         return this;
     }
+    
+    public BottomDialog setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public BottomDialog setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

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

@@ -1180,4 +1180,16 @@ public class BottomMenu extends BottomDialog {
         this.dialogXAnimImpl = dialogXAnimImpl;
         return this;
     }
+    
+    public BottomMenu setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public BottomMenu setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

+ 13 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/CustomDialog.java

@@ -244,6 +244,7 @@ public class CustomDialog extends BaseDialog {
             if (boxRoot == null || getTopActivity() == null) {
                 return;
             }
+            boxRoot.setRootPadding(screenPaddings[0],screenPaddings[1],screenPaddings[2],screenPaddings[3]);
             if (baseView != null) {
                 if (!initSetCustomViewLayoutListener) {
                     RelativeLayout.LayoutParams rlp;
@@ -943,4 +944,16 @@ public class CustomDialog extends BaseDialog {
         this.dialogXAnimImpl = dialogXAnimImpl;
         return this;
     }
+    
+    public CustomDialog setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public CustomDialog setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

+ 13 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/FullScreenDialog.java

@@ -277,6 +277,7 @@ public class FullScreenDialog extends BaseDialog {
             if (boxRoot == null || getTopActivity() == null) {
                 return;
             }
+            boxRoot.setRootPadding(screenPaddings[0],screenPaddings[1],screenPaddings[2],screenPaddings[3]);
             if (backgroundColor != -1) {
                 tintColor(bkg, backgroundColor);
             }
@@ -667,4 +668,16 @@ public class FullScreenDialog extends BaseDialog {
         this.dialogXAnimImpl = dialogXAnimImpl;
         return this;
     }
+    
+    public FullScreenDialog setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public FullScreenDialog setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

+ 12 - 0
DialogX/src/main/java/com/kongzue/dialogx/dialogs/GuideDialog.java

@@ -698,4 +698,16 @@ public class GuideDialog extends CustomDialog {
         this.dialogXAnimImpl = dialogXAnimImpl;
         return this;
     }
+    
+    public GuideDialog setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public GuideDialog setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

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

@@ -640,4 +640,16 @@ public class InputDialog extends MessageDialog {
         this.dialogXAnimImpl = dialogXAnimImpl;
         return this;
     }
+    
+    public InputDialog setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public InputDialog setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

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

@@ -487,6 +487,7 @@ public class MessageDialog extends BaseDialog {
             if (boxRoot == null || getTopActivity() == null) {
                 return;
             }
+            boxRoot.setRootPadding(screenPaddings[0],screenPaddings[1],screenPaddings[2],screenPaddings[3]);
             if (backgroundColor != -1) {
                 tintColor(bkg, backgroundColor);
                 if (style instanceof MaterialStyle) {
@@ -1306,4 +1307,16 @@ public class MessageDialog extends BaseDialog {
         this.dialogXAnimImpl = dialogXAnimImpl;
         return this;
     }
+    
+    public MessageDialog setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public MessageDialog setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

+ 31 - 5
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopMenu.java

@@ -37,6 +37,7 @@ import com.kongzue.dialogx.interfaces.OnBackgroundMaskClickListener;
 import com.kongzue.dialogx.interfaces.OnBindView;
 import com.kongzue.dialogx.interfaces.OnIconChangeCallBack;
 import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
+import com.kongzue.dialogx.util.BottomMenuArrayAdapter;
 import com.kongzue.dialogx.util.ObjectRunnable;
 import com.kongzue.dialogx.util.PopMenuArrayAdapter;
 import com.kongzue.dialogx.util.TextInfo;
@@ -80,6 +81,7 @@ public class PopMenu extends BaseDialog {
     protected float backgroundRadius = -1;
     protected DialogXAnimInterface<PopMenu> dialogXAnimImpl;
     protected OnBackPressedListener<PopMenu> onBackPressedListener;
+    protected int pressedIndex = -1;
     
     protected int alignGravity = -1;                                        //指定菜单相对 baseView 的位置
     
@@ -270,11 +272,11 @@ public class PopMenu extends BaseDialog {
     
     public class DialogImpl implements DialogConvertViewInterface {
         
-        private DialogXBaseRelativeLayout boxRoot;
-        private MaxRelativeLayout boxBody;
-        private RelativeLayout boxCustom;
-        private PopMenuListView listMenu;
-        private BlurView blurView;
+        public DialogXBaseRelativeLayout boxRoot;
+        public MaxRelativeLayout boxBody;
+        public RelativeLayout boxCustom;
+        public PopMenuListView listMenu;
+        public BlurView blurView;
         
         public DialogImpl(View convertView) {
             boxRoot = convertView.findViewById(R.id.box_root);
@@ -381,6 +383,7 @@ public class PopMenu extends BaseDialog {
             if (boxRoot == null || getTopActivity() == null) {
                 return;
             }
+            boxRoot.setRootPadding(screenPaddings[0],screenPaddings[1],screenPaddings[2],screenPaddings[3]);
             if (listMenu.getAdapter() == null) {
                 listMenu.setAdapter(menuListAdapter);
             } else {
@@ -439,6 +442,7 @@ public class PopMenu extends BaseDialog {
                 boxBody.setMaxHeight(height);
                 boxBody.setMinimumHeight(height);
             }
+            
             onDialogRefreshUI();
         }
         
@@ -1051,4 +1055,26 @@ public class PopMenu extends BaseDialog {
         refreshUI();
         return this;
     }
+    
+    public PopMenu setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public PopMenu setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
+    
+    public int getPressedIndex() {
+        return pressedIndex;
+    }
+    
+    public PopMenu setPressedIndex(int pressedIndex) {
+        this.pressedIndex = pressedIndex;
+        refreshUI();
+        return this;
+    }
 }

+ 20 - 7
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopNotification.java

@@ -488,13 +488,13 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
     
     public class DialogImpl implements DialogConvertViewInterface {
         
-        private DialogXBaseRelativeLayout boxRoot;
-        private ViewGroup boxBody;
-        private ImageView imgDialogxPopIcon;
-        private TextView txtDialogxPopTitle;
-        private TextView txtDialogxPopMessage;
-        private TextView txtDialogxButton;
-        private RelativeLayout boxCustom;
+        public DialogXBaseRelativeLayout boxRoot;
+        public ViewGroup boxBody;
+        public ImageView imgDialogxPopIcon;
+        public TextView txtDialogxPopTitle;
+        public TextView txtDialogxPopMessage;
+        public TextView txtDialogxButton;
+        public RelativeLayout boxCustom;
         
         public BlurView blurView;
         
@@ -650,6 +650,7 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
             if (boxRoot == null || getTopActivity() == null) {
                 return;
             }
+            boxRoot.setRootPadding(screenPaddings[0],screenPaddings[1],screenPaddings[2],screenPaddings[3]);
             if (backgroundColor != -1) {
                 tintColor(boxBody, backgroundColor);
             }
@@ -1335,4 +1336,16 @@ public class PopNotification extends BaseDialog implements NoTouchInterface {
         this.dialogXAnimImpl = dialogXAnimImpl;
         return this;
     }
+    
+    public PopNotification setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public PopNotification setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

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

@@ -564,6 +564,7 @@ public class PopTip extends BaseDialog implements NoTouchInterface {
             if (boxRoot == null || getTopActivity() == null) {
                 return;
             }
+            boxRoot.setRootPadding(screenPaddings[0],screenPaddings[1],screenPaddings[2],screenPaddings[3]);
             if (backgroundColor != -1) {
                 tintColor(boxBody, backgroundColor);
             }
@@ -1184,4 +1185,16 @@ public class PopTip extends BaseDialog implements NoTouchInterface {
         this.dialogXAnimImpl = dialogXAnimImpl;
         return this;
     }
+    
+    public PopTip setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public PopTip setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

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

@@ -204,4 +204,16 @@ public class TipDialog extends WaitDialog {
         refreshUI();
         return this;
     }
+    
+    public TipDialog setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public TipDialog setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

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

@@ -349,7 +349,7 @@ public class WaitDialog extends BaseDialog {
                             
                             onDialogShow();
                             getDialogLifecycleCallback().onShow(me());
-    
+                            
                             lifecycle.setCurrentState(Lifecycle.State.RESUMED);
                         }
                     });
@@ -388,7 +388,7 @@ public class WaitDialog extends BaseDialog {
                         if (onBackPressedListener.onBackPressed(WaitDialog.this)) {
                             dismiss();
                         }
-                    }else{
+                    } else {
                         if (isCancelable()) {
                             dismiss();
                         }
@@ -405,6 +405,7 @@ public class WaitDialog extends BaseDialog {
             if (boxRoot == null || getTopActivity() == null) {
                 return;
             }
+            boxRoot.setRootPadding(screenPaddings[0], screenPaddings[1], screenPaddings[2], screenPaddings[3]);
             
             bkg.setMaxWidth(getMaxWidth());
             
@@ -1104,4 +1105,16 @@ public class WaitDialog extends BaseDialog {
         this.dialogXAnimImpl = dialogXAnimImpl;
         return this;
     }
+    
+    public WaitDialog setRootPadding(int padding) {
+        this.screenPaddings = new int[]{padding, padding, padding, padding};
+        refreshUI();
+        return this;
+    }
+    
+    public WaitDialog setRootPadding(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) {
+        this.screenPaddings = new int[]{paddingLeft, paddingTop, paddingRight, paddingBottom};
+        refreshUI();
+        return this;
+    }
 }

+ 1 - 0
DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java

@@ -463,6 +463,7 @@ public abstract class BaseDialog implements LifecycleOwner {
     protected long enterAnimDuration = -1;
     protected long exitAnimDuration = -1;
     protected int maxWidth;
+    protected int[] screenPaddings = new int[4];
     
     public BaseDialog() {
         cancelable = DialogX.cancelable;

+ 18 - 8
DialogX/src/main/java/com/kongzue/dialogx/util/PopMenuArrayAdapter.java

@@ -11,6 +11,7 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.widget.BaseAdapter;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.Space;
 import android.widget.TextView;
 
@@ -78,9 +79,10 @@ public class PopMenuArrayAdapter extends BaseAdapter {
             
             convertView = mInflater.inflate(resourceId, null);
             
+            viewHolder.boxItem = convertView.findViewById(R.id.box_item);
             viewHolder.imgDialogxMenuIcon = convertView.findViewById(R.id.img_dialogx_menu_icon);
             viewHolder.txtDialogxMenuText = convertView.findViewById(R.id.txt_dialogx_menu_text);
-            viewHolder.spaceRightPadding = convertView.findViewById(R.id.space_dialogx_right_padding);
+            viewHolder.spaceDialogxRightPadding = convertView.findViewById(R.id.space_dialogx_right_padding);
             
             convertView.setTag(viewHolder);
         } else {
@@ -90,6 +92,11 @@ public class PopMenuArrayAdapter extends BaseAdapter {
         if (customBackgroundRes != 0) {
             convertView.setBackgroundResource(customBackgroundRes);
         }
+        if (popMenu.getPressedIndex() == position) {
+            viewHolder.boxItem.setBackgroundResource(popMenu.isLightTheme() ? R.color.black5 : R.color.white5);
+        } else {
+            viewHolder.boxItem.setBackgroundResource(R.color.empty);
+        }
         viewHolder.imgDialogxMenuIcon.setVisibility(View.GONE);
         viewHolder.txtDialogxMenuText.setText(menuList.get(position));
         if (popMenu.getStyle().popMenuSettings() != null && popMenu.getStyle().popMenuSettings().paddingVertical() != 0) {
@@ -117,8 +124,8 @@ public class PopMenuArrayAdapter extends BaseAdapter {
                 viewHolder.imgDialogxMenuIcon.setVisibility(View.VISIBLE);
                 viewHolder.imgDialogxMenuIcon.setImageResource(resId);
                 if (isHaveProperties(viewHolder.txtDialogxMenuText.getGravity(), Gravity.CENTER) || isHaveProperties(viewHolder.txtDialogxMenuText.getGravity(), Gravity.CENTER_HORIZONTAL)) {
-                    if (viewHolder.spaceRightPadding != null) {
-                        viewHolder.spaceRightPadding.setVisibility(View.VISIBLE);
+                    if (viewHolder.spaceDialogxRightPadding != null) {
+                        viewHolder.spaceDialogxRightPadding.setVisibility(View.VISIBLE);
                     }
                 }
                 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@@ -128,14 +135,14 @@ public class PopMenuArrayAdapter extends BaseAdapter {
                 }
             } else {
                 viewHolder.imgDialogxMenuIcon.setVisibility(View.GONE);
-                if (viewHolder.spaceRightPadding != null) {
-                    viewHolder.spaceRightPadding.setVisibility(View.GONE);
+                if (viewHolder.spaceDialogxRightPadding != null) {
+                    viewHolder.spaceDialogxRightPadding.setVisibility(View.GONE);
                 }
             }
         } else {
             viewHolder.imgDialogxMenuIcon.setVisibility(View.GONE);
-            if (viewHolder.spaceRightPadding != null) {
-                viewHolder.spaceRightPadding.setVisibility(View.GONE);
+            if (viewHolder.spaceDialogxRightPadding != null) {
+                viewHolder.spaceDialogxRightPadding.setVisibility(View.GONE);
             }
         }
         return convertView;
@@ -146,8 +153,11 @@ public class PopMenuArrayAdapter extends BaseAdapter {
     }
     
     class ViewHolder {
+        LinearLayout boxItem;
         ImageView imgDialogxMenuIcon;
         TextView txtDialogxMenuText;
-        Space spaceRightPadding;
+        Space spaceDialogxRightPadding;
+        
+        
     }
 }

+ 11 - 3
DialogX/src/main/java/com/kongzue/dialogx/util/views/DialogXBaseRelativeLayout.java

@@ -238,11 +238,11 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
             if (bkgLp.getRules()[ALIGN_PARENT_BOTTOM] == RelativeLayout.TRUE && isAutoUnsafePlacePadding()) {
                 bkgView.setPadding(0, 0, 0, bottom);
                 bkgView.setNavBarHeight(bottom);
-                setPadding(left, top, right, 0);
+                setPadding(extraPadding[0]+left,extraPadding[1]+ top, extraPadding[2]+right, extraPadding[3]);
                 return;
             }
         }
-        if (isAutoUnsafePlacePadding()) setPadding(left, top, right, bottom);
+        if (isAutoUnsafePlacePadding()) setPadding(extraPadding[0]+left, extraPadding[1]+top, extraPadding[2]+right, extraPadding[3]+bottom);
     }
     
     public DialogXBaseRelativeLayout setOnBackPressedListener(PrivateBackPressedListener onBackPressedListener) {
@@ -270,7 +270,7 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
     public DialogXBaseRelativeLayout setAutoUnsafePlacePadding(boolean autoUnsafePlacePadding) {
         this.autoUnsafePlacePadding = autoUnsafePlacePadding;
         if (!autoUnsafePlacePadding) {
-            setPadding(0, 0, 0, 0);
+            setPadding(extraPadding[0], extraPadding[1], extraPadding[2], extraPadding[3]);
         }
         return this;
     }
@@ -345,4 +345,12 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         boolean onBackPressed();
     }
     
+    int[] extraPadding = new int[4];
+    
+    public void setRootPadding(int left, int top, int right, int bottom) {
+        extraPadding[0] = left;
+        extraPadding[1] = top;
+        extraPadding[2] = right;
+        extraPadding[3] = bottom;
+    }
 }

+ 1 - 0
DialogX/src/main/res/layout/item_dialogx_material_context_menu_normal_text.xml

@@ -3,6 +3,7 @@
     android:layout_height="wrap_content">
 
     <LinearLayout
+        android:id="@+id/box_item"
         android:layout_width="match_parent"
         android:layout_height="48dp"
         android:gravity="center_vertical"

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

@@ -15,6 +15,7 @@
     <color name="black25">#40000000</color>
     <color name="black20">#33000000</color>
     <color name="black10">#1A000000</color>
+    <color name="black5">#0D000000</color>
     <color name="empty">#00000000</color>
 
     <color name="white">#fff</color>
@@ -29,6 +30,7 @@
     <color name="white25">#40ffffff</color>
     <color name="white20">#33ffffff</color>
     <color name="white10">#1Affffff</color>
+    <color name="white5">#0DFFFFFF</color>
 
     <color name="dialogxColorBlue">#2196F3</color>
 

BIN
app/release/app-release.apk


+ 2 - 2
app/release/output-metadata.json

@@ -10,8 +10,8 @@
     {
       "type": "SINGLE",
       "filters": [],
-      "versionCode": 45,
-      "versionName": "0.0.46.beta15",
+      "versionCode": 46,
+      "versionName": "0.0.46",
       "outputFile": "app-release.apk"
     }
   ]

+ 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.46
+BUILD_VERSION=0.0.47.beta1
 BUILD_VERSION_INT=46