Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92f02463 authored by John Spurlock's avatar John Spurlock Committed by Android (Google) Code Review
Browse files

Merge "Settings: Allow user to configure "None" for downtime." into lmp-mr1-dev

parents 63530b56 645cc5cf
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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>

+10 −0
Original line number Diff line number Diff line
@@ -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
+23 −1
Original line number Diff line number Diff line
@@ -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();