Update DND visual interruption choices.
Change-Id: I9313052d60a9fbd88546c1478ac9b830ae6fc40c
This commit is contained in:
@@ -6153,23 +6153,26 @@
|
|||||||
<!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: Turn on all notifications. -->
|
<!-- [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>
|
<string name="zen_mode_summary_always">Change to always interrupt</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=40] Zen mode settings: No screen interruptions option -->
|
<!-- [CHAR LIMIT=40] Zen mode settings: visual interruptions: screen is on: title -->
|
||||||
<string name="zen_mode_peek">No screen interruptions</string>
|
<string name="zen_mode_screen_on">Block when screen is on</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=130] Zen mode settings: No screen interruptions summary -->
|
<!-- [CHAR LIMIT=130] Zen mode settings: visual interruptions: screen is on: summary -->
|
||||||
<string name="zen_mode_peek_summary">Prevent notifications silenced by Do Not Disturb from peeking or appearing on the current screen</string>
|
<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: No notification light option -->
|
<!-- [CHAR LIMIT=40] Zen mode settings: visual interruptions: screen is off: title -->
|
||||||
<string name="zen_mode_lights">No notification light</string>
|
<string name="zen_mode_screen_off">Block when screen is off</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=105] Zen mode settings: No notification light summary -->
|
<!-- [CHAR LIMIT=130] Zen mode settings: visual interruptions: screen is off: summary -->
|
||||||
<string name="zen_mode_lights_summary">Prevent notifications silenced by Do Not Disturb from causing the light to pulse</string>
|
<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=40] Zen mode settings: Don't turn the screen on option -->
|
<!-- [CHAR LIMIT=130] Zen mode settings: visual interruptions summary -->
|
||||||
<string name="zen_mode_screen_on">Never turn on the screen</string>
|
<string name="zen_mode_all_visual_interruptions">Off</string>
|
||||||
|
<!-- [CHAR LIMIT=130] Zen mode settings: visual interruptions summary -->
|
||||||
<!-- [CHAR LIMIT=130] Zen mode settings: Don't turn the screen on summary -->
|
<string name="zen_mode_screen_on_visual_interruptions">When screen is on</string>
|
||||||
<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=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
|
<!-- [CHAR LIMIT=NONE] Content description for per-app notification
|
||||||
settings button -->
|
settings button -->
|
||||||
|
@@ -18,16 +18,14 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||||
android:title="@string/zen_mode_visual_interruptions_settings_title" >
|
android:title="@string/zen_mode_visual_interruptions_settings_title" >
|
||||||
|
|
||||||
<SwitchPreference android:key="peek"
|
<SwitchPreference android:key="screenOn"
|
||||||
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"
|
|
||||||
android:title="@string/zen_mode_screen_on"
|
android:title="@string/zen_mode_screen_on"
|
||||||
android:summary="@string/zen_mode_screen_on_summary" />
|
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>
|
</PreferenceScreen>
|
||||||
|
@@ -31,8 +31,11 @@ import com.android.settings.SettingsActivity;
|
|||||||
|
|
||||||
public class ZenModeSettings extends ZenModeSettingsBase {
|
public class ZenModeSettings extends ZenModeSettingsBase {
|
||||||
private static final String KEY_PRIORITY_SETTINGS = "priority_settings";
|
private static final String KEY_PRIORITY_SETTINGS = "priority_settings";
|
||||||
|
private static final String KEY_VISUAL_SETTINGS = "visual_interruptions_settings";
|
||||||
|
|
||||||
private Preference mPrioritySettings;
|
private Preference mPrioritySettings;
|
||||||
|
private Preference mVisualSettings;
|
||||||
|
private Policy mPolicy;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -42,6 +45,8 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
|||||||
final PreferenceScreen root = getPreferenceScreen();
|
final PreferenceScreen root = getPreferenceScreen();
|
||||||
|
|
||||||
mPrioritySettings = root.findPreference(KEY_PRIORITY_SETTINGS);
|
mPrioritySettings = root.findPreference(KEY_PRIORITY_SETTINGS);
|
||||||
|
mVisualSettings = root.findPreference(KEY_VISUAL_SETTINGS);
|
||||||
|
mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -50,7 +55,6 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
|||||||
if (isUiRestricted()) {
|
if (isUiRestricted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateControls();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,11 +69,13 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onZenModeConfigChanged() {
|
protected void onZenModeConfigChanged() {
|
||||||
|
mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
|
||||||
updateControls();
|
updateControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateControls() {
|
private void updateControls() {
|
||||||
updatePrioritySettingsSummary();
|
updatePrioritySettingsSummary();
|
||||||
|
updateVisualSettingsSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -90,31 +96,47 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePrioritySettingsSummary() {
|
private void updatePrioritySettingsSummary() {
|
||||||
Policy policy = NotificationManager.from(mContext).getNotificationPolicy();
|
|
||||||
String s = getResources().getString(R.string.zen_mode_alarms);
|
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);
|
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);
|
R.string.zen_mode_events);
|
||||||
if (isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_MESSAGES)) {
|
if (isCategoryEnabled(mPolicy, Policy.PRIORITY_CATEGORY_MESSAGES)) {
|
||||||
if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
|
if (mPolicy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
|
||||||
s = appendLowercase(s, true, R.string.zen_mode_all_messages);
|
s = appendLowercase(s, true, R.string.zen_mode_all_messages);
|
||||||
} else {
|
} else {
|
||||||
s = appendLowercase(s, true, R.string.zen_mode_selected_messages);
|
s = appendLowercase(s, true, R.string.zen_mode_selected_messages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_CALLS)) {
|
if (isCategoryEnabled(mPolicy, Policy.PRIORITY_CATEGORY_CALLS)) {
|
||||||
if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
|
if (mPolicy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
|
||||||
s = appendLowercase(s, true, R.string.zen_mode_all_callers);
|
s = appendLowercase(s, true, R.string.zen_mode_all_callers);
|
||||||
} else {
|
} else {
|
||||||
s = appendLowercase(s, true, R.string.zen_mode_selected_callers);
|
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);
|
s = appendLowercase(s, true, R.string.zen_mode_repeat_callers);
|
||||||
}
|
}
|
||||||
mPrioritySettings.setSummary(s);
|
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) {
|
private boolean isCategoryEnabled(Policy policy, int categoryType) {
|
||||||
return (policy.priorityCategories & categoryType) != 0;
|
return (policy.priorityCategories & categoryType) != 0;
|
||||||
}
|
}
|
||||||
|
@@ -37,12 +37,10 @@ import java.util.List;
|
|||||||
|
|
||||||
public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase {
|
public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase {
|
||||||
|
|
||||||
private static final String KEY_PEEK = "peek";
|
private static final String KEY_SCREEN_OFF = "screenOff";
|
||||||
private static final String KEY_LIGHTS = "lights";
|
private static final String KEY_SCREEN_ON = "screenOn";
|
||||||
private static final String KEY_SCREEN_ON = "screen_on";
|
|
||||||
|
|
||||||
private SwitchPreference mPeek;
|
private SwitchPreference mScreenOff;
|
||||||
private SwitchPreference mLights;
|
|
||||||
private SwitchPreference mScreenOn;
|
private SwitchPreference mScreenOn;
|
||||||
|
|
||||||
private boolean mDisableListeners;
|
private boolean mDisableListeners;
|
||||||
@@ -56,28 +54,15 @@ public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase {
|
|||||||
|
|
||||||
mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
|
mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
|
||||||
|
|
||||||
mPeek = (SwitchPreference) root.findPreference(KEY_PEEK);
|
mScreenOff = (SwitchPreference) root.findPreference(KEY_SCREEN_OFF);
|
||||||
mPeek.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
mScreenOff.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
if (mDisableListeners) return true;
|
if (mDisableListeners) return true;
|
||||||
final boolean val = (Boolean) newValue;
|
final boolean val = (Boolean) newValue;
|
||||||
MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_PEEK, val);
|
MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_WHEN_SCREEN_OFF, val);
|
||||||
if (DEBUG) Log.d(TAG, "onPrefChange suppressPeek=" + val);
|
if (DEBUG) Log.d(TAG, "onPrefChange suppressWhenScreenOff=" + val);
|
||||||
savePolicy(getNewSuppressedEffects(val, Policy.SUPPRESSED_EFFECT_PEEK));
|
savePolicy(getNewSuppressedEffects(val, Policy.SUPPRESSED_EFFECT_SCREEN_OFF));
|
||||||
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));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -88,8 +73,8 @@ public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase {
|
|||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
if (mDisableListeners) return true;
|
if (mDisableListeners) return true;
|
||||||
final boolean val = (Boolean) newValue;
|
final boolean val = (Boolean) newValue;
|
||||||
MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_SCREEN_ON, val);
|
MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_WHEN_SCREEN_ON, val);
|
||||||
if (DEBUG) Log.d(TAG, "onPrefChange suppressScreenOn=" + val);
|
if (DEBUG) Log.d(TAG, "onPrefChange suppressWhenScreenOn=" + val);
|
||||||
savePolicy(getNewSuppressedEffects(val, Policy.SUPPRESSED_EFFECT_SCREEN_ON));
|
savePolicy(getNewSuppressedEffects(val, Policy.SUPPRESSED_EFFECT_SCREEN_ON));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -114,8 +99,7 @@ public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase {
|
|||||||
|
|
||||||
private void updateControls() {
|
private void updateControls() {
|
||||||
mDisableListeners = true;
|
mDisableListeners = true;
|
||||||
mPeek.setChecked(isEffectSuppressed(Policy.SUPPRESSED_EFFECT_PEEK));
|
mScreenOff.setChecked(isEffectSuppressed(Policy.SUPPRESSED_EFFECT_SCREEN_OFF));
|
||||||
mLights.setChecked(isEffectSuppressed(Policy.SUPPRESSED_EFFECT_LIGHTS));
|
|
||||||
mScreenOn.setChecked(isEffectSuppressed(Policy.SUPPRESSED_EFFECT_SCREEN_ON));
|
mScreenOn.setChecked(isEffectSuppressed(Policy.SUPPRESSED_EFFECT_SCREEN_ON));
|
||||||
mDisableListeners = false;
|
mDisableListeners = false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user