|
@@ -3,6 +3,7 @@ package com.afollestad.materialdialogs;
|
|
|
import android.annotation.SuppressLint;
|
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
+import android.content.res.ColorStateList;
|
|
|
import android.graphics.Paint;
|
|
|
import android.graphics.Typeface;
|
|
|
import android.graphics.drawable.Drawable;
|
|
@@ -369,9 +370,9 @@ public class MaterialDialog extends DialogBase implements
|
|
|
protected CharSequence negativeText;
|
|
|
protected View customView;
|
|
|
protected int widgetColor;
|
|
|
- protected int positiveColor;
|
|
|
- protected int negativeColor;
|
|
|
- protected int neutralColor;
|
|
|
+ protected ColorStateList positiveColor;
|
|
|
+ protected ColorStateList negativeColor;
|
|
|
+ protected ColorStateList neutralColor;
|
|
|
protected ButtonCallback callback;
|
|
|
protected ListCallback listCallback;
|
|
|
protected ListCallbackSingleChoice listCallbackSingleChoice;
|
|
@@ -463,9 +464,9 @@ public class MaterialDialog extends DialogBase implements
|
|
|
this.widgetColor = DialogUtils.resolveColor(context, android.R.attr.colorAccent, this.widgetColor);
|
|
|
}
|
|
|
|
|
|
- this.positiveColor = this.widgetColor;
|
|
|
- this.negativeColor = this.widgetColor;
|
|
|
- this.neutralColor = this.widgetColor;
|
|
|
+ this.positiveColor = DialogUtils.getActionTextStateList(context, this.widgetColor);
|
|
|
+ this.negativeColor = DialogUtils.getActionTextStateList(context, this.widgetColor);
|
|
|
+ this.neutralColor = DialogUtils.getActionTextStateList(context, this.widgetColor);
|
|
|
|
|
|
this.progressPercentFormat = NumberFormat.getPercentInstance();
|
|
|
this.progressNumberFormat = "%1d/%2d";
|
|
@@ -514,11 +515,11 @@ public class MaterialDialog extends DialogBase implements
|
|
|
this.titleColor = s.titleColor;
|
|
|
if (s.contentColor != 0)
|
|
|
this.contentColor = s.contentColor;
|
|
|
- if (s.positiveColor != 0)
|
|
|
+ if (s.positiveColor != null)
|
|
|
this.positiveColor = s.positiveColor;
|
|
|
- if (s.neutralColor != 0)
|
|
|
+ if (s.neutralColor != null)
|
|
|
this.neutralColor = s.neutralColor;
|
|
|
- if (s.negativeColor != 0)
|
|
|
+ if (s.negativeColor != null)
|
|
|
this.negativeColor = s.negativeColor;
|
|
|
if (s.itemColor != 0)
|
|
|
this.itemColor = s.itemColor;
|
|
@@ -782,17 +783,21 @@ public class MaterialDialog extends DialogBase implements
|
|
|
}
|
|
|
|
|
|
public Builder positiveColor(@ColorInt int color) {
|
|
|
- this.positiveColor = color;
|
|
|
- this.positiveColorSet = true;
|
|
|
- return this;
|
|
|
+ return positiveColor(DialogUtils.getActionTextStateList(context, color));
|
|
|
}
|
|
|
|
|
|
public Builder positiveColorRes(@ColorRes int colorRes) {
|
|
|
- return positiveColor(this.context.getResources().getColor(colorRes));
|
|
|
+ return positiveColor(DialogUtils.getActionTextColorStateList(this.context, colorRes));
|
|
|
}
|
|
|
|
|
|
public Builder positiveColorAttr(@AttrRes int colorAttr) {
|
|
|
- return positiveColor(DialogUtils.resolveColor(this.context, colorAttr));
|
|
|
+ return positiveColor(DialogUtils.resolveActionTextColorStateList(this.context, colorAttr, null));
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder positiveColor(ColorStateList colorStateList) {
|
|
|
+ this.positiveColor = colorStateList;
|
|
|
+ this.positiveColorSet = true;
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
public Builder neutralText(@StringRes int neutralRes) {
|
|
@@ -805,17 +810,21 @@ public class MaterialDialog extends DialogBase implements
|
|
|
}
|
|
|
|
|
|
public Builder negativeColor(@ColorInt int color) {
|
|
|
- this.negativeColor = color;
|
|
|
- this.negativeColorSet = true;
|
|
|
- return this;
|
|
|
+ return negativeColor(DialogUtils.getActionTextStateList(context, color));
|
|
|
}
|
|
|
|
|
|
public Builder negativeColorRes(@ColorRes int colorRes) {
|
|
|
- return negativeColor(this.context.getResources().getColor(colorRes));
|
|
|
+ return negativeColor(DialogUtils.getActionTextColorStateList(this.context, colorRes));
|
|
|
}
|
|
|
|
|
|
public Builder negativeColorAttr(@AttrRes int colorAttr) {
|
|
|
- return negativeColor(DialogUtils.resolveColor(this.context, colorAttr));
|
|
|
+ return negativeColor(DialogUtils.resolveActionTextColorStateList(this.context, colorAttr, null));
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder negativeColor(ColorStateList colorStateList) {
|
|
|
+ this.negativeColor = colorStateList;
|
|
|
+ this.negativeColorSet = true;
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
public Builder negativeText(@StringRes int negativeRes) {
|
|
@@ -828,17 +837,21 @@ public class MaterialDialog extends DialogBase implements
|
|
|
}
|
|
|
|
|
|
public Builder neutralColor(@ColorInt int color) {
|
|
|
- this.neutralColor = color;
|
|
|
- this.neutralColorSet = true;
|
|
|
- return this;
|
|
|
+ return neutralColor(DialogUtils.getActionTextStateList(context, color));
|
|
|
}
|
|
|
|
|
|
public Builder neutralColorRes(@ColorRes int colorRes) {
|
|
|
- return neutralColor(this.context.getResources().getColor(colorRes));
|
|
|
+ return neutralColor(DialogUtils.getActionTextColorStateList(this.context, colorRes));
|
|
|
}
|
|
|
|
|
|
public Builder neutralColorAttr(@AttrRes int colorAttr) {
|
|
|
- return neutralColor(DialogUtils.resolveColor(this.context, colorAttr));
|
|
|
+ return neutralColor(DialogUtils.resolveActionTextColorStateList(this.context, colorAttr, null));
|
|
|
+ }
|
|
|
+
|
|
|
+ public Builder neutralColor(ColorStateList colorStateList) {
|
|
|
+ this.neutralColor = colorStateList;
|
|
|
+ this.neutralColorSet = true;
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
public Builder listSelector(@DrawableRes int selectorRes) {
|
|
@@ -1661,4 +1674,4 @@ public class MaterialDialog extends DialogBase implements
|
|
|
|
|
|
void onInput(MaterialDialog dialog, CharSequence input);
|
|
|
}
|
|
|
-}
|
|
|
+}
|