diff options
author | John Spurlock <jspurlock@google.com> | 2015-04-10 08:11:12 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2015-04-10 08:12:14 -0400 |
commit | 35fba3eeafe47ccd900b3e18b6b64a16ad677462 (patch) | |
tree | 9e97d1ba2b6c81bf586ec8c816109baf591a73d2 /src/com | |
parent | d333a7d9f10500ec45377e099955031017d6a158 (diff) | |
download | packages_apps_Settings-35fba3eeafe47ccd900b3e18b6b64a16ad677462.tar.gz packages_apps_Settings-35fba3eeafe47ccd900b3e18b6b64a16ad677462.tar.bz2 packages_apps_Settings-35fba3eeafe47ccd900b3e18b6b64a16ad677462.zip |
Settings: New zen option to allow repeat callers.
Bug: 20064962
Change-Id: Icc65da146503386c057d7f78d6610f83f56d1a92
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/settings/notification/ZenModePrioritySettings.java | 28 | ||||
-rw-r--r-- | src/com/android/settings/notification/ZenModeSettings.java | 3 |
2 files changed, 25 insertions, 6 deletions
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); } |