1
0
kongzue 4 жил өмнө
parent
commit
e824892688

+ 3 - 12
.idea/codeStyles/Project.xml

@@ -3,18 +3,9 @@
     <JetCodeStyleSettings>
       <option name="PACKAGES_TO_USE_STAR_IMPORTS">
         <value>
-          <package name="java.util" alias="false" withSubpackages="false" />
-          <package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
-          <package name="io.ktor" alias="false" withSubpackages="true" />
-        </value>
-      </option>
-      <option name="PACKAGES_IMPORT_LAYOUT">
-        <value>
-          <package name="" alias="false" withSubpackages="true" />
-          <package name="java" alias="false" withSubpackages="true" />
-          <package name="javax" alias="false" withSubpackages="true" />
-          <package name="kotlin" alias="false" withSubpackages="true" />
-          <package name="" alias="true" withSubpackages="true" />
+          <package name="java.util" withSubpackages="false" static="false" />
+          <package name="kotlinx.android.synthetic" withSubpackages="true" static="false" />
+          <package name="io.ktor" withSubpackages="true" static="false" />
         </value>
       </option>
     </JetCodeStyleSettings>

+ 6 - 0
DialogX/src/main/java/com/kongzue/dialogx/DialogX.java

@@ -89,6 +89,12 @@ public class DialogX {
     //默认 PopTip 文本样式
     public static TextInfo popTextInfo;
     
+    //默认启动对话框动画时长
+    public static long enterAnimDuration = -1;
+    
+    //默认关闭对话框动画时长
+    public static long exitAnimDuration = -1;
+    
     //全局 Dialog 生命周期监听器
     public static DialogLifecycleCallback<BaseDialog> dialogLifeCycleListener;
     

+ 38 - 9
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomDialog.java

@@ -387,9 +387,16 @@ public class BottomDialog extends BaseDialog {
             boxRoot.post(new Runnable() {
                 @Override
                 public void run() {
-                    boxRoot.animate().setDuration(300).alpha(1f).setInterpolator(new DecelerateInterpolator()).setDuration(100).setListener(null);
+                    boxRoot.animate()
+                            .setDuration(enterAnimDuration == -1 ? 300 : enterAnimDuration)
+                            .alpha(1f)
+                            .setInterpolator(new DecelerateInterpolator())
+                            .setListener(null);
                     
                     Animation enterAnim = AnimationUtils.loadAnimation(getContext(), R.anim.anim_dialogx_bottom_enter);
+                    if (enterAnimDuration != -1) {
+                        enterAnim.setDuration(enterAnimDuration);
+                    }
                     enterAnim.setInterpolator(new DecelerateInterpolator(2f));
                     bkg.startAnimation(enterAnim);
                     
@@ -501,15 +508,19 @@ public class BottomDialog extends BaseDialog {
                 boxContent.getViewTreeObserver().removeOnGlobalLayoutListener(onContentViewLayoutChangeListener);
             
             ObjectAnimator exitAnim = ObjectAnimator.ofFloat(bkg, "y", bkg.getY(), boxBkg.getHeight());
-            exitAnim.setDuration(300);
+            exitAnim.setDuration(exitAnimDuration == -1 ? 300 : exitAnimDuration);
             exitAnim.start();
             
-            boxRoot.animate().setDuration(300).alpha(0f).setInterpolator(new AccelerateInterpolator()).setDuration(exitAnim.getDuration()).setListener(new AnimatorListenerEndCallBack() {
-                @Override
-                public void onAnimationEnd(Animator animation) {
-                    dismiss(dialogView);
-                }
-            });
+            boxRoot.animate()
+                    .alpha(0f)
+                    .setInterpolator(new AccelerateInterpolator())
+                    .setDuration(exitAnim.getDuration())
+                    .setListener(new AnimatorListenerEndCallBack() {
+                        @Override
+                        public void onAnimationEnd(Animator animation) {
+                            dismiss(dialogView);
+                        }
+                    });
         }
         
         public void preDismiss() {
@@ -517,7 +528,7 @@ public class BottomDialog extends BaseDialog {
                 doDismiss(boxRoot);
             } else {
                 ObjectAnimator enterAnim = ObjectAnimator.ofFloat(bkg, "y", bkg.getY(), bkgEnterAimY);
-                enterAnim.setDuration(300);
+                enterAnim.setDuration(exitAnimDuration == -1 ? 300 : exitAnimDuration);
                 enterAnim.start();
             }
         }
@@ -814,4 +825,22 @@ public class BottomDialog extends BaseDialog {
         refreshUI();
         return this;
     }
+    
+    public long getEnterAnimDuration() {
+        return enterAnimDuration;
+    }
+    
+    public BottomDialog setEnterAnimDuration(long enterAnimDuration) {
+        this.enterAnimDuration = enterAnimDuration;
+        return this;
+    }
+    
+    public long getExitAnimDuration() {
+        return exitAnimDuration;
+    }
+    
+    public BottomDialog setExitAnimDuration(long exitAnimDuration) {
+        this.exitAnimDuration = exitAnimDuration;
+        return this;
+    }
 }

+ 29 - 11
DialogX/src/main/java/com/kongzue/dialogx/dialogs/BottomMenu.java

@@ -820,30 +820,30 @@ public class BottomMenu extends BottomDialog {
         return okText;
     }
     
-    public BottomDialog setOkButton(CharSequence okText) {
+    public BottomMenu setOkButton(CharSequence okText) {
         this.okText = okText;
         refreshUI();
         return this;
     }
     
-    public BottomDialog setOkButton(int OkTextResId) {
+    public BottomMenu setOkButton(int OkTextResId) {
         this.okText = getString(OkTextResId);
         refreshUI();
         return this;
     }
     
-    public BottomDialog setOkButton(OnDialogButtonClickListener<BottomDialog> OkButtonClickListener) {
+    public BottomMenu setOkButton(OnDialogButtonClickListener<BottomDialog> OkButtonClickListener) {
         this.okButtonClickListener = OkButtonClickListener;
         return this;
     }
     
-    public BottomDialog setOkButton(CharSequence OkText, OnDialogButtonClickListener<BottomDialog> OkButtonClickListener) {
+    public BottomMenu setOkButton(CharSequence OkText, OnDialogButtonClickListener<BottomDialog> OkButtonClickListener) {
         this.okText = OkText;
         this.okButtonClickListener = OkButtonClickListener;
         return this;
     }
     
-    public BottomDialog setOkButton(int OkTextResId, OnDialogButtonClickListener<BottomDialog> OkButtonClickListener) {
+    public BottomMenu setOkButton(int OkTextResId, OnDialogButtonClickListener<BottomDialog> OkButtonClickListener) {
         this.okText = getString(OkTextResId);
         this.okButtonClickListener = OkButtonClickListener;
         return this;
@@ -853,38 +853,56 @@ public class BottomMenu extends BottomDialog {
         return otherText;
     }
     
-    public BottomDialog setOtherButton(CharSequence otherText) {
+    public BottomMenu setOtherButton(CharSequence otherText) {
         this.otherText = otherText;
         refreshUI();
         return this;
     }
     
-    public BottomDialog setOtherButton(int OtherTextResId) {
+    public BottomMenu setOtherButton(int OtherTextResId) {
         this.otherText = getString(OtherTextResId);
         refreshUI();
         return this;
     }
     
-    public BottomDialog setOtherButton(OnDialogButtonClickListener<BottomDialog> OtherButtonClickListener) {
+    public BottomMenu setOtherButton(OnDialogButtonClickListener<BottomDialog> OtherButtonClickListener) {
         this.otherButtonClickListener = OtherButtonClickListener;
         return this;
     }
     
-    public BottomDialog setOtherButton(CharSequence OtherText, OnDialogButtonClickListener<BottomDialog> OtherButtonClickListener) {
+    public BottomMenu setOtherButton(CharSequence OtherText, OnDialogButtonClickListener<BottomDialog> OtherButtonClickListener) {
         this.otherText = OtherText;
         this.otherButtonClickListener = OtherButtonClickListener;
         return this;
     }
     
-    public BottomDialog setOtherButton(int OtherTextResId, OnDialogButtonClickListener<BottomDialog> OtherButtonClickListener) {
+    public BottomMenu setOtherButton(int OtherTextResId, OnDialogButtonClickListener<BottomDialog> OtherButtonClickListener) {
         this.otherText = getString(OtherTextResId);
         this.otherButtonClickListener = OtherButtonClickListener;
         return this;
     }
     
-    public BottomDialog setMaskColor(@ColorInt int maskColor) {
+    public BottomMenu setMaskColor(@ColorInt int maskColor) {
         this.maskColor = maskColor;
         refreshUI();
         return this;
     }
+    
+    public long getEnterAnimDuration() {
+        return enterAnimDuration;
+    }
+    
+    public BottomMenu setEnterAnimDuration(long enterAnimDuration) {
+        this.enterAnimDuration = enterAnimDuration;
+        return this;
+    }
+    
+    public long getExitAnimDuration() {
+        return exitAnimDuration;
+    }
+    
+    public BottomMenu setExitAnimDuration(long exitAnimDuration) {
+        this.exitAnimDuration = exitAnimDuration;
+        return this;
+    }
 }

+ 36 - 7
DialogX/src/main/java/com/kongzue/dialogx/dialogs/CustomDialog.java

@@ -162,7 +162,11 @@ public class CustomDialog extends BaseDialog {
             boxRoot.post(new Runnable() {
                 @Override
                 public void run() {
-                    boxRoot.animate().setDuration(300).alpha(1f).setInterpolator(new DecelerateInterpolator()).setDuration(100).setListener(null);
+                    boxRoot.animate()
+                            .setDuration(enterAnimDuration == -1 ? 300 : enterAnimDuration)
+                            .alpha(1f)
+                            .setInterpolator(new DecelerateInterpolator())
+                            .setListener(null);
                     
                     if (enterAnimResId == R.anim.anim_dialogx_default_enter && exitAnimResId == R.anim.anim_dialogx_default_exit) {
                         switch (align) {
@@ -221,14 +225,21 @@ public class CustomDialog extends BaseDialog {
             if (v != null) v.setEnabled(false);
             
             Animation exitAnim = AnimationUtils.loadAnimation(getContext(), exitAnimResId);
+            if (exitAnimDuration != -1) {
+                exitAnim.setDuration(exitAnimDuration);
+            }
             boxCustom.startAnimation(exitAnim);
             
-            boxRoot.animate().setDuration(300).alpha(0f).setInterpolator(new AccelerateInterpolator()).setDuration(exitAnim.getDuration()).setListener(new AnimatorListenerEndCallBack() {
-                @Override
-                public void onAnimationEnd(Animator animation) {
-                    dismiss(dialogView);
-                }
-            });
+            boxRoot.animate()
+                    .alpha(0f)
+                    .setInterpolator(new AccelerateInterpolator())
+                    .setDuration(exitAnim.getDuration())
+                    .setListener(new AnimatorListenerEndCallBack() {
+                        @Override
+                        public void onAnimationEnd(Animator animation) {
+                            dismiss(dialogView);
+                        }
+                    });
         }
     }
     
@@ -368,4 +379,22 @@ public class CustomDialog extends BaseDialog {
         refreshUI();
         return this;
     }
+    
+    public long getEnterAnimDuration() {
+        return enterAnimDuration;
+    }
+    
+    public CustomDialog setEnterAnimDuration(long enterAnimDuration) {
+        this.enterAnimDuration = enterAnimDuration;
+        return this;
+    }
+    
+    public long getExitAnimDuration() {
+        return exitAnimDuration;
+    }
+    
+    public CustomDialog setExitAnimDuration(long exitAnimDuration) {
+        this.exitAnimDuration = exitAnimDuration;
+        return this;
+    }
 }

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

@@ -76,7 +76,7 @@ public class FullScreenDialog extends BaseDialog {
         super.beforeShow();
         dialogView = createView(isLightTheme() ? R.layout.layout_dialogx_fullscreen : R.layout.layout_dialogx_fullscreen_dark);
         dialogImpl = new DialogImpl(dialogView);
-        dialogView.setTag(getClass().getSimpleName() + "(" +Integer.toHexString(hashCode()) + ")");
+        dialogView.setTag(getClass().getSimpleName() + "(" + Integer.toHexString(hashCode()) + ")");
         show(dialogView);
     }
     
@@ -84,7 +84,7 @@ public class FullScreenDialog extends BaseDialog {
         super.beforeShow();
         dialogView = createView(isLightTheme() ? R.layout.layout_dialogx_fullscreen : R.layout.layout_dialogx_fullscreen_dark);
         dialogImpl = new DialogImpl(dialogView);
-        dialogView.setTag(getClass().getSimpleName() + "(" +Integer.toHexString(hashCode()) + ")");
+        dialogView.setTag(getClass().getSimpleName() + "(" + Integer.toHexString(hashCode()) + ")");
         show(activity, dialogView);
     }
     
@@ -154,10 +154,14 @@ public class FullScreenDialog extends BaseDialog {
                     bkgEnterAimY = boxRoot.getSafeHeight() - boxCustom.getHeight();
                     if (bkgEnterAimY < 0) bkgEnterAimY = 0;
                     
-                    boxRoot.animate().setDuration(300).alpha(1f).setInterpolator(new DecelerateInterpolator()).setDuration(100).setListener(null);
+                    boxRoot.animate()
+                            .setDuration(enterAnimDuration == -1 ? 300 : enterAnimDuration)
+                            .alpha(1f)
+                            .setInterpolator(new DecelerateInterpolator())
+                            .setListener(null);
                     
                     ObjectAnimator exitAnim = ObjectAnimator.ofFloat(bkg, "y", boxRoot.getHeight(), bkgEnterAimY);
-                    exitAnim.setDuration(300);
+                    exitAnim.setDuration(enterAnimDuration == -1 ? 300 : enterAnimDuration);
                     exitAnim.start();
                 }
             });
@@ -179,7 +183,7 @@ public class FullScreenDialog extends BaseDialog {
                 public void onChange(Rect unsafeRect) {
                     if (unsafeRect.bottom > dip2px(100)) {
                         ObjectAnimator enterAnim = ObjectAnimator.ofFloat(bkg, "y", bkg.getY(), 0);
-                        enterAnim.setDuration(300);
+                        enterAnim.setDuration(enterAnimDuration == -1 ? 300 : enterAnimDuration);
                         enterAnim.start();
                     }
                 }
@@ -222,15 +226,19 @@ public class FullScreenDialog extends BaseDialog {
             if (v != null) v.setEnabled(false);
             
             ObjectAnimator exitAnim = ObjectAnimator.ofFloat(bkg, "y", bkg.getY(), boxBkg.getHeight());
-            exitAnim.setDuration(300);
+            exitAnim.setDuration(exitAnimDuration == -1 ? 300 : exitAnimDuration);
             exitAnim.start();
             
-            boxRoot.animate().setDuration(300).alpha(0f).setInterpolator(new AccelerateInterpolator()).setDuration(exitAnim.getDuration()).setListener(new AnimatorListenerEndCallBack() {
-                @Override
-                public void onAnimationEnd(Animator animation) {
-                    dismiss(dialogView);
-                }
-            });
+            boxRoot.animate()
+                    .alpha(0f)
+                    .setInterpolator(new AccelerateInterpolator())
+                    .setDuration(exitAnim.getDuration())
+                    .setListener(new AnimatorListenerEndCallBack() {
+                        @Override
+                        public void onAnimationEnd(Animator animation) {
+                            dismiss(dialogView);
+                        }
+                    });
         }
         
         public void preDismiss() {
@@ -238,7 +246,7 @@ public class FullScreenDialog extends BaseDialog {
                 doDismiss(boxRoot);
             } else {
                 ObjectAnimator enterAnim = ObjectAnimator.ofFloat(bkg, "y", bkg.getY(), bkgEnterAimY);
-                enterAnim.setDuration(300);
+                enterAnim.setDuration(exitAnimDuration == -1 ? 300 : exitAnimDuration);
                 enterAnim.start();
             }
         }
@@ -341,4 +349,22 @@ public class FullScreenDialog extends BaseDialog {
         refreshUI();
         return this;
     }
+    
+    public long getEnterAnimDuration() {
+        return enterAnimDuration;
+    }
+    
+    public FullScreenDialog setEnterAnimDuration(long enterAnimDuration) {
+        this.enterAnimDuration = enterAnimDuration;
+        return this;
+    }
+    
+    public long getExitAnimDuration() {
+        return exitAnimDuration;
+    }
+    
+    public FullScreenDialog setExitAnimDuration(long exitAnimDuration) {
+        this.exitAnimDuration = exitAnimDuration;
+        return this;
+    }
 }

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

@@ -499,4 +499,22 @@ public class InputDialog extends MessageDialog {
         refreshUI();
         return this;
     }
+    
+    public long getEnterAnimDuration() {
+        return enterAnimDuration;
+    }
+    
+    public InputDialog setEnterAnimDuration(long enterAnimDuration) {
+        this.enterAnimDuration = enterAnimDuration;
+        return this;
+    }
+    
+    public long getExitAnimDuration() {
+        return exitAnimDuration;
+    }
+    
+    public InputDialog setExitAnimDuration(long exitAnimDuration) {
+        this.exitAnimDuration = exitAnimDuration;
+        return this;
+    }
 }

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

@@ -197,7 +197,7 @@ public class MessageDialog extends BaseDialog {
         
         dialogView = createView(layoutId);
         dialogImpl = new DialogImpl(dialogView);
-        dialogView.setTag(getClass().getSimpleName() + "(" +Integer.toHexString(hashCode()) + ")");
+        dialogView.setTag(getClass().getSimpleName() + "(" + Integer.toHexString(hashCode()) + ")");
         show(dialogView);
     }
     
@@ -208,7 +208,7 @@ public class MessageDialog extends BaseDialog {
         
         dialogView = createView(layoutId);
         dialogImpl = new DialogImpl(dialogView);
-        dialogView.setTag(getClass().getSimpleName() + "(" +Integer.toHexString(hashCode()) + ")");
+        dialogView.setTag(getClass().getSimpleName() + "(" + Integer.toHexString(hashCode()) + ")");
         show(activity, dialogView);
     }
     
@@ -275,10 +275,17 @@ public class MessageDialog extends BaseDialog {
                     boxRoot.setAlpha(0f);
                     int enterAnimResId = style.enterAnimResId() == 0 ? R.anim.anim_dialogx_default_enter : style.enterAnimResId();
                     Animation enterAnim = AnimationUtils.loadAnimation(getContext(), enterAnimResId);
+                    if (enterAnimDuration != -1) {
+                        enterAnim.setDuration(enterAnimDuration);
+                    }
                     enterAnim.setInterpolator(new DecelerateInterpolator());
                     bkg.startAnimation(enterAnim);
                     
-                    boxRoot.animate().setDuration(enterAnim.getDuration()).alpha(1f).setInterpolator(new DecelerateInterpolator()).setDuration(300).setListener(null);
+                    boxRoot.animate()
+                            .setDuration(enterAnim.getDuration())
+                            .alpha(1f)
+                            .setInterpolator(new DecelerateInterpolator())
+                            .setListener(null);
                     
                     getDialogLifecycleCallback().onShow(me);
                     
@@ -302,13 +309,23 @@ public class MessageDialog extends BaseDialog {
                         txtInput.postDelayed(new Runnable() {
                             @Override
                             public void run() {
+                                if (txtInput == null) return;
                                 txtInput.requestFocus();
                                 txtInput.setFocusableInTouchMode(true);
                                 InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                                 imm.showSoftInput(txtInput, InputMethodManager.RESULT_UNCHANGED_SHOWN);
                                 txtInput.setSelection(txtInput.getText().length());
+                                if (inputInfo != null && inputInfo.isSelectAllText()) {
+                                    txtInput.selectAll();
+                                }
                             }
                         }, 300);
+                    }else{
+                        if (inputInfo != null && inputInfo.isSelectAllText()) {
+                            txtInput.clearFocus();
+                            txtInput.requestFocus();
+                            txtInput.selectAll();
+                        }
                     }
                     
                     if (onBindView != null) onBindView.onBind(me, onBindView.getCustomView());
@@ -453,16 +470,8 @@ public class MessageDialog extends BaseDialog {
                     inputType = inputType | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
                 }
                 txtInput.setInputType(inputType);
-                if (inputInfo.getTextInfo() != null)
+                if (inputInfo.getTextInfo() != null) {
                     useTextInfo(txtInput, inputInfo.getTextInfo());
-                
-                if (inputInfo.isSelectAllText()) {
-                    txtInput.post(new Runnable() {
-                        @Override
-                        public void run() {
-                            txtInput.selectAll();
-                        }
-                    });
                 }
             }
             
@@ -613,16 +622,23 @@ public class MessageDialog extends BaseDialog {
             if (v != null) v.setEnabled(false);
             
             int exitAnimResId = style.exitAnimResId() == 0 ? R.anim.anim_dialogx_default_exit : style.exitAnimResId();
-            Animation enterAnim = AnimationUtils.loadAnimation(getContext(), exitAnimResId);
-            enterAnim.setInterpolator(new AccelerateInterpolator());
-            bkg.startAnimation(enterAnim);
+            Animation exitAnim = AnimationUtils.loadAnimation(getContext(), exitAnimResId);
+            exitAnim.setInterpolator(new AccelerateInterpolator());
+            if (exitAnimDuration != -1) {
+                exitAnim.setDuration(exitAnimDuration);
+            }
+            bkg.startAnimation(exitAnim);
             
-            boxRoot.animate().setDuration(300).alpha(0f).setInterpolator(new AccelerateInterpolator()).setDuration(enterAnim.getDuration()).setListener(new AnimatorListenerEndCallBack() {
-                @Override
-                public void onAnimationEnd(Animator animation) {
-                    dismiss(dialogView);
-                }
-            });
+            boxRoot.animate()
+                    .alpha(0f)
+                    .setInterpolator(new AccelerateInterpolator())
+                    .setDuration(exitAnimDuration == -1 ? exitAnim.getDuration() : exitAnimDuration)
+                    .setListener(new AnimatorListenerEndCallBack() {
+                        @Override
+                        public void onAnimationEnd(Animator animation) {
+                            dismiss(dialogView);
+                        }
+                    });
         }
     }
     
@@ -950,4 +966,22 @@ public class MessageDialog extends BaseDialog {
         refreshUI();
         return this;
     }
+    
+    public long getEnterAnimDuration() {
+        return enterAnimDuration;
+    }
+    
+    public MessageDialog setEnterAnimDuration(long enterAnimDuration) {
+        this.enterAnimDuration = enterAnimDuration;
+        return this;
+    }
+    
+    public long getExitAnimDuration() {
+        return exitAnimDuration;
+    }
+    
+    public MessageDialog setExitAnimDuration(long exitAnimDuration) {
+        this.exitAnimDuration = exitAnimDuration;
+        return this;
+    }
 }

+ 41 - 10
DialogX/src/main/java/com/kongzue/dialogx/dialogs/PopTip.java

@@ -261,7 +261,7 @@ public class PopTip extends BaseDialog {
         }
         dialogView = createView(layoutResId);
         dialogImpl = new DialogImpl(dialogView);
-        dialogView.setTag(getClass().getSimpleName() + "(" +Integer.toHexString(hashCode()) + ")");
+        dialogView.setTag(getClass().getSimpleName() + "(" + Integer.toHexString(hashCode()) + ")");
         show(dialogView);
     }
     
@@ -285,7 +285,7 @@ public class PopTip extends BaseDialog {
         }
         dialogView = createView(layoutResId);
         dialogImpl = new DialogImpl(dialogView);
-        dialogView.setTag(getClass().getSimpleName() + "(" +Integer.toHexString(hashCode()) + ")");
+        dialogView.setTag(getClass().getSimpleName() + "(" + Integer.toHexString(hashCode()) + ")");
         show(activity, dialogView);
     }
     
@@ -355,7 +355,7 @@ public class PopTip extends BaseDialog {
             boxRoot.setFocusable(false);
             boxRoot.setFocusableInTouchMode(false);
             boxRoot.setAutoUnsafePlacePadding(false);
-    
+            
             if (autoDismissTimer == null) {
                 showShort();
             }
@@ -416,9 +416,16 @@ public class PopTip extends BaseDialog {
                     
                     Animation enterAnim = AnimationUtils.loadAnimation(getContext(), enterAnimResId);
                     enterAnim.setInterpolator(new DecelerateInterpolator(2f));
+                    if (enterAnimDuration!=-1){
+                        enterAnim.setDuration(enterAnimDuration);
+                    }
                     boxBody.startAnimation(enterAnim);
                     
-                    boxRoot.animate().setDuration(enterAnim.getDuration()).alpha(1f).setInterpolator(new DecelerateInterpolator()).setListener(null);
+                    boxRoot.animate()
+                            .setDuration(enterAnimDuration==-1?enterAnim.getDuration():enterAnimDuration)
+                            .alpha(1f)
+                            .setInterpolator(new DecelerateInterpolator())
+                            .setListener(null);
                 }
             });
             
@@ -497,14 +504,21 @@ public class PopTip extends BaseDialog {
                     if (v != null) v.setEnabled(false);
                     
                     Animation exitAnim = AnimationUtils.loadAnimation(getContext(), exitAnimResId);
+                    if (exitAnimDuration!=-1){
+                        exitAnim.setDuration(exitAnimResId);
+                    }
                     boxBody.startAnimation(exitAnim);
                     
-                    boxRoot.animate().alpha(0f).setInterpolator(new AccelerateInterpolator()).setDuration(exitAnim.getDuration()).setListener(new AnimatorListenerEndCallBack() {
-                        @Override
-                        public void onAnimationEnd(Animator animation) {
-                            dismiss(dialogView);
-                        }
-                    });
+                    boxRoot.animate()
+                            .alpha(0f)
+                            .setInterpolator(new AccelerateInterpolator())
+                            .setDuration(exitAnimDuration == -1 ? exitAnim.getDuration() : exitAnimDuration)
+                            .setListener(new AnimatorListenerEndCallBack() {
+                                @Override
+                                public void onAnimationEnd(Animator animation) {
+                                    dismiss(dialogView);
+                                }
+                            });
                 }
             });
         }
@@ -700,4 +714,21 @@ public class PopTip extends BaseDialog {
         refreshUI();
         return this;
     }
+    public long getEnterAnimDuration() {
+        return enterAnimDuration;
+    }
+    
+    public PopTip setEnterAnimDuration(long enterAnimDuration) {
+        this.enterAnimDuration = enterAnimDuration;
+        return this;
+    }
+    
+    public long getExitAnimDuration() {
+        return exitAnimDuration;
+    }
+    
+    public PopTip setExitAnimDuration(long exitAnimDuration) {
+        this.exitAnimDuration = exitAnimDuration;
+        return this;
+    }
 }

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

@@ -28,6 +28,17 @@ public class TipDialog extends WaitDialog {
         return me();
     }
     
+    public static WaitDialog show(CharSequence message) {
+        DialogImpl dialogImpl = me().dialogImpl;
+        me().preMessage(message);
+        if (dialogImpl != null) {
+            dialogImpl.showTip(TYPE.WARNING);
+        } else {
+            me().showTip(message, TYPE.WARNING);
+        }
+        return me();
+    }
+    
     public static WaitDialog show(int messageResId, TYPE tip) {
         DialogImpl dialogImpl = me().dialogImpl;
         me().preMessage(messageResId);

+ 38 - 10
DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java

@@ -225,9 +225,16 @@ public class WaitDialog extends BaseDialog {
                             int enterAnimResId = R.anim.anim_dialogx_default_enter;
                             Animation enterAnim = AnimationUtils.loadAnimation(getContext(), enterAnimResId);
                             enterAnim.setInterpolator(new DecelerateInterpolator());
+                            if (enterAnimDuration != -1) {
+                                enterAnim.setDuration(enterAnimDuration);
+                            }
                             bkg.startAnimation(enterAnim);
                             
-                            boxRoot.animate().setDuration(enterAnim.getDuration()).alpha(1f).setInterpolator(new DecelerateInterpolator()).setDuration(300).setListener(null);
+                            boxRoot.animate()
+                                    .setDuration(enterAnimDuration == -1 ? enterAnim.getDuration() : enterAnimDuration)
+                                    .alpha(1f)
+                                    .setInterpolator(new DecelerateInterpolator())
+                                    .setListener(null);
                             
                             getDialogLifecycleCallback().onShow(me());
                         }
@@ -331,16 +338,23 @@ public class WaitDialog extends BaseDialog {
                     if (v != null) v.setEnabled(false);
                     
                     int exitAnimResId = R.anim.anim_dialogx_default_exit;
-                    Animation enterAnim = AnimationUtils.loadAnimation(getContext(), exitAnimResId);
-                    enterAnim.setInterpolator(new AccelerateInterpolator());
-                    bkg.startAnimation(enterAnim);
+                    Animation exitAnim = AnimationUtils.loadAnimation(getContext(), exitAnimResId);
+                    if (exitAnimDuration != -1) {
+                        exitAnim.setDuration(exitAnimDuration);
+                    }
+                    exitAnim.setInterpolator(new AccelerateInterpolator());
+                    bkg.startAnimation(exitAnim);
                     
-                    boxRoot.animate().setDuration(300).alpha(0f).setInterpolator(new AccelerateInterpolator()).setDuration(enterAnim.getDuration()).setListener(new AnimatorListenerEndCallBack() {
-                        @Override
-                        public void onAnimationEnd(Animator animation) {
-                            dismiss(dialogView);
-                        }
-                    });
+                    boxRoot.animate()
+                            .alpha(0f)
+                            .setInterpolator(new AccelerateInterpolator())
+                            .setDuration(exitAnimDuration == -1 ? exitAnim.getDuration() : exitAnimDuration)
+                            .setListener(new AnimatorListenerEndCallBack() {
+                                @Override
+                                public void onAnimationEnd(Animator animation) {
+                                    dismiss(dialogView);
+                                }
+                            });
                 }
             });
         }
@@ -547,4 +561,18 @@ public class WaitDialog extends BaseDialog {
         this.tipDialogLifecycleCallback = dialogLifecycleCallback;
         return this;
     }
+    
+    public WaitDialog setEnterAnimDuration(long enterAnimDuration) {
+        this.enterAnimDuration = enterAnimDuration;
+        return this;
+    }
+    
+    public long getExitAnimDuration() {
+        return exitAnimDuration;
+    }
+    
+    public WaitDialog setExitAnimDuration(long exitAnimDuration) {
+        this.exitAnimDuration = exitAnimDuration;
+        return this;
+    }
 }

+ 6 - 2
DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java

@@ -51,11 +51,11 @@ public class BaseDialog {
         });
     }
     
-    public static void log(Object o) {
+    protected static void log(Object o) {
         if (DEBUGMODE) Log.i(">>>", o.toString());
     }
     
-    public static void error(Object o) {
+    protected static void error(Object o) {
         if (DEBUGMODE) Log.e(">>>", o.toString());
     }
     
@@ -111,11 +111,15 @@ public class BaseDialog {
     protected DialogX.THEME theme;
     protected boolean autoShowInputKeyboard;
     protected int backgroundColor = -1;
+    protected long enterAnimDuration = -1;
+    protected long exitAnimDuration = -1;
     
     public BaseDialog() {
         cancelable = DialogX.cancelable;
         style = DialogX.globalStyle;
         theme = DialogX.globalTheme;
+        enterAnimDuration = DialogX.enterAnimDuration;
+        exitAnimDuration = DialogX.exitAnimDuration;
         autoShowInputKeyboard = DialogX.autoShowInputKeyboard;
     }
     

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

@@ -137,7 +137,7 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
                 ((Activity) BaseDialog.getContext()).getWindowManager().getDefaultDisplay().getRealMetrics(displayMetrics);
                 Rect rect = new Rect();
                 ((Activity) BaseDialog.getContext()).getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
-                paddingView( rect.left,  rect.top, displayMetrics.widthPixels - rect.right, displayMetrics.heightPixels - rect.bottom);
+                paddingView(rect.left, rect.top, displayMetrics.widthPixels - rect.right, displayMetrics.heightPixels - rect.bottom);
             }
         }
     };
@@ -174,10 +174,10 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
         public abstract void onDismiss();
     }
     
-    protected Rect unsafePlace;
+    protected Rect unsafePlace = new Rect();
     
     private void paddingView(int left, int top, int right, int bottom) {
-        Log.e(">>>", "paddingView: left:" + left + " top:" + top + " right:" + right + " bottom:" + bottom);
+        log("paddingView: left:" + left + " top:" + top + " right:" + right + " bottom:" + bottom);
         unsafePlace = new Rect(left, top, right, bottom);
         if (onSafeInsetsChangeListener != null) onSafeInsetsChangeListener.onChange(unsafePlace);
         MaxRelativeLayout bkgView = findViewById(R.id.bkg);

+ 2 - 2
README.md

@@ -106,7 +106,7 @@ DialogX 采用了主题分离结构,主框架仅包含 Material 设计风格
 想要在您的项目引入 DialogX,您需要在 app 的 build.gradle 文件中找到 `dependencies{}` 代码块,并在其中加入以下语句:
 
 ```
-implementation 'com.kongzue.dialogx:DialogX:0.0.29'
+implementation 'com.kongzue.dialogx:DialogX:0.0.30'
 ```
 
 若有需要,也可以手动配置 Maven:
@@ -115,7 +115,7 @@ implementation 'com.kongzue.dialogx:DialogX:0.0.29'
 <dependency>
   <groupId>com.kongzue.dialogx</groupId>
   <artifactId>DialogX</artifactId>
-  <version>0.0.29</version>
+  <version>0.0.30</version>
   <type>pom</type>
 </dependency>
 ```

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

@@ -48,6 +48,7 @@ import com.kongzue.dialogx.style.IOSStyle;
 import com.kongzue.dialogx.style.KongzueStyle;
 import com.kongzue.dialogx.style.MIUIStyle;
 import com.kongzue.dialogx.style.MaterialStyle;
+import com.kongzue.dialogx.util.InputInfo;
 import com.kongzue.dialogx.util.TextInfo;
 
 import java.util.Timer;
@@ -257,6 +258,8 @@ public class MainActivity extends BaseActivity {
             @Override
             public void onClick(View view) {
                 new InputDialog("标题", "正文内容", "确定", "取消", "正在输入的文字")
+                        .setInputText("Hello World")
+                        .setInputInfo(new InputInfo().setSelectAllText(true))
                         .setCancelable(false)
                         .setOkButton(new OnInputDialogButtonClickListener<InputDialog>() {
                             @Override
@@ -373,7 +376,7 @@ public class MainActivity extends BaseActivity {
                 }, 3000);
             }
         });
-    
+        
         btnBottomDialog.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {

+ 2 - 2
build.gradle

@@ -5,8 +5,8 @@ buildscript {
         jcenter()
     }
     dependencies {
-        classpath "com.android.tools.build:gradle:4.0.1"
-        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
+        classpath 'com.android.tools.build:gradle:4.1.2'
+        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
 
         // NOTE: Do not place your application dependencies here; they belong

+ 2 - 2
gradle.properties

@@ -18,5 +18,5 @@ android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
 
-BUILD_VERSION=0.0.29.debug1
-BUILD_VERSION_INT=29
+BUILD_VERSION=0.0.30
+BUILD_VERSION_INT=30

+ 2 - 2
gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
-#Mon Sep 21 17:04:55 CST 2020
+#Tue Jan 26 19:13:49 CST 2021
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip