Merge "Simplify DND Behavior secondary text"

This commit is contained in:
TreeHugger Robot
2017-12-13 22:59:43 +00:00
committed by Android (Google) Code Review
4 changed files with 49 additions and 30 deletions

View File

@@ -6728,14 +6728,14 @@
<!-- Do not disturb: Subtitle for DND behavior indicating no sound will get past DND. [CHAR LIMIT=30] -->
<string name="zen_mode_behavior_no_sound">No sound</string>
<!-- Do not disturb: Subtitle for DND behavior indicating no sound will get past DND due to user and/or API-invoked Total Silence mode. [CHAR LIMIT=40] -->
<string name="zen_mode_behavior_total_silence">No sound (Total Silence)</string>
<!-- Do not disturb: Subtitle for DND behavior indicating no sound will get past DND. [CHAR LIMIT=40] -->
<string name="zen_mode_behavior_total_silence">Total Silence</string>
<!-- Do not disturb: Used before specifying which sounds can bypass DND (ie: No sound except alarms and reminders). [CHAR LIMIT=40] -->
<string name="zen_mode_behavior_no_sound_except">No sound except <xliff:g id="categories" example="alarms, media and system feedback">%1$s</xliff:g></string>
<!-- Do not disturb: Specifies sounds that can bypass DND in user and/or API-invoked Alarms Only mode. [CHAR LIMIT=100] -->
<string name="zen_mode_behavior_alarms_only">No sound except alarms, media and system feedback (Alarms only)</string>
<!-- Do not disturb: Specifies alarms and media can bypass DND. [CHAR LIMIT=100] -->
<string name="zen_mode_behavior_alarms_only">No sound except alarms and media</string>
<!-- Do not disturb: Title for the zen mode automation option in Settings. [CHAR LIMIT=40] -->
<string name="zen_mode_automation_settings_title">Turn on automatically</string>
@@ -7315,8 +7315,11 @@
<!-- [CHAR LIMIT=50] Zen mode settings: Alarms option -->
<string name="zen_mode_alarms">Alarms</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Media and system sounds option -->
<string name="zen_mode_media_system_other">Media and system feedback</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Media option -->
<string name="zen_mode_media_system_other">Media</string>
<!-- [CHAR LIMIT=50] 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</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
<string name="zen_mode_reminders">Reminders</string>
@@ -7336,6 +7339,9 @@
<!-- [CHAR LIMIT=200] Zen mode settings: Repeat callers option summary -->
<string name="zen_mode_repeat_callers_summary">If the same person calls a second time within a <xliff:g id="minutes">%d</xliff:g> minute period</string>
<!-- [CHAR LIMIT=50] Zen mode settings dnd beahvior description: when a user has chosen custom sounds to bypass DND -->
<string name="zen_mode_behavior_summary_custom">Custom</string>
<!-- [CHAR LIMIT=20] Zen mode settings: When option -->
<string name="zen_mode_when">Automatically turn on</string>

View File

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

View File

@@ -97,23 +97,21 @@ public class ZenModeSettings extends ZenModeSettingsBase {
enabledCategories = getEnabledCategories(policy);
}
// no sound categories can bypass dnd
int numCategories = enabledCategories.size();
if (numCategories == 0) {
return mContext.getString(R.string.zen_mode_behavior_no_sound);
return mContext.getString(R.string.zen_mode_behavior_total_silence);
}
String s = enabledCategories.get(0).toLowerCase();
for (int i = 1; i < numCategories; i++) {
if (i == numCategories - 1) {
s = mContext.getString(R.string.join_many_items_last,
s, enabledCategories.get(i).toLowerCase());
} else {
s = mContext.getString(R.string.join_many_items_middle,
s, enabledCategories.get(i).toLowerCase());
}
// only alarms and media/system can bypass dnd
if (numCategories == 2 &&
isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_ALARMS) &&
isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER)) {
return mContext.getString(R.string.zen_mode_behavior_alarms_only);
}
return mContext.getString(R.string.zen_mode_behavior_no_sound_except, s);
// custom
return mContext.getString(R.string.zen_mode_behavior_summary_custom);
}
String getAutomaticRulesSummary() {

View File

@@ -18,6 +18,7 @@ package com.android.settings.notification;
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
import android.app.NotificationManager;
@@ -53,7 +54,7 @@ public class ZenModeSettingsTest {
}
@Test
public void testGetBehaviorSettingSummary_sameOrderAsTargetPage() {
public void testGetBehaviorSettingSummary_customBehavior() {
NotificationManager.Policy policy = new NotificationManager.Policy(
NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS
| NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS
@@ -63,18 +64,31 @@ public class ZenModeSettingsTest {
final String result = mBuilder.getBehaviorSettingSummary(policy,
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
String alarms = mContext.getString(R.string.zen_mode_alarms).toLowerCase();
String reminders = mContext.getString(R.string.zen_mode_reminders).toLowerCase();
String events = mContext.getString(R.string.zen_mode_events).toLowerCase();
String media = mContext.getString(R.string.zen_mode_media_system_other).toLowerCase();
String custom = mContext.getString(R.string.zen_mode_behavior_summary_custom);
assertEquals(custom, result);
}
assertThat(result).contains(alarms);
assertThat(result).contains(reminders);
assertThat(result).contains(events);
assertThat(result).contains(media);
assertTrue(result.indexOf(alarms) < result.indexOf(media)
&& result.indexOf(media) < result.indexOf(reminders)
&& result.indexOf(reminders) < result.indexOf(events));
@Test
public void testGetBehaviorSettingSummary_totalSilence() {
NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0);
final String result = mBuilder.getBehaviorSettingSummary(policy,
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
String totalSilence = mContext.getString(R.string.zen_mode_behavior_total_silence);
assertEquals(totalSilence, result);
}
@Test
public void testGetBehaviorSettingSummary_alarmsAndMedia() {
NotificationManager.Policy policy = new NotificationManager.Policy(
NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS
| NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER,
0, 0);
final String result = mBuilder.getBehaviorSettingSummary(policy,
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
String alarmsAndMedia = mContext.getString(R.string.zen_mode_behavior_alarms_only);
assertEquals(alarmsAndMedia, result);
}
@Test