summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2014-11-05 12:04:16 -0500
committerJohn Spurlock <jspurlock@google.com>2014-11-05 12:04:16 -0500
commit645cc5cf82258dcefe5cd4a38710df5c77226dba (patch)
tree6157d657f9c4d1bb068932b853c83e0f3e53e40c
parent7db037a989ea9c106ea404681cfe22a1fd2a2973 (diff)
downloadpackages_apps_Settings-645cc5cf82258dcefe5cd4a38710df5c77226dba.zip
packages_apps_Settings-645cc5cf82258dcefe5cd4a38710df5c77226dba.tar.gz
packages_apps_Settings-645cc5cf82258dcefe5cd4a38710df5c77226dba.tar.bz2
Settings: Allow user to configure "None" for downtime.
New setting under Zen > Downtime subcategory. Also rename the category header, remove obsolete parenthetical. Bug: 16373455 Change-Id: Ic3430e1795fc79c315dea3c24d88dfcde6742849
-rw-r--r--res/values/strings.xml11
-rw-r--r--res/xml/zen_mode_settings.xml10
-rw-r--r--src/com/android/settings/notification/ZenModeSettings.java24
3 files changed, 43 insertions, 2 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7afec0b..06f48ce 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5819,7 +5819,7 @@
<string name="zen_mode_important_category">Priority interruptions</string>
<!-- [CHAR LIMIT=60] Zen mode settings: Downtime category text -->
- <string name="zen_mode_downtime_category">Downtime (priority interruptions only)</string>
+ <string name="zen_mode_downtime_category">Downtime</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Downtime days option title -->
<string name="zen_mode_downtime_days">Days</string>
@@ -5827,6 +5827,15 @@
<!-- [CHAR LIMIT=40] Zen mode settings: Downtime days option value, no days set -->
<string name="zen_mode_downtime_days_none">None</string>
+ <!-- [CHAR LIMIT=60] Zen mode settings: Downtime mode option title -->
+ <string name="zen_mode_downtime_mode_title">Interruptions allowed</string>
+
+ <!-- [CHAR LIMIT=40] Zen mode settings: Downtime mode option value, priority only -->
+ <string name="zen_mode_downtime_mode_priority">Priority only</string>
+
+ <!-- [CHAR LIMIT=40] Zen mode settings: Downtime mode option value, none -->
+ <string name="zen_mode_downtime_mode_none">None</string>
+
<!-- [CHAR LIMIT=40] Zen mode settings: Automation category text -->
<string name="zen_mode_automation_category">Automation</string>
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index 9a450e0..7514565 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -65,15 +65,25 @@
</PreferenceCategory>
+ <!-- Downtime -->
<PreferenceCategory
android:key="downtime"
android:title="@string/zen_mode_downtime_category" >
+ <!-- Days -->
<Preference
android:key="days"
android:title="@string/zen_mode_downtime_days"
android:persistent="false" />
+ <!-- Start time/End time added and removed here! :-) -->
+
+ <!-- Interruptions allowed -->
+ <com.android.settings.notification.DropDownPreference
+ android:key="downtime_mode"
+ android:title="@string/zen_mode_downtime_mode_title"
+ android:order="100"
+ android:persistent="false" />
</PreferenceCategory>
<PreferenceCategory
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index 64a5d81..71ff664 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -63,7 +63,7 @@ import java.util.Objects;
public class ZenModeSettings extends SettingsPreferenceFragment implements Indexable {
private static final String TAG = "ZenModeSettings";
- private static final boolean DEBUG = true;
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final String KEY_ZEN_MODE = "zen_mode";
private static final String KEY_IMPORTANT = "important";
@@ -77,6 +77,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
private static final String KEY_DAYS = "days";
private static final String KEY_START_TIME = "start_time";
private static final String KEY_END_TIME = "end_time";
+ private static final String KEY_DOWNTIME_MODE = "downtime_mode";
private static final String KEY_AUTOMATION = "automation";
private static final String KEY_ENTRY = "entry";
@@ -113,6 +114,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
rt.put(R.string.zen_mode_downtime_days, KEY_DAYS);
rt.put(R.string.zen_mode_start_time, KEY_START_TIME);
rt.put(R.string.zen_mode_end_time, KEY_END_TIME);
+ rt.put(R.string.zen_mode_downtime_mode_title, KEY_DOWNTIME_MODE);
rt.put(R.string.zen_mode_automation_category, KEY_AUTOMATION);
rt.put(R.string.manage_condition_providers, KEY_CONDITION_PROVIDERS);
return rt;
@@ -132,6 +134,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
private Preference mDays;
private TimePickerPreference mStart;
private TimePickerPreference mEnd;
+ private DropDownPreference mDowntimeMode;
private PreferenceCategory mAutomationCategory;
private Preference mEntry;
private Preference mConditionProviders;
@@ -300,6 +303,24 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
downtime.addPreference(mEnd);
mEnd.setDependency(mDays.getKey());
+ mDowntimeMode = (DropDownPreference) downtime.findPreference(KEY_DOWNTIME_MODE);
+ mDowntimeMode.addItem(R.string.zen_mode_downtime_mode_priority, false);
+ mDowntimeMode.addItem(R.string.zen_mode_downtime_mode_none, true);
+ mDowntimeMode.setCallback(new DropDownPreference.Callback() {
+ @Override
+ public boolean onItemSelected(int pos, Object value) {
+ if (mDisableListeners) return true;
+ final boolean sleepNone = value instanceof Boolean ? ((Boolean) value) : false;
+ if (mConfig == null || mConfig.sleepNone == sleepNone) return false;
+ final ZenModeConfig newConfig = mConfig.copy();
+ newConfig.sleepNone = sleepNone;
+ if (DEBUG) Log.d(TAG, "onPrefChange sleepNone=" + sleepNone);
+ return setZenModeConfig(newConfig);
+ }
+ });
+ mDowntimeMode.setOrder(10); // sort at the bottom of the category
+ mDowntimeMode.setDependency(mDays.getKey());
+
mAutomationCategory = (PreferenceCategory) findPreference(KEY_AUTOMATION);
mEntry = findPreference(KEY_ENTRY);
mEntry.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@@ -373,6 +394,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
updateDays();
mStart.setTime(mConfig.sleepStartHour, mConfig.sleepStartMinute);
mEnd.setTime(mConfig.sleepEndHour, mConfig.sleepEndMinute);
+ mDowntimeMode.setSelectedValue(mConfig.sleepNone);
mDisableListeners = false;
refreshAutomationSection();
updateEndSummary();