summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2015-05-05 18:31:27 -0400
committerJohn Spurlock <jspurlock@google.com>2015-05-05 18:50:15 -0400
commit0d2a8d204bb7d62834d51393a1d4a6ddaa7753f8 (patch)
treeebb6697e04402a640b0ba8f0bc4ccd9aa2e65a46
parentfaadcd60e7ab8fa6eb9b5be7be907129bd3f8575 (diff)
downloadpackages_apps_Settings-0d2a8d204bb7d62834d51393a1d4a6ddaa7753f8.zip
packages_apps_Settings-0d2a8d204bb7d62834d51393a1d4a6ddaa7753f8.tar.gz
packages_apps_Settings-0d2a8d204bb7d62834d51393a1d4a6ddaa7753f8.tar.bz2
Settings: Migrate calls & messages priority settings.
Bug: 18635172 Change-Id: Ib5fe3bc80590875bb4a1547013ac3444939ab6fd
-rw-r--r--res/values/strings.xml16
-rw-r--r--res/xml/zen_mode_priority_settings.xml18
-rw-r--r--src/com/android/settings/notification/ZenModePrioritySettings.java81
3 files changed, 54 insertions, 61 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ebef5de..ce56b63 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6160,17 +6160,17 @@
<!-- [CHAR LIMIT=20] Zen mode settings: Messages option -->
<string name="zen_mode_messages">Messages</string>
- <!-- [CHAR LIMIT=50] Zen mode settings: From option -->
- <string name="zen_mode_from">Calls/messages from</string>
+ <!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From anyone -->
+ <string name="zen_mode_from_anyone">From anyone</string>
- <!-- [CHAR LIMIT=30] Zen mode settings: From option value: Anyone -->
- <string name="zen_mode_from_anyone">Anyone</string>
+ <!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From contacts only -->
+ <string name="zen_mode_from_contacts">From contacts only</string>
- <!-- [CHAR LIMIT=30] Zen mode settings: From option value: Contacts -->
- <string name="zen_mode_from_contacts">Contacts only</string>
+ <!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From starred contacts only -->
+ <string name="zen_mode_from_starred">From starred contacts only</string>
- <!-- [CHAR LIMIT=30] Zen mode settings: From option value: Starred contacts -->
- <string name="zen_mode_from_starred">Starred contacts only</string>
+ <!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: None -->
+ <string name="zen_mode_from_none">None</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Alarms option -->
<string name="zen_mode_alarms">Alarms</string>
diff --git a/res/xml/zen_mode_priority_settings.xml b/res/xml/zen_mode_priority_settings.xml
index 5b1dbf8..bfe0871 100644
--- a/res/xml/zen_mode_priority_settings.xml
+++ b/res/xml/zen_mode_priority_settings.xml
@@ -46,26 +46,16 @@
android:switchTextOn="" />
<!-- Messages -->
- <SwitchPreference
+ <com.android.settings.DropDownPreference
android:key="messages"
android:title="@string/zen_mode_messages"
- android:persistent="false"
- android:switchTextOff=""
- android:switchTextOn="" />
+ android:persistent="false" />
<!-- Calls -->
- <SwitchPreference
+ <com.android.settings.DropDownPreference
android:key="calls"
android:title="@string/zen_mode_calls"
- android:persistent="false"
- android:switchTextOff=""
- android:switchTextOn="" />
-
- <!-- Messages/calls from -->
- <com.android.settings.DropDownPreference
- android:key="starred"
- android:title="@string/zen_mode_from"
- android:persistent="false" />
+ android:persistent="false" />
<!-- Repeat callers -->
<SwitchPreference
diff --git a/src/com/android/settings/notification/ZenModePrioritySettings.java b/src/com/android/settings/notification/ZenModePrioritySettings.java
index 89e9ea3..4907cf0 100644
--- a/src/com/android/settings/notification/ZenModePrioritySettings.java
+++ b/src/com/android/settings/notification/ZenModePrioritySettings.java
@@ -34,15 +34,15 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde
private static final String KEY_EVENTS = "events";
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 static final int SOURCE_NONE = -1;
+
private boolean mDisableListeners;
private SwitchPreference mReminders;
private SwitchPreference mEvents;
- private SwitchPreference mMessages;
- private SwitchPreference mCalls;
- private DropDownPreference mStarred;
+ private DropDownPreference mMessages;
+ private DropDownPreference mCalls;
private SwitchPreference mRepeatCallers;
@Override
@@ -79,48 +79,46 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde
}
});
- mMessages = (SwitchPreference) root.findPreference(KEY_MESSAGES);
- mMessages.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (mDisableListeners) return true;
- final boolean val = (Boolean) newValue;
- if (val == mConfig.allowMessages) return true;
- if (DEBUG) Log.d(TAG, "onPrefChange allowMessages=" + val);
- final ZenModeConfig newConfig = mConfig.copy();
- newConfig.allowMessages = val;
- return setZenModeConfig(newConfig);
- }
- });
-
- mCalls = (SwitchPreference) root.findPreference(KEY_CALLS);
- mCalls.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ mMessages = (DropDownPreference) root.findPreference(KEY_MESSAGES);
+ addSources(mMessages);
+ mMessages.setCallback(new DropDownPreference.Callback() {
@Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
+ public boolean onItemSelected(int pos, Object newValue) {
if (mDisableListeners) return true;
- final boolean val = (Boolean) newValue;
- if (val == mConfig.allowCalls) return true;
- if (DEBUG) Log.d(TAG, "onPrefChange allowCalls=" + val);
+ final int val = (Integer) newValue;
+ final boolean allowMessages = val != SOURCE_NONE;
+ final int allowMessagesFrom = val == SOURCE_NONE ? mConfig.allowMessagesFrom : val;
+ if (allowMessages == mConfig.allowMessages
+ && allowMessagesFrom == mConfig.allowMessagesFrom) {
+ return true;
+ }
+ if (DEBUG) Log.d(TAG, "onPrefChange allowMessages=" + allowMessages
+ + " allowMessagesFrom=" + ZenModeConfig.sourceToString(allowMessagesFrom));
final ZenModeConfig newConfig = mConfig.copy();
- newConfig.allowCalls = val;
+ newConfig.allowMessages = allowMessages;
+ newConfig.allowMessagesFrom = allowMessagesFrom;
return setZenModeConfig(newConfig);
}
});
- mStarred = (DropDownPreference) root.findPreference(KEY_STARRED);
- mStarred.addItem(R.string.zen_mode_from_anyone, ZenModeConfig.SOURCE_ANYONE);
- mStarred.addItem(R.string.zen_mode_from_contacts, ZenModeConfig.SOURCE_CONTACT);
- mStarred.addItem(R.string.zen_mode_from_starred, ZenModeConfig.SOURCE_STAR);
- mStarred.setCallback(new DropDownPreference.Callback() {
+ mCalls = (DropDownPreference) root.findPreference(KEY_CALLS);
+ addSources(mCalls);
+ mCalls.setCallback(new DropDownPreference.Callback() {
@Override
public boolean onItemSelected(int pos, Object newValue) {
if (mDisableListeners) return true;
final int val = (Integer) newValue;
- if (val == mConfig.allowFrom) return true;
- if (DEBUG) Log.d(TAG, "onPrefChange allowFrom=" +
- ZenModeConfig.sourceToString(val));
+ final boolean allowCalls = val != SOURCE_NONE;
+ final int allowCallsFrom = val == SOURCE_NONE ? mConfig.allowCallsFrom : val;
+ if (allowCalls == mConfig.allowCalls
+ && allowCallsFrom == mConfig.allowCallsFrom) {
+ return true;
+ }
+ if (DEBUG) Log.d(TAG, "onPrefChange allowCalls=" + allowCalls
+ + " allowCallsFrom=" + ZenModeConfig.sourceToString(allowCallsFrom));
final ZenModeConfig newConfig = mConfig.copy();
- newConfig.allowFrom = val;
+ newConfig.allowCalls = allowCalls;
+ newConfig.allowCallsFrom = allowCallsFrom;
return setZenModeConfig(newConfig);
}
});
@@ -158,16 +156,14 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde
private void updateControls() {
mDisableListeners = true;
if (mCalls != null) {
- mCalls.setChecked(mConfig.allowCalls);
+ mCalls.setSelectedValue(mConfig.allowCalls ? mConfig.allowCallsFrom : SOURCE_NONE);
}
- mMessages.setChecked(mConfig.allowMessages);
- mStarred.setSelectedValue(mConfig.allowFrom);
- mStarred.setEnabled(mConfig.allowCalls || mConfig.allowMessages);
+ mMessages.setSelectedValue(mConfig.allowMessages ? mConfig.allowMessagesFrom : SOURCE_NONE);
mReminders.setChecked(mConfig.allowReminders);
mEvents.setChecked(mConfig.allowEvents);
mRepeatCallers.setChecked(mConfig.allowRepeatCallers);
mRepeatCallers.setEnabled(!mConfig.allowCalls
- || mConfig.allowFrom != ZenModeConfig.SOURCE_ANYONE);
+ || mConfig.allowCallsFrom != ZenModeConfig.SOURCE_ANYONE);
mDisableListeners = false;
}
@@ -176,4 +172,11 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase implements Inde
return MetricsLogger.NOTIFICATION_ZEN_MODE_PRIORITY;
}
+ private static void addSources(DropDownPreference pref) {
+ pref.addItem(R.string.zen_mode_from_anyone, ZenModeConfig.SOURCE_ANYONE);
+ pref.addItem(R.string.zen_mode_from_contacts, ZenModeConfig.SOURCE_CONTACT);
+ pref.addItem(R.string.zen_mode_from_starred, ZenModeConfig.SOURCE_STAR);
+ pref.addItem(R.string.zen_mode_from_none, SOURCE_NONE);
+ }
+
}