Merge "Settings: Add zen rule name warning text." into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1a1181edde
@@ -32,13 +32,23 @@
|
|||||||
|
|
||||||
</EditText>
|
</EditText>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/rule_name_warning"
|
||||||
|
android:visibility="invisible"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:layout_marginLeft="26dp"
|
||||||
|
android:layout_marginRight="26dp"
|
||||||
|
android:textColor="@color/zen_rule_name_warning"
|
||||||
|
android:text="@string/zen_mode_rule_name_warning" />
|
||||||
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
android:id="@+id/rule_types"
|
android:id="@+id/rule_types"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="22dp"
|
android:layout_marginLeft="22dp"
|
||||||
android:layout_marginRight="22dp"
|
android:layout_marginRight="22dp"
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:checkedButton="@+id/rule_type_schedule" >
|
android:checkedButton="@+id/rule_type_schedule" >
|
||||||
|
|
||||||
|
@@ -50,6 +50,8 @@
|
|||||||
<color name="setup_wizard_wifi_color_dark">#89ffffff</color>
|
<color name="setup_wizard_wifi_color_dark">#89ffffff</color>
|
||||||
<color name="setup_wizard_wifi_color_light">#89000000</color>
|
<color name="setup_wizard_wifi_color_light">#89000000</color>
|
||||||
|
|
||||||
|
<color name="system_warning_color">#fff4511e</color><!-- deep orange 600 -->
|
||||||
|
|
||||||
<color name="lock_pattern_background">#00000000</color>
|
<color name="lock_pattern_background">#00000000</color>
|
||||||
<color name="lock_pattern_view_regular_color">#ff37474f</color>
|
<color name="lock_pattern_view_regular_color">#ff37474f</color>
|
||||||
<color name="lock_pattern_view_error_color">@color/warning</color>
|
<color name="lock_pattern_view_error_color">@color/warning</color>
|
||||||
@@ -57,7 +59,7 @@
|
|||||||
<color name="lock_pattern_view_regular_color_dark">#ffffff</color>
|
<color name="lock_pattern_view_regular_color_dark">#ffffff</color>
|
||||||
|
|
||||||
<color name="unlock_pattern_view_regular_color">@android:color/white</color>
|
<color name="unlock_pattern_view_regular_color">@android:color/white</color>
|
||||||
<color name="unlock_pattern_view_error_color">#fff4511e</color>
|
<color name="unlock_pattern_view_error_color">@color/system_warning_color</color>
|
||||||
|
|
||||||
<color name="fingerprint_title_area_bg">#ff009688</color>
|
<color name="fingerprint_title_area_bg">#ff009688</color>
|
||||||
<color name="fingerprint_title_color">#ffffffff</color>
|
<color name="fingerprint_title_color">#ffffffff</color>
|
||||||
@@ -96,4 +98,6 @@
|
|||||||
<color name="memory_max_use">#ff009587</color>
|
<color name="memory_max_use">#ff009587</color>
|
||||||
<color name="memory_remaining">#ffced7db</color>
|
<color name="memory_remaining">#ffced7db</color>
|
||||||
|
|
||||||
|
<color name="zen_rule_name_warning">@color/system_warning_color</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -6104,6 +6104,9 @@
|
|||||||
<!-- [CHAR LIMIT=40] Zen mode settings: Rule name hint text -->
|
<!-- [CHAR LIMIT=40] Zen mode settings: Rule name hint text -->
|
||||||
<string name="zen_mode_rule_name_hint">Enter rule name</string>
|
<string name="zen_mode_rule_name_hint">Enter rule name</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=100] Zen mode settings: Warning text for invalid zen rule names -->
|
||||||
|
<string name="zen_mode_rule_name_warning">Rule name already in use</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=40] Zen mode settings: Add rule menu option name -->
|
<!-- [CHAR LIMIT=40] Zen mode settings: Add rule menu option name -->
|
||||||
<string name="zen_mode_add_rule">Add rule</string>
|
<string name="zen_mode_add_rule">Add rule</string>
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnDismissListener;
|
import android.content.DialogInterface.OnDismissListener;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.service.notification.ZenModeConfig;
|
import android.service.notification.ZenModeConfig;
|
||||||
import android.service.notification.ZenModeConfig.EventInfo;
|
import android.service.notification.ZenModeConfig.EventInfo;
|
||||||
@@ -31,6 +32,7 @@ import android.text.TextUtils;
|
|||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@@ -47,7 +49,10 @@ public abstract class ZenRuleNameDialog {
|
|||||||
|
|
||||||
private final AlertDialog mDialog;
|
private final AlertDialog mDialog;
|
||||||
private final EditText mEditText;
|
private final EditText mEditText;
|
||||||
|
private final View mWarning;
|
||||||
private final RadioGroup mTypes;
|
private final RadioGroup mTypes;
|
||||||
|
private final ColorStateList mWarningTint;
|
||||||
|
private final ColorStateList mOriginalTint;
|
||||||
private final String mOriginalRuleName;
|
private final String mOriginalRuleName;
|
||||||
private final ArraySet<String> mExistingNames;
|
private final ArraySet<String> mExistingNames;
|
||||||
private final ServiceListing mServiceListing;
|
private final ServiceListing mServiceListing;
|
||||||
@@ -59,11 +64,16 @@ public abstract class ZenRuleNameDialog {
|
|||||||
mServiceListing = serviceListing;
|
mServiceListing = serviceListing;
|
||||||
mIsNew = ruleName == null;
|
mIsNew = ruleName == null;
|
||||||
mOriginalRuleName = ruleName;
|
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);
|
final View v = LayoutInflater.from(context).inflate(R.layout.zen_rule_name, null, false);
|
||||||
mEditText = (EditText) v.findViewById(R.id.rule_name);
|
mEditText = (EditText) v.findViewById(R.id.rule_name);
|
||||||
|
mWarning = v.findViewById(R.id.rule_name_warning);
|
||||||
if (!mIsNew) {
|
if (!mIsNew) {
|
||||||
mEditText.setText(ruleName);
|
mEditText.setText(ruleName);
|
||||||
}
|
}
|
||||||
|
TypedValue outValue = new TypedValue();
|
||||||
|
context.getTheme().resolveAttribute(android.R.attr.colorAccent, outValue, true);
|
||||||
|
mOriginalTint = ColorStateList.valueOf(outValue.data);
|
||||||
mEditText.setSelectAllOnFocus(true);
|
mEditText.setSelectAllOnFocus(true);
|
||||||
mTypes = (RadioGroup) v.findViewById(R.id.rule_types);
|
mTypes = (RadioGroup) v.findViewById(R.id.rule_types);
|
||||||
if (mServiceListing != null) {
|
if (mServiceListing != null) {
|
||||||
@@ -112,7 +122,7 @@ public abstract class ZenRuleNameDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
updatePositiveButton();
|
updatePositiveButtonAndWarning();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mExistingNames = new ArraySet<String>(existingNames.size());
|
mExistingNames = new ArraySet<String>(existingNames.size());
|
||||||
@@ -125,7 +135,7 @@ public abstract class ZenRuleNameDialog {
|
|||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
mDialog.show();
|
mDialog.show();
|
||||||
updatePositiveButton();
|
updatePositiveButtonAndWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindType(int id, RuleInfo ri) {
|
private void bindType(int id, RuleInfo ri) {
|
||||||
@@ -152,12 +162,15 @@ public abstract class ZenRuleNameDialog {
|
|||||||
return mEditText.getText() == null ? null : mEditText.getText().toString().trim();
|
return mEditText.getText() == null ? null : mEditText.getText().toString().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePositiveButton() {
|
private void updatePositiveButtonAndWarning() {
|
||||||
final String name = trimmedText();
|
final String name = trimmedText();
|
||||||
final boolean validName = !TextUtils.isEmpty(name)
|
final boolean validName = !TextUtils.isEmpty(name)
|
||||||
&& (name.equalsIgnoreCase(mOriginalRuleName)
|
&& (name.equalsIgnoreCase(mOriginalRuleName)
|
||||||
|| !mExistingNames.contains(name.toLowerCase()));
|
|| !mExistingNames.contains(name.toLowerCase()));
|
||||||
mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(validName);
|
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() {
|
private static RuleInfo defaultNewSchedule() {
|
||||||
|
Reference in New Issue
Block a user