diff options
author | John Spurlock <jspurlock@google.com> | 2015-06-04 15:41:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-04 15:41:58 +0000 |
commit | 1a1181edde0d8d941161e941f12e6783f25ae43d (patch) | |
tree | faa770be63aa805bb0942f36210da402aef2817a /src/com/android/settings/notification | |
parent | cd5b97dfad920ca5f84e42f3e0dbb648550637e6 (diff) | |
parent | 7b4d1e2cb8684dc1bece3cfe4edfb43b73a00565 (diff) | |
download | packages_apps_Settings-1a1181edde0d8d941161e941f12e6783f25ae43d.zip packages_apps_Settings-1a1181edde0d8d941161e941f12e6783f25ae43d.tar.gz packages_apps_Settings-1a1181edde0d8d941161e941f12e6783f25ae43d.tar.bz2 |
Merge "Settings: Add zen rule name warning text." into mnc-dev
Diffstat (limited to 'src/com/android/settings/notification')
-rw-r--r-- | src/com/android/settings/notification/ZenRuleNameDialog.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/com/android/settings/notification/ZenRuleNameDialog.java b/src/com/android/settings/notification/ZenRuleNameDialog.java index 1279ee6..c06038e 100644 --- a/src/com/android/settings/notification/ZenRuleNameDialog.java +++ b/src/com/android/settings/notification/ZenRuleNameDialog.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; import android.content.pm.ServiceInfo; +import android.content.res.ColorStateList; import android.net.Uri; import android.service.notification.ZenModeConfig; import android.service.notification.ZenModeConfig.EventInfo; @@ -31,6 +32,7 @@ import android.text.TextUtils; import android.text.TextWatcher; import android.util.ArraySet; import android.util.Log; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; @@ -47,7 +49,10 @@ public abstract class ZenRuleNameDialog { private final AlertDialog mDialog; private final EditText mEditText; + private final View mWarning; private final RadioGroup mTypes; + private final ColorStateList mWarningTint; + private final ColorStateList mOriginalTint; private final String mOriginalRuleName; private final ArraySet<String> mExistingNames; private final ServiceListing mServiceListing; @@ -59,11 +64,16 @@ public abstract class ZenRuleNameDialog { mServiceListing = serviceListing; mIsNew = ruleName == null; mOriginalRuleName = ruleName; + mWarningTint = ColorStateList.valueOf(context.getColor(R.color.zen_rule_name_warning)); final View v = LayoutInflater.from(context).inflate(R.layout.zen_rule_name, null, false); mEditText = (EditText) v.findViewById(R.id.rule_name); + mWarning = v.findViewById(R.id.rule_name_warning); if (!mIsNew) { mEditText.setText(ruleName); } + TypedValue outValue = new TypedValue(); + context.getTheme().resolveAttribute(android.R.attr.colorAccent, outValue, true); + mOriginalTint = ColorStateList.valueOf(outValue.data); mEditText.setSelectAllOnFocus(true); mTypes = (RadioGroup) v.findViewById(R.id.rule_types); if (mServiceListing != null) { @@ -112,7 +122,7 @@ public abstract class ZenRuleNameDialog { @Override public void afterTextChanged(Editable s) { - updatePositiveButton(); + updatePositiveButtonAndWarning(); } }); mExistingNames = new ArraySet<String>(existingNames.size()); @@ -125,7 +135,7 @@ public abstract class ZenRuleNameDialog { public void show() { mDialog.show(); - updatePositiveButton(); + updatePositiveButtonAndWarning(); } private void bindType(int id, RuleInfo ri) { @@ -152,12 +162,15 @@ public abstract class ZenRuleNameDialog { return mEditText.getText() == null ? null : mEditText.getText().toString().trim(); } - private void updatePositiveButton() { + private void updatePositiveButtonAndWarning() { final String name = trimmedText(); final boolean validName = !TextUtils.isEmpty(name) && (name.equalsIgnoreCase(mOriginalRuleName) || !mExistingNames.contains(name.toLowerCase())); mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(validName); + final boolean showWarning = !TextUtils.isEmpty(name) && !validName; + mWarning.setVisibility(showWarning ? View.VISIBLE : View.INVISIBLE); + mEditText.setBackgroundTintList(showWarning ? mWarningTint : mOriginalTint); } private static RuleInfo defaultNewSchedule() { |