Skip to content

Commit

Permalink
0.0.50.beta22
Browse files Browse the repository at this point in the history
- 新增默认文本设置:

  // 默认消息对话框标题文本
  DialogX.defaultMessageDialogTitleText
  // 等待提示框默认文本
  DialogX.defaultWaitDialogWaitingText;
  // 成功提示框默认文本
  DialogX.defaultTipDialogSuccessText;
  // 错误提示框默认文本
  DialogX.defaultTipDialogErrorText;
  // 警告提示框默认文本
  DialogX.defaultTipDialogWarningText;

  设置文本后可以在不指定对应对话框的相关文本时直接使用默认文本;

  对应的对话框静态启动方法省略默认可设置文本的方法也已添加,比如 `MessageDialog.show(messageText)` 或者 `WaitDialog.showWaitWithDefaultText()` 以及 `TipDialog.showTipWithDefaultText(TYPE)`

- 修复 PopNotification 在允许同时显示多条通知时,关闭后依然能够接收到触摸事件的问题;
- 修复 PopNotification 在 DialogFragment 模式下默认顶部位置异常的问题
  • Loading branch information
kongzue committed Oct 22, 2024
1 parent b846250 commit ccc5a91
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 4 deletions.
15 changes: 15 additions & 0 deletions DialogX/src/main/java/com/kongzue/dialogx/DialogX.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ public static MessageDialog build(OnBindView<MessageDialog> 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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/kongzue/dialogxdemo/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 启动对话框
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ccc5a91

Please sign in to comment.