diff --git a/DialogX/src/main/java/com/kongzue/dialogx/DialogX.java b/DialogX/src/main/java/com/kongzue/dialogx/DialogX.java index 1388bbc1..0b518643 100644 --- a/DialogX/src/main/java/com/kongzue/dialogx/DialogX.java +++ b/DialogX/src/main/java/com/kongzue/dialogx/DialogX.java @@ -199,4 +199,19 @@ private static int dip2px(float dpValue) { public static DialogListBuilder showDialogList(BaseDialog... dialogs) { return DialogListBuilder.create(dialogs).show(); } + + // 默认消息对话框标题文本 + public static CharSequence defaultMessageDialogTitleText; + + // 等待提示框默认文本 + public static CharSequence defaultWaitDialogWaitingText; + + // 成功提示框默认文本 + public static CharSequence defaultTipDialogSuccessText; + + // 错误提示框默认文本 + public static CharSequence defaultTipDialogErrorText; + + // 警告提示框默认文本 + public static CharSequence defaultTipDialogWarningText; } diff --git a/DialogX/src/main/java/com/kongzue/dialogx/dialogs/MessageDialog.java b/DialogX/src/main/java/com/kongzue/dialogx/dialogs/MessageDialog.java index 05eebae8..2c1dec1a 100644 --- a/DialogX/src/main/java/com/kongzue/dialogx/dialogs/MessageDialog.java +++ b/DialogX/src/main/java/com/kongzue/dialogx/dialogs/MessageDialog.java @@ -127,6 +127,10 @@ public static MessageDialog build(OnBindView onBindView) { return new MessageDialog().setCustomView(onBindView); } + public MessageDialog(CharSequence message) { + this.message = message; + } + public MessageDialog(CharSequence title, CharSequence message) { this.title = title; this.message = message; @@ -640,7 +644,7 @@ public void getOutline(View view, Outline outline) { } } - showText(txtDialogTitle, title); + showText(txtDialogTitle, title == null ? DialogX.defaultMessageDialogTitleText : title); showText(txtDialogTip, message); showText(btnSelectPositive, okText); showText(btnSelectNegative, cancelText); diff --git a/DialogX/src/main/java/com/kongzue/dialogx/dialogs/TipDialog.java b/DialogX/src/main/java/com/kongzue/dialogx/dialogs/TipDialog.java index 84e9bc3d..89257071 100644 --- a/DialogX/src/main/java/com/kongzue/dialogx/dialogs/TipDialog.java +++ b/DialogX/src/main/java/com/kongzue/dialogx/dialogs/TipDialog.java @@ -31,6 +31,10 @@ protected TipDialog() { super(); } + public static WaitDialog showTipWithDefaultText(TYPE tip) { + return WaitDialog.showTipWithDefaultText(tip); + } + public static WaitDialog show(int messageResId) { return show((Activity) null, messageResId); } diff --git a/DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java b/DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java index 5d854596..df1a565c 100644 --- a/DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java +++ b/DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java @@ -104,6 +104,36 @@ public static WaitDialog build() { return new WaitDialog(); } + public static WaitDialog showWaitWithDefaultText() { + WaitDialog dialog = getInstance(); + if (dialog != null) { + dialog.setTip(null, TYPE.NONE); + if (dialog.getDialogImpl() == null) { + dialog.show(); + } else { + dialog.cancelDelayDismissTimer(); + } + return dialog; + } else { + return instanceBuild(); + } + } + + protected static WaitDialog showTipWithDefaultText(TYPE tip) { + WaitDialog dialog = getInstance(); + if (dialog != null) { + dialog.setTip(null, tip); + if (dialog.getDialogImpl() == null) { + dialog.show(); + } else { + dialog.cancelDelayDismissTimer(); + } + return dialog; + } else { + return instanceBuild(); + } + } + public static WaitDialog show(CharSequence message) { WaitDialog dialog = getInstance(); if (dialog != null) { @@ -530,7 +560,7 @@ public void getOutline(View view, Outline outline) { } } - showText(txtInfo, message); + showText(txtInfo, message == null ? getDefaultTipText(readyTipType) : message); useTextInfo(txtInfo, messageTextInfo); if (maskColor != null) { @@ -565,6 +595,21 @@ public void onClick(View v) { onDialogRefreshUI(); } + private CharSequence getDefaultTipText(TYPE readyTipType) { + switch (readyTipType) { + case WARNING: + return DialogX.defaultTipDialogWarningText; + case SUCCESS: + return DialogX.defaultTipDialogSuccessText; + case ERROR: + return DialogX.defaultTipDialogErrorText; + case NONE: + return DialogX.defaultWaitDialogWaitingText; + default: + return null; + } + } + public void doDismiss(final View v) { if (WaitDialog.this.preDismiss(WaitDialog.this)) { return; diff --git a/app/src/main/java/com/kongzue/dialogxdemo/App.java b/app/src/main/java/com/kongzue/dialogxdemo/App.java index bb5c8378..a9707277 100644 --- a/app/src/main/java/com/kongzue/dialogxdemo/App.java +++ b/app/src/main/java/com/kongzue/dialogxdemo/App.java @@ -44,6 +44,8 @@ public ALIGN align() { DialogX.onlyOnePopTip = false; DialogX.onlyOnePopNotification=false; DialogX.DEBUGMODE = BuildConfig.DEBUG; + DialogX.defaultWaitDialogWaitingText="hahah"; + DialogX.defaultTipDialogSuccessText="okok!!!"; //DialogX.ignoreUnsafeInsetsHorizontal = true; //以下代码用于测试后台 Service 启动对话框 diff --git a/app/src/main/java/com/kongzue/dialogxdemo/activity/MainActivity.java b/app/src/main/java/com/kongzue/dialogxdemo/activity/MainActivity.java index 9e570f59..b4548623 100644 --- a/app/src/main/java/com/kongzue/dialogxdemo/activity/MainActivity.java +++ b/app/src/main/java/com/kongzue/dialogxdemo/activity/MainActivity.java @@ -1233,7 +1233,7 @@ public boolean onClick(PopTip popTip, View v) { toast("邮件已撤回"); return false; } - }).setTintIcon(true).showLong().setAlign(DialogXStyle.PopTipSettings.ALIGN.TOP); + }).setTintIcon(true).showLong(); } } }); diff --git a/gradle.properties b/gradle.properties index 38daded2..679653f7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true -BUILD_VERSION=0.0.50.beta21 +BUILD_VERSION=0.0.50.beta22 BUILD_VERSION_INT=50 DIALOGX_STYLE_VERSION=5 android.nonTransitiveRClass=true