Merge changes from topic "dnd_touch_sounds" into pi-dev

am: e9fbcd7114

Change-Id: Ie536a0126a05b379d06caceb54681f4757077c7b
This commit is contained in:
Beverly
2018-03-13 20:34:41 +00:00
committed by android-build-merger
3 changed files with 31 additions and 41 deletions

View File

@@ -6999,6 +6999,11 @@
<!-- Do not disturb: what to block summary, all effects --> <!-- Do not disturb: what to block summary, all effects -->
<string name="zen_mode_block_effect_summary_all">Sound, vibration, and visual signs of notifications</string> <string name="zen_mode_block_effect_summary_all">Sound, vibration, and visual signs of notifications</string>
<!-- Do not disturb: Zen mode no sounds are exceptions to bypass do not disturb-->
<string name="zen_mode_no_exceptions">None</string>
<!-- Do not disturb: Zen mode catch all "other" sounds can bypass do not disturb -->
<string name="zen_mode_other_options">other options</string>
<!-- Do not disturb: Button to add new automatic rule to DND. [CHAR LIMIT=30] --> <!-- Do not disturb: Button to add new automatic rule to DND. [CHAR LIMIT=30] -->
<string name="zen_mode_add">Add</string> <string name="zen_mode_add">Add</string>
@@ -7592,8 +7597,8 @@
<!-- [CHAR LIMIT=50] Zen mode settings: Media option --> <!-- [CHAR LIMIT=50] Zen mode settings: Media option -->
<string name="zen_mode_media">Media</string> <string name="zen_mode_media">Media</string>
<!-- [CHAR LIMIT=50] Zen mode settings: System option which includes sounds such as touch and charging sounds --> <!-- [CHAR LIMIT=50] Zen mode settings: System option which includes sounds such as touch sounds -->
<string name="zen_mode_system">Touch and charging sounds</string> <string name="zen_mode_system">Touch sounds</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Reminders option --> <!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
<string name="zen_mode_reminders">Reminders</string> <string name="zen_mode_reminders">Reminders</string>

View File

@@ -94,31 +94,29 @@ public class ZenModeSettings extends ZenModeSettingsBase {
}; };
String getBehaviorSettingSummary(Policy policy, int zenMode) { String getBehaviorSettingSummary(Policy policy, int zenMode) {
List<String> enabledCategories; List<String> enabledCategories = getEnabledCategories(policy);
if (zenMode == Settings.Global.ZEN_MODE_NO_INTERRUPTIONS) {
return mContext.getString(R.string.zen_mode_behavior_total_silence);
} else if (zenMode == Settings.Global.ZEN_MODE_ALARMS) {
return mContext.getString(R.string.zen_mode_behavior_alarms_only);
} else {
enabledCategories = getEnabledCategories(policy);
}
// no sound categories can bypass dnd
int numCategories = enabledCategories.size(); int numCategories = enabledCategories.size();
if (numCategories == 0) { if (numCategories == 0) {
return mContext.getString(R.string.zen_mode_behavior_total_silence); return mContext.getString(R.string.zen_mode_no_exceptions);
} else if (numCategories == 1) {
return enabledCategories.get(0);
} else if (numCategories == 2) {
return mContext.getString(R.string.join_two_items, enabledCategories.get(0),
enabledCategories.get(1).toLowerCase());
} else if (numCategories == 3){
String secondaryText = mContext.getString(R.string.join_two_unrelated_items,
enabledCategories.get(0), enabledCategories.get(1).toLowerCase());
return mContext.getString(R.string.join_two_items, secondaryText,
enabledCategories.get(2).toLowerCase());
} else {
String secondaryText = mContext.getString(R.string.join_many_items_middle,
enabledCategories.get(0), enabledCategories.get(1).toLowerCase());
secondaryText = mContext.getString(R.string.join_many_items_middle, secondaryText,
enabledCategories.get(2).toLowerCase());
return mContext.getString(R.string.join_many_items_last, secondaryText,
mContext.getString(R.string.zen_mode_other_options));
} }
// only alarms and media can bypass dnd
if (numCategories == 2 &&
isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_ALARMS) &&
isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_MEDIA)) {
return mContext.getString(R.string.zen_mode_behavior_alarms_only);
}
// custom
return mContext.getString(R.string.zen_mode_behavior_summary_custom);
} }
String getSoundSummary() { String getSoundSummary() {

View File

@@ -47,27 +47,12 @@ public class ZenModeSettingsTest {
} }
@Test @Test
public void testGetBehaviorSettingSummary_customBehavior() { public void testGetBehaviorSettingSummary_noSoundsCanBypass() {
NotificationManager.Policy policy = new NotificationManager.Policy(
NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS
| NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS
| NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS
| NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA,
0, 0);
final String result = mBuilder.getBehaviorSettingSummary(policy,
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
String custom = mContext.getString(R.string.zen_mode_behavior_summary_custom);
assertEquals(custom, result);
}
@Test
public void testGetBehaviorSettingSummary_totalSilence() {
NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0); NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0);
final String result = mBuilder.getBehaviorSettingSummary(policy, final String result = mBuilder.getBehaviorSettingSummary(policy,
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS); Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
String totalSilence = mContext.getString(R.string.zen_mode_behavior_total_silence); String totalSilence = mContext.getString(R.string.zen_mode_no_exceptions);
assertEquals(totalSilence, result); assertEquals(totalSilence, result);
} }
@@ -80,7 +65,9 @@ public class ZenModeSettingsTest {
final String result = mBuilder.getBehaviorSettingSummary(policy, final String result = mBuilder.getBehaviorSettingSummary(policy,
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS); Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
String alarmsAndMedia = mContext.getString(R.string.zen_mode_behavior_alarms_only); String alarmsAndMedia = mContext.getString(R.string.join_two_items,
mContext.getString(R.string.zen_mode_alarms),
mContext.getString(R.string.zen_mode_media).toLowerCase());
assertEquals(alarmsAndMedia, result); assertEquals(alarmsAndMedia, result);
} }