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

Commit 1879dd1a authored by Julia Reynolds's avatar Julia Reynolds Committed by android-build-merger
Browse files

Update DND visual interruption choices.

am: 9bfad94e

* commit '9bfad94e':
  Update DND visual interruption choices.
parents 62f75238 9bfad94e
Loading
Loading
Loading
Loading
+20 −17
Original line number Diff line number Diff line
@@ -6153,23 +6153,26 @@
    <!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: Turn on all notifications. -->
    <string name="zen_mode_summary_always">Change to always interrupt</string>
    <!-- [CHAR LIMIT=40] Zen mode settings: No screen interruptions option -->
    <string name="zen_mode_peek">No screen interruptions</string>
    <!-- [CHAR LIMIT=130] Zen mode settings: No screen interruptions summary -->
    <string name="zen_mode_peek_summary">Prevent notifications silenced by Do Not Disturb from peeking or appearing on the current screen</string>
    <!-- [CHAR LIMIT=40] Zen mode settings: No notification light option -->
    <string name="zen_mode_lights">No notification light</string>
    <!-- [CHAR LIMIT=105] Zen mode settings: No notification light summary -->
    <string name="zen_mode_lights_summary">Prevent notifications silenced by Do Not Disturb from causing the light to pulse</string>
    <!-- [CHAR LIMIT=40] Zen mode settings: Don't turn the screen on option -->
    <string name="zen_mode_screen_on">Never turn on the screen</string>
    <!-- [CHAR LIMIT=130] Zen mode settings: Don't turn the screen on summary -->
    <string name="zen_mode_screen_on_summary">If the screen is off, prevent notifications silenced by Do Not Disturb from turning it on</string>
    <!-- [CHAR LIMIT=40] Zen mode settings: visual interruptions: screen is on: title -->
    <string name="zen_mode_screen_on">Block when screen is on</string>
    <!-- [CHAR LIMIT=130] Zen mode settings:  visual interruptions: screen is on: summary -->
    <string name="zen_mode_screen_on_summary">Prevent notifications silenced by Do Not Disturb from peeking or popping on screen</string>
    <!-- [CHAR LIMIT=40] Zen mode settings: visual interruptions: screen is off: title -->
    <string name="zen_mode_screen_off">Block when screen is off</string>
    <!-- [CHAR LIMIT=130] Zen mode settings:  visual interruptions: screen is off: summary -->
    <string name="zen_mode_screen_off_summary">Prevent notifications silenced by Do Not Disturb from turning on the screen or pulsing the notification light</string>
    <!-- [CHAR LIMIT=130] Zen mode settings:  visual interruptions summary -->
    <string name="zen_mode_all_visual_interruptions">Off</string>
    <!-- [CHAR LIMIT=130] Zen mode settings:  visual interruptions summary -->
    <string name="zen_mode_screen_on_visual_interruptions">When screen is on</string>
    <!-- [CHAR LIMIT=130] Zen mode settings:  visual interruptions summary -->
    <string name="zen_mode_screen_off_visual_interruptions">When screen is off</string>
    <!-- [CHAR LIMIT=130] Zen mode settings:  visual interruptions summary -->
    <string name="zen_mode_no_visual_interruptions">When screen is on or off</string>
    <!-- [CHAR LIMIT=NONE] Content description for per-app notification
         settings button -->
+7 −9
Original line number Diff line number Diff line
@@ -18,16 +18,14 @@
                  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
                  android:title="@string/zen_mode_visual_interruptions_settings_title" >

    <SwitchPreference android:key="peek"
                      android:title="@string/zen_mode_peek"
                      android:summary="@string/zen_mode_peek_summary" />

    <SwitchPreference android:key="lights"
                      android:title="@string/zen_mode_lights"
                      android:summary="@string/zen_mode_lights_summary" />

    <SwitchPreference android:key="screen_on"
    <SwitchPreference android:key="screenOn"
                      android:title="@string/zen_mode_screen_on"
                      android:summary="@string/zen_mode_screen_on_summary" />

    <SwitchPreference android:key="screenOff"
                      android:title="@string/zen_mode_screen_off"
                      android:summary="@string/zen_mode_screen_off_summary" />



</PreferenceScreen>
+31 −9
Original line number Diff line number Diff line
@@ -31,8 +31,11 @@ import com.android.settings.SettingsActivity;

public class ZenModeSettings extends ZenModeSettingsBase {
    private static final String KEY_PRIORITY_SETTINGS = "priority_settings";
    private static final String KEY_VISUAL_SETTINGS = "visual_interruptions_settings";

    private Preference mPrioritySettings;
    private Preference mVisualSettings;
    private Policy mPolicy;

    @Override
    public void onCreate(Bundle savedInstanceState) {
@@ -42,6 +45,8 @@ public class ZenModeSettings extends ZenModeSettingsBase {
        final PreferenceScreen root = getPreferenceScreen();

        mPrioritySettings = root.findPreference(KEY_PRIORITY_SETTINGS);
        mVisualSettings = root.findPreference(KEY_VISUAL_SETTINGS);
        mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
    }

    @Override
@@ -50,7 +55,6 @@ public class ZenModeSettings extends ZenModeSettingsBase {
        if (isUiRestricted()) {
            return;
        }
        updateControls();
    }

    @Override
@@ -65,11 +69,13 @@ public class ZenModeSettings extends ZenModeSettingsBase {

    @Override
    protected void onZenModeConfigChanged() {
        mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
        updateControls();
    }

    private void updateControls() {
        updatePrioritySettingsSummary();
        updateVisualSettingsSummary();
    }

    @Override
@@ -90,31 +96,47 @@ public class ZenModeSettings extends ZenModeSettingsBase {
    }

    private void updatePrioritySettingsSummary() {
        Policy policy = NotificationManager.from(mContext).getNotificationPolicy();
        String s = getResources().getString(R.string.zen_mode_alarms);
        s = appendLowercase(s, isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_REMINDERS),
        s = appendLowercase(s, isCategoryEnabled(mPolicy, Policy.PRIORITY_CATEGORY_REMINDERS),
                R.string.zen_mode_reminders);
        s = appendLowercase(s, isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_EVENTS),
        s = appendLowercase(s, isCategoryEnabled(mPolicy, Policy.PRIORITY_CATEGORY_EVENTS),
                R.string.zen_mode_events);
        if (isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_MESSAGES)) {
            if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
        if (isCategoryEnabled(mPolicy, Policy.PRIORITY_CATEGORY_MESSAGES)) {
            if (mPolicy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
                s = appendLowercase(s, true, R.string.zen_mode_all_messages);
            } else {
                s = appendLowercase(s, true, R.string.zen_mode_selected_messages);
            }
        }
        if (isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_CALLS)) {
            if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
        if (isCategoryEnabled(mPolicy, Policy.PRIORITY_CATEGORY_CALLS)) {
            if (mPolicy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
                s = appendLowercase(s, true, R.string.zen_mode_all_callers);
            } else {
                s = appendLowercase(s, true, R.string.zen_mode_selected_callers);
            }
        } else if (isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_REPEAT_CALLERS)) {
        } else if (isCategoryEnabled(mPolicy, Policy.PRIORITY_CATEGORY_REPEAT_CALLERS)) {
            s = appendLowercase(s, true, R.string.zen_mode_repeat_callers);
        }
        mPrioritySettings.setSummary(s);
    }

    private void updateVisualSettingsSummary() {
        String s = getString(R.string.zen_mode_all_visual_interruptions);
        if (isEffectSuppressed(Policy.SUPPRESSED_EFFECT_SCREEN_ON)
                && isEffectSuppressed(Policy.SUPPRESSED_EFFECT_SCREEN_OFF)) {
            s = getString(R.string.zen_mode_no_visual_interruptions);
        } else if (isEffectSuppressed(Policy.SUPPRESSED_EFFECT_SCREEN_ON)) {
            s = getString(R.string.zen_mode_screen_on_visual_interruptions);
        } else if (isEffectSuppressed(Policy.SUPPRESSED_EFFECT_SCREEN_OFF)) {
            s = getString(R.string.zen_mode_screen_off_visual_interruptions);
        }
        mVisualSettings.setSummary(s);
    }

    private boolean isEffectSuppressed(int effect) {
        return (mPolicy.suppressedVisualEffects & effect) != 0;
    }

    private boolean isCategoryEnabled(Policy policy, int categoryType) {
        return (policy.priorityCategories & categoryType) != 0;
    }
+11 −27
Original line number Diff line number Diff line
@@ -37,12 +37,10 @@ import java.util.List;

public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase {

    private static final String KEY_PEEK = "peek";
    private static final String KEY_LIGHTS = "lights";
    private static final String KEY_SCREEN_ON = "screen_on";
    private static final String KEY_SCREEN_OFF = "screenOff";
    private static final String KEY_SCREEN_ON = "screenOn";

    private SwitchPreference mPeek;
    private SwitchPreference mLights;
    private SwitchPreference mScreenOff;
    private SwitchPreference mScreenOn;

    private boolean mDisableListeners;
@@ -56,28 +54,15 @@ public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase {

        mPolicy = NotificationManager.from(mContext).getNotificationPolicy();

        mPeek = (SwitchPreference) root.findPreference(KEY_PEEK);
        mPeek.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        mScreenOff = (SwitchPreference) root.findPreference(KEY_SCREEN_OFF);
        mScreenOff.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                if (mDisableListeners) return true;
                final boolean val = (Boolean) newValue;
                MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_PEEK, val);
                if (DEBUG) Log.d(TAG, "onPrefChange suppressPeek=" + val);
                savePolicy(getNewSuppressedEffects(val, Policy.SUPPRESSED_EFFECT_PEEK));
                return true;
            }
        });

        mLights = (SwitchPreference) root.findPreference(KEY_LIGHTS);
        mLights.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                if (mDisableListeners) return true;
                final boolean val = (Boolean) newValue;
                MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_LIGHTS, val);
                if (DEBUG) Log.d(TAG, "onPrefChange suppressLights=" + val);
                savePolicy(getNewSuppressedEffects(val, Policy.SUPPRESSED_EFFECT_LIGHTS));
                MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_WHEN_SCREEN_OFF, val);
                if (DEBUG) Log.d(TAG, "onPrefChange suppressWhenScreenOff=" + val);
                savePolicy(getNewSuppressedEffects(val, Policy.SUPPRESSED_EFFECT_SCREEN_OFF));
                return true;
            }
        });
@@ -88,8 +73,8 @@ public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase {
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                if (mDisableListeners) return true;
                final boolean val = (Boolean) newValue;
                MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_SCREEN_ON, val);
                if (DEBUG) Log.d(TAG, "onPrefChange suppressScreenOn=" + val);
                MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_WHEN_SCREEN_ON, val);
                if (DEBUG) Log.d(TAG, "onPrefChange suppressWhenScreenOn=" + val);
                savePolicy(getNewSuppressedEffects(val, Policy.SUPPRESSED_EFFECT_SCREEN_ON));
                return true;
            }
@@ -114,8 +99,7 @@ public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase {

    private void updateControls() {
        mDisableListeners = true;
        mPeek.setChecked(isEffectSuppressed(Policy.SUPPRESSED_EFFECT_PEEK));
        mLights.setChecked(isEffectSuppressed(Policy.SUPPRESSED_EFFECT_LIGHTS));
        mScreenOff.setChecked(isEffectSuppressed(Policy.SUPPRESSED_EFFECT_SCREEN_OFF));
        mScreenOn.setChecked(isEffectSuppressed(Policy.SUPPRESSED_EFFECT_SCREEN_ON));
        mDisableListeners = false;
    }