6.7.0 - Alpha14 - dialogs.build 方法支持 textAllCaps 相关选项参数; 修复 dialogs.build 参数破坏性及兼容性

This commit is contained in:
SuperMonster003
2026-01-14 12:47:15 +08:00
parent 62504d6608
commit 8812471328
14 changed files with 114 additions and 68 deletions

View File

@@ -304,12 +304,19 @@ class DialogInit {
dialog.view.setButtonGravity(builder.buttonsGravity);
dialog.view.setButtonStackedGravity(builder.btnStackedGravity);
dialog.view.setStackingBehavior(builder.stackingBehavior);
boolean textAllCaps;
textAllCaps = DialogUtils.resolveBoolean(builder.context, android.R.attr.textAllCaps, true);
MDButton positiveTextView = dialog.positiveButton;
dialog.setTypeface(positiveTextView, builder.mediumFont);
positiveTextView.setAllCapsCompat(textAllCaps);
if (builder.positiveTextAllCaps != null) {
positiveTextView.setAllCapsCompat(builder.positiveTextAllCaps);
} else if (builder.textAllCaps != null) {
positiveTextView.setAllCapsCompat(builder.textAllCaps);
} else {
positiveTextView.setAllCapsCompat(textAllCaps);
}
positiveTextView.setText(builder.positiveText);
positiveTextView.setTextColor(builder.positiveColor);
dialog.positiveButton.setStackedSelector(dialog.getButtonSelector(DialogAction.POSITIVE, true));
@@ -320,7 +327,13 @@ class DialogInit {
MDButton negativeTextView = dialog.negativeButton;
dialog.setTypeface(negativeTextView, builder.mediumFont);
negativeTextView.setAllCapsCompat(textAllCaps);
if (builder.negativeTextAllCaps != null) {
negativeTextView.setAllCapsCompat(builder.negativeTextAllCaps);
} else if (builder.textAllCaps != null) {
negativeTextView.setAllCapsCompat(builder.textAllCaps);
} else {
negativeTextView.setAllCapsCompat(textAllCaps);
}
negativeTextView.setText(builder.negativeText);
negativeTextView.setTextColor(builder.negativeColor);
dialog.negativeButton.setStackedSelector(dialog.getButtonSelector(DialogAction.NEGATIVE, true));
@@ -331,7 +344,13 @@ class DialogInit {
MDButton neutralTextView = dialog.neutralButton;
dialog.setTypeface(neutralTextView, builder.mediumFont);
neutralTextView.setAllCapsCompat(textAllCaps);
if (builder.neutralTextAllCaps != null) {
neutralTextView.setAllCapsCompat(builder.neutralTextAllCaps);
} else if (builder.textAllCaps != null) {
neutralTextView.setAllCapsCompat(builder.textAllCaps);
} else {
neutralTextView.setAllCapsCompat(textAllCaps);
}
neutralTextView.setText(builder.neutralText);
neutralTextView.setTextColor(builder.neutralColor);
dialog.neutralButton.setStackedSelector(dialog.getButtonSelector(DialogAction.NEUTRAL, true));

View File

@@ -14,7 +14,6 @@ import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
@@ -57,7 +56,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/** @author Aidan Follestad (afollestad) */
public class MaterialDialog extends DialogBase implements View.OnClickListener, DefaultRvAdapter.InternalListCallback {
@@ -1079,6 +1077,10 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
protected CharSequence positiveText;
protected CharSequence neutralText;
protected CharSequence negativeText;
protected Boolean positiveTextAllCaps = null;
protected Boolean negativeTextAllCaps = null;
protected Boolean neutralTextAllCaps = null;
protected Boolean textAllCaps = null;
protected boolean positiveFocus;
protected boolean neutralFocus;
protected boolean negativeFocus;
@@ -1634,6 +1636,11 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
return this;
}
public Builder positiveTextAllCaps(boolean allCaps) {
this.positiveTextAllCaps = allCaps;
return this;
}
public Builder positiveColor(@ColorInt int color) {
return positiveColor(DialogUtils.getActionTextStateList(context, color));
}
@@ -1670,6 +1677,11 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
return this;
}
public Builder neutralTextAllCaps(boolean allCaps) {
this.neutralTextAllCaps = allCaps;
return this;
}
public Builder negativeColor(@ColorInt int color) {
return negativeColor(DialogUtils.getActionTextStateList(context, color));
}
@@ -1701,6 +1713,11 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
return this;
}
public Builder negativeTextAllCaps(boolean allCaps) {
this.negativeTextAllCaps = allCaps;
return this;
}
public Builder negativeFocus(boolean isFocusedDefault) {
this.negativeFocus = isFocusedDefault;
return this;
@@ -2006,6 +2023,11 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
return this;
}
public Builder textAllCaps(boolean allCaps) {
this.textAllCaps = allCaps;
return this;
}
/**
* Sets a custom {@link androidx.recyclerview.widget.RecyclerView.Adapter} for the dialog's list
*