diff --git a/res/values/strings.xml b/res/values/strings.xml
index ec4d220888d..be9a09ce359 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6153,23 +6153,26 @@
Change to always interrupt
-
- No screen interruptions
+
+ Block when screen is on
-
- Prevent notifications silenced by Do Not Disturb from peeking or appearing on the current screen
+
+ Prevent notifications silenced by Do Not Disturb from peeking or popping on screen
-
- No notification light
+
+ Block when screen is off
-
- Prevent notifications silenced by Do Not Disturb from causing the light to pulse
+
+ Prevent notifications silenced by Do Not Disturb from turning on the screen or pulsing the notification light
-
- Never turn on the screen
-
-
- If the screen is off, prevent notifications silenced by Do Not Disturb from turning it on
+
+ Off
+
+ When screen is on
+
+ When screen is off
+
+ When screen is on or off
diff --git a/res/xml/zen_mode_visual_interruptions_settings.xml b/res/xml/zen_mode_visual_interruptions_settings.xml
index 42a043b9aea..012dd954a9f 100644
--- a/res/xml/zen_mode_visual_interruptions_settings.xml
+++ b/res/xml/zen_mode_visual_interruptions_settings.xml
@@ -18,16 +18,14 @@
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/zen_mode_visual_interruptions_settings_title" >
-
-
-
-
-
+
+
+
+
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index b875afa44fa..297029e3a7e 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -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;
}
diff --git a/src/com/android/settings/notification/ZenModeVisualInterruptionSettings.java b/src/com/android/settings/notification/ZenModeVisualInterruptionSettings.java
index 3bc0759a027..a951a6911aa 100644
--- a/src/com/android/settings/notification/ZenModeVisualInterruptionSettings.java
+++ b/src/com/android/settings/notification/ZenModeVisualInterruptionSettings.java
@@ -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;
}