Merge "Settings: Allow user to configure "None" for downtime." into lmp-mr1-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 933497e..25bacb3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5822,7 +5822,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>
@@ -5830,6 +5830,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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
updateDays();
mStart.setTime(mConfig.sleepStartHour, mConfig.sleepStartMinute);
mEnd.setTime(mConfig.sleepEndHour, mConfig.sleepEndMinute);
+ mDowntimeMode.setSelectedValue(mConfig.sleepNone);
mDisableListeners = false;
refreshAutomationSection();
updateEndSummary();