diff options
-rw-r--r-- | res/values/strings.xml | 9 | ||||
-rw-r--r-- | res/xml/zen_mode_priority_settings.xml | 8 | ||||
-rw-r--r-- | src/com/android/settings/notification/ZenModePrioritySettings.java | 28 | ||||
-rw-r--r-- | src/com/android/settings/notification/ZenModeSettings.java | 3 |
4 files changed, 42 insertions, 6 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 940f6bf99..e300d425b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5915,6 +5915,15 @@ <!-- [CHAR LIMIT=50] Zen mode settings: Events option --> <string name="zen_mode_events">Events</string> + <!-- [CHAR LIMIT=50] Zen mode settings: Selected callers summary --> + <string name="zen_mode_selected_callers">Selected callers</string> + + <!-- [CHAR LIMIT=50] Zen mode settings: Repeat callers option --> + <string name="zen_mode_repeat_callers">Repeat callers</string> + + <!-- [CHAR LIMIT=200] Zen mode settings: Repeat callers option summary --> + <string name="zen_mode_repeat_callers_summary">If the same person calls a second time within a <xliff:g id="minutes">%d</xliff:g> minute period, allow it</string> + <!-- [CHAR LIMIT=20] Zen mode settings: When option --> <string name="zen_mode_when">Automatically turn on</string> diff --git a/res/xml/zen_mode_priority_settings.xml b/res/xml/zen_mode_priority_settings.xml index 6cdbe95c0..5b1dbf8e5 100644 --- a/res/xml/zen_mode_priority_settings.xml +++ b/res/xml/zen_mode_priority_settings.xml @@ -67,4 +67,12 @@ android:title="@string/zen_mode_from" android:persistent="false" /> + <!-- Repeat callers --> + <SwitchPreference + android:key="repeat_callers" + android:title="@string/zen_mode_repeat_callers" + android:persistent="false" + android:switchTextOff="" + android:switchTextOn="" /> + </PreferenceScreen> diff --git a/src/com/android/settings/notification/ZenModePrioritySettings.java b/src/com/android/settings/notification/ZenModePrioritySettings.java index af74a46fc..89e9ea384 100644 --- a/src/com/android/settings/notification/ZenModePrioritySettings.java +++ b/src/com/android/settings/notification/ZenModePrioritySettings.java @@ -35,6 +35,7 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde private static final String KEY_MESSAGES = "messages"; private static final String KEY_CALLS = "calls"; private static final String KEY_STARRED = "starred"; + private static final String KEY_REPEAT_CALLERS = "repeat_callers"; private boolean mDisableListeners; private SwitchPreference mReminders; @@ -42,6 +43,7 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde private SwitchPreference mMessages; private SwitchPreference mCalls; private DropDownPreference mStarred; + private SwitchPreference mRepeatCallers; @Override public void onCreate(Bundle savedInstanceState) { @@ -123,6 +125,23 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde } }); + mRepeatCallers = (SwitchPreference) root.findPreference(KEY_REPEAT_CALLERS); + mRepeatCallers.setSummary(mContext.getString(R.string.zen_mode_repeat_callers_summary, + mContext.getResources().getInteger(com.android.internal.R.integer + .config_zen_repeat_callers_threshold))); + mRepeatCallers.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + if (mDisableListeners) return true; + final boolean val = (Boolean) newValue; + if (val == mConfig.allowRepeatCallers) return true; + if (DEBUG) Log.d(TAG, "onPrefChange allowRepeatCallers=" + val); + final ZenModeConfig newConfig = mConfig.copy(); + newConfig.allowRepeatCallers = val; + return setZenModeConfig(newConfig); + } + }); + updateControls(); } @@ -143,9 +162,12 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde } mMessages.setChecked(mConfig.allowMessages); mStarred.setSelectedValue(mConfig.allowFrom); + mStarred.setEnabled(mConfig.allowCalls || mConfig.allowMessages); mReminders.setChecked(mConfig.allowReminders); mEvents.setChecked(mConfig.allowEvents); - updateStarredEnabled(); + mRepeatCallers.setChecked(mConfig.allowRepeatCallers); + mRepeatCallers.setEnabled(!mConfig.allowCalls + || mConfig.allowFrom != ZenModeConfig.SOURCE_ANYONE); mDisableListeners = false; } @@ -154,8 +176,4 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde return MetricsLogger.NOTIFICATION_ZEN_MODE_PRIORITY; } - private void updateStarredEnabled() { - mStarred.setEnabled(mConfig.allowCalls || mConfig.allowMessages); - } - } diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java index 88ecef593..24774cb69 100644 --- a/src/com/android/settings/notification/ZenModeSettings.java +++ b/src/com/android/settings/notification/ZenModeSettings.java @@ -159,10 +159,11 @@ public class ZenModeSettings extends ZenModeSettingsBase } private void updatePrioritySettingsSummary() { + final boolean callers = mConfig.allowCalls || mConfig.allowRepeatCallers; String s = getResources().getString(R.string.zen_mode_alarms); s = appendLowercase(s, mConfig.allowReminders, R.string.zen_mode_reminders); s = appendLowercase(s, mConfig.allowEvents, R.string.zen_mode_events); - s = appendLowercase(s, mConfig.allowCalls, R.string.zen_mode_calls); + s = appendLowercase(s, callers, R.string.zen_mode_selected_callers); s = appendLowercase(s, mConfig.allowMessages, R.string.zen_mode_messages); mPrioritySettings.setSummary(s); } |