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

Commit c8549629 authored by Beverly's avatar Beverly
Browse files

System gets its own dnd toggle

Test: make ROBOTEST_FILTER=ZenModeSystemPreferenceControllerTest RunSettingsRoboTests -j40
Bug: 73362490
Change-Id: Id5212665da8c820fc070676ff034dbe67510ea5d
parent 22a39c2b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -7528,10 +7528,10 @@
    <string name="zen_mode_alarms">Alarms</string>
    <!-- [CHAR LIMIT=50] Zen mode settings: Media option -->
    <string name="zen_mode_media_system_other">Media</string>
    <string name="zen_mode_media">Media</string>
    <!-- [CHAR LIMIT=120] Zen mode settings: Media secondary text explaining sounds include system feedback such as system tapping sounds, haptic feedback, etc. -->
    <string name="zen_mode_media_system_other_secondary_text">Includes system feedback like touch and charging sounds</string>
    <!-- [CHAR LIMIT=50] Zen mode settings: System option which includes sounds such as touch and charging sounds -->
    <string name="zen_mode_system">Touch and charging sounds</string>
    <!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
    <string name="zen_mode_reminders">Reminders</string>
+7 −3
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="zen_mode_behavior_settings_page"
    android:title="@string/zen_mode_behavior_settings_title"
    settings:initialExpandedChildrenCount="7">
    settings:initialExpandedChildrenCount="8">

   <PreferenceCategory
       android:title="@string/zen_mode_behavior_allow_title"
@@ -34,8 +34,12 @@
       <!-- Media -->
       <SwitchPreference
           android:key="zen_mode_media"
           android:title="@string/zen_mode_media_system_other"
           android:summary="@string/zen_mode_media_system_other_secondary_text"/>
           android:title="@string/zen_mode_media"/>

       <!-- System -->
       <SwitchPreference
           android:key="zen_mode_system"
           android:title="@string/zen_mode_system"/>

       <!-- Reminders -->
       <SwitchPreference
+3 −2
Original line number Diff line number Diff line
@@ -40,7 +40,8 @@ public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Inde
            Lifecycle lifecycle) {
        List<AbstractPreferenceController> controllers = new ArrayList<>();
        controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle));
        controllers.add(new ZenModeMediaSystemOtherPreferenceController(context, lifecycle));
        controllers.add(new ZenModeMediaPreferenceController(context, lifecycle));
        controllers.add(new ZenModeSystemPreferenceController(context, lifecycle));
        controllers.add(new ZenModeEventsPreferenceController(context, lifecycle));
        controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle));
        controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle));
@@ -85,7 +86,7 @@ public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Inde
                public List<String> getNonIndexableKeys(Context context) {
                    final List<String> keys = super.getNonIndexableKeys(context);
                    keys.add(ZenModeAlarmsPreferenceController.KEY);
                    keys.add(ZenModeMediaSystemOtherPreferenceController.KEY);
                    keys.add(ZenModeMediaPreferenceController.KEY);
                    keys.add(ZenModeEventsPreferenceController.KEY);
                    keys.add(ZenModeRemindersPreferenceController.KEY);
                    keys.add(ZenModeMessagesPreferenceController.KEY);
+5 −5
Original line number Diff line number Diff line
@@ -25,13 +25,13 @@ import android.util.Log;

import com.android.settingslib.core.lifecycle.Lifecycle;

public class ZenModeMediaSystemOtherPreferenceController extends AbstractZenModePreferenceController
public class ZenModeMediaPreferenceController extends AbstractZenModePreferenceController
        implements Preference.OnPreferenceChangeListener {

    protected static final String KEY = "zen_mode_media";
    private final ZenModeBackend mBackend;

    public ZenModeMediaSystemOtherPreferenceController(Context context, Lifecycle lifecycle) {
    public ZenModeMediaPreferenceController(Context context, Lifecycle lifecycle) {
        super(context, KEY, lifecycle);
        mBackend = ZenModeBackend.getInstance(context);
    }
@@ -63,7 +63,7 @@ public class ZenModeMediaSystemOtherPreferenceController extends AbstractZenMode
            default:
                pref.setEnabled(true);
                pref.setChecked(mBackend.isPriorityCategoryEnabled(
                        Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER));
                        Policy.PRIORITY_CATEGORY_MEDIA));
        }
    }

@@ -71,9 +71,9 @@ public class ZenModeMediaSystemOtherPreferenceController extends AbstractZenMode
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        final boolean allowMedia = (Boolean) newValue;
        if (ZenModeSettingsBase.DEBUG) {
            Log.d(TAG, "onPrefChange allowMediaSystemOther=" + allowMedia);
            Log.d(TAG, "onPrefChange allowMedia=" + allowMedia);
        }
        mBackend.saveSoundPolicy(Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER, allowMedia);
        mBackend.saveSoundPolicy(Policy.PRIORITY_CATEGORY_MEDIA, allowMedia);
        return true;
    }
}
+10 −5
Original line number Diff line number Diff line
@@ -77,9 +77,11 @@ public class ZenModeSettings extends ZenModeSettingsBase {
            mContext = context;
        }

        // these should match NotificationManager.Policy#ALL_PRIORITY_CATEGORIES
        private static final int[] ALL_PRIORITY_CATEGORIES = {
                Policy.PRIORITY_CATEGORY_ALARMS,
                Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER,
                Policy.PRIORITY_CATEGORY_MEDIA,
                Policy.PRIORITY_CATEGORY_SYSTEM,
                Policy.PRIORITY_CATEGORY_REMINDERS,
                Policy.PRIORITY_CATEGORY_EVENTS,
                Policy.PRIORITY_CATEGORY_MESSAGES,
@@ -104,10 +106,10 @@ public class ZenModeSettings extends ZenModeSettingsBase {
                return mContext.getString(R.string.zen_mode_behavior_total_silence);
            }

            // only alarms and media/system can bypass dnd
            // only alarms and media can bypass dnd
            if (numCategories == 2 &&
                    isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_ALARMS) &&
                    isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER)) {
                    isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_MEDIA)) {
                return mContext.getString(R.string.zen_mode_behavior_alarms_only);
            }

@@ -164,9 +166,12 @@ public class ZenModeSettings extends ZenModeSettingsBase {
                if (isCategoryEnabled(policy, category)) {
                    if (category == Policy.PRIORITY_CATEGORY_ALARMS) {
                        enabledCategories.add(mContext.getString(R.string.zen_mode_alarms));
                    } else if (category == Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) {
                    } else if (category == Policy.PRIORITY_CATEGORY_MEDIA) {
                        enabledCategories.add(mContext.getString(
                                R.string.zen_mode_media_system_other));
                                R.string.zen_mode_media));
                    } else if (category == Policy.PRIORITY_CATEGORY_SYSTEM) {
                        enabledCategories.add(mContext.getString(
                                R.string.zen_mode_system));
                    } else if (category == Policy.PRIORITY_CATEGORY_REMINDERS) {
                        enabledCategories.add(mContext.getString(R.string.zen_mode_reminders));
                    } else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
Loading