Merge "Fix typo"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 65d6d0a..1c85566 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7975,9 +7975,15 @@
<!-- [CHAR LIMIT=50] Zen mode settings: All messages summary -->
<string name="zen_mode_all_messages">Messages</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: Messages option (ie: text messages) -->
+ <string name="zen_mode_all_messages_list">messages</string>
+
<!-- [CHAR LIMIT=50] Zen mode settings: Selected messages summary -->
<string name="zen_mode_selected_messages">Some messages</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: Selected messages (ie: some text messages are allowed to bypass dnd) -->
+ <string name="zen_mode_selected_messages_list">some messages</string>
+
<!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From anyone -->
<string name="zen_mode_from_anyone">From anyone</string>
@@ -8002,21 +8008,36 @@
<!-- [CHAR LIMIT=50] Zen mode settings: Alarms option -->
<string name="zen_mode_alarms">Alarms</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: Alarms option (ie: sound from alarm clock) -->
+ <string name="zen_mode_alarms_list">alarms</string>
+
<!-- [CHAR LIMIT=50] Zen mode settings: Media option -->
<string name="zen_mode_media">Media</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: Media (ie: sound from video) -->
+ <string name="zen_mode_media_list">media</string>
+
<!-- [CHAR LIMIT=50] Zen mode settings: System option which includes sounds such as touch sounds -->
<string name="zen_mode_system">Touch sounds</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: System sounds (ie: touch sounds) -->
+ <string name="zen_mode_system_list">touch sounds</string>
+
<!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
<string name="zen_mode_reminders">Reminders</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: Reminders (ie: calendar reminders are allowed to bypass dnd) -->
+ <string name="zen_mode_reminders_list">reminders</string>
+
<!-- [CHAR LIMIT=70] Zen mode settings: Allow reminders toggle title -->
<string name="zen_mode_reminders_title">Allow reminders</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Events option -->
<string name="zen_mode_events">Events</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: Events (ie: calendar events) -->
+ <string name="zen_mode_events_list">events</string>
+
<!-- [CHAR LIMIT=70] Zen mode settings: Allow events toggle title -->
<string name="zen_mode_events_title">Allow events</string>
@@ -8032,6 +8053,9 @@
<!-- [CHAR LIMIT=50] Zen mode settings: Repeat callers option -->
<string name="zen_mode_repeat_callers">Repeat callers</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: Repeat callers (ie: repeat callers are allowed to bypass dnd) -->
+ <string name="zen_mode_repeat_callers_list">repeat callers</string>
+
<!-- [CHAR LIMIT=70] Zen mode settings: Allow repeat callers toggle title -->
<string name="zen_mode_repeat_callers_title">Allow repeat callers</string>
diff --git a/src/com/android/settings/notification/NotificationPreferenceController.java b/src/com/android/settings/notification/NotificationPreferenceController.java
index 49bb08e..1ce42c2 100644
--- a/src/com/android/settings/notification/NotificationPreferenceController.java
+++ b/src/com/android/settings/notification/NotificationPreferenceController.java
@@ -138,11 +138,11 @@
protected boolean isChannelBlockable() {
if (mChannel != null && mAppRow != null) {
- if (!mAppRow.systemApp) {
- return true;
+ if (!isChannelConfigurable()) {
+ return mChannel.getImportance() == IMPORTANCE_NONE;
}
- return mChannel.isBlockableSystem()
+ return mChannel.isBlockableSystem() || !mAppRow.systemApp
|| mChannel.getImportance() == IMPORTANCE_NONE;
}
return false;
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index 240ab68..e05dabe 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -119,22 +119,22 @@
List<String> enabledCategories = getEnabledCategories(policy,
category -> PRIORITY_CATEGORY_ALARMS == category
|| PRIORITY_CATEGORY_MEDIA == category
- || PRIORITY_CATEGORY_SYSTEM == category);
+ || PRIORITY_CATEGORY_SYSTEM == category, false);
int numCategories = enabledCategories.size();
if (numCategories == 0) {
return mContext.getString(R.string.zen_sound_all_muted);
} else if (numCategories == 1) {
return mContext.getString(R.string.zen_sound_one_allowed,
- enabledCategories.get(0).toLowerCase());
+ enabledCategories.get(0));
} else if (numCategories == 2) {
return mContext.getString(R.string.zen_sound_two_allowed,
- enabledCategories.get(0).toLowerCase(),
- enabledCategories.get(1).toLowerCase());
+ enabledCategories.get(0),
+ enabledCategories.get(1));
} else if (numCategories == 3) {
return mContext.getString(R.string.zen_sound_three_allowed,
- enabledCategories.get(0).toLowerCase(),
- enabledCategories.get(1).toLowerCase(),
- enabledCategories.get(2).toLowerCase());
+ enabledCategories.get(0),
+ enabledCategories.get(1),
+ enabledCategories.get(2));
} else {
return mContext.getString(R.string.zen_sound_none_muted);
}
@@ -143,17 +143,17 @@
String getCallsSettingSummary(Policy policy) {
List<String> enabledCategories = getEnabledCategories(policy,
category -> PRIORITY_CATEGORY_CALLS == category
- || PRIORITY_CATEGORY_REPEAT_CALLERS == category);
+ || PRIORITY_CATEGORY_REPEAT_CALLERS == category, false);
int numCategories = enabledCategories.size();
if (numCategories == 0) {
return mContext.getString(R.string.zen_mode_no_exceptions);
} else if (numCategories == 1) {
return mContext.getString(R.string.zen_mode_calls_summary_one,
- enabledCategories.get(0).toLowerCase());
+ enabledCategories.get(0));
} else {
return mContext.getString(R.string.zen_mode_calls_summary_two,
- enabledCategories.get(0).toLowerCase(),
- enabledCategories.get(1).toLowerCase());
+ enabledCategories.get(0),
+ enabledCategories.get(1));
}
}
@@ -161,7 +161,7 @@
List<String> enabledCategories = getEnabledCategories(policy,
category -> PRIORITY_CATEGORY_EVENTS == category
|| PRIORITY_CATEGORY_REMINDERS == category
- || PRIORITY_CATEGORY_MESSAGES == category);
+ || PRIORITY_CATEGORY_MESSAGES == category, true);
int numCategories = enabledCategories.size();
if (numCategories == 0) {
return mContext.getString(R.string.zen_mode_no_exceptions);
@@ -169,19 +169,19 @@
return enabledCategories.get(0);
} else if (numCategories == 2) {
return mContext.getString(R.string.join_two_items, enabledCategories.get(0),
- enabledCategories.get(1).toLowerCase());
+ enabledCategories.get(1));
} else if (numCategories == 3){
final List<String> summaries = new ArrayList<>();
summaries.add(enabledCategories.get(0));
- summaries.add(enabledCategories.get(1).toLowerCase());
- summaries.add(enabledCategories.get(2).toLowerCase());
+ summaries.add(enabledCategories.get(1));
+ summaries.add(enabledCategories.get(2));
return ListFormatter.getInstance().format(summaries);
} else {
final List<String> summaries = new ArrayList<>();
summaries.add(enabledCategories.get(0));
- summaries.add(enabledCategories.get(1).toLowerCase());
- summaries.add(enabledCategories.get(2).toLowerCase());
+ summaries.add(enabledCategories.get(1));
+ summaries.add(enabledCategories.get(2));
summaries.add(mContext.getString(R.string.zen_mode_other_options));
return ListFormatter.getInstance().format(summaries);
@@ -251,48 +251,18 @@
}
private List<String> getEnabledCategories(Policy policy,
- Predicate<Integer> filteredCategories) {
+ Predicate<Integer> filteredCategories, boolean capitalizeFirstInList) {
List<String> enabledCategories = new ArrayList<>();
for (int category : ALL_PRIORITY_CATEGORIES) {
+ boolean isFirst = capitalizeFirstInList && enabledCategories.isEmpty();
if (filteredCategories.test(category) && isCategoryEnabled(policy, category)) {
- if (category == PRIORITY_CATEGORY_ALARMS) {
- enabledCategories.add(mContext.getString(R.string.zen_mode_alarms));
- } else if (category == PRIORITY_CATEGORY_MEDIA) {
- enabledCategories.add(mContext.getString(
- R.string.zen_mode_media));
- } else if (category == PRIORITY_CATEGORY_SYSTEM) {
- enabledCategories.add(mContext.getString(
- R.string.zen_mode_system));
- } else if (category == Policy.PRIORITY_CATEGORY_MESSAGES) {
- if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
- enabledCategories.add(mContext.getString(
- R.string.zen_mode_all_messages));
- } else {
- enabledCategories.add(mContext.getString(
- R.string.zen_mode_selected_messages));
- }
- } else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
- enabledCategories.add(mContext.getString(R.string.zen_mode_events));
- } else if (category == Policy.PRIORITY_CATEGORY_REMINDERS) {
- enabledCategories.add(mContext.getString(R.string.zen_mode_reminders));
- } else if (category == Policy.PRIORITY_CATEGORY_CALLS) {
- if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
- enabledCategories.add(mContext.getString(
- R.string.zen_mode_all_callers));
- } else if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_CONTACTS){
- enabledCategories.add(mContext.getString(
- R.string.zen_mode_contacts_callers));
- } else {
- enabledCategories.add(mContext.getString(
- R.string.zen_mode_starred_callers));
- }
- } else if (category == Policy.PRIORITY_CATEGORY_REPEAT_CALLERS) {
- if (!enabledCategories.contains(mContext.getString(
- R.string.zen_mode_all_callers))) {
- enabledCategories.add(mContext.getString(
- R.string.zen_mode_repeat_callers));
- }
+ if (category == Policy.PRIORITY_CATEGORY_REPEAT_CALLERS
+ && isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_CALLS)
+ && policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
+ continue;
}
+
+ enabledCategories.add(getCategory(category, policy, isFirst));
}
}
return enabledCategories;
@@ -301,6 +271,70 @@
private boolean isCategoryEnabled(Policy policy, int categoryType) {
return (policy.priorityCategories & categoryType) != 0;
}
+
+ private String getCategory(int category, Policy policy, boolean isFirst) {
+ if (category == PRIORITY_CATEGORY_ALARMS) {
+ if (isFirst) {
+ return mContext.getString(R.string.zen_mode_alarms);
+ } else {
+ return mContext.getString(R.string.zen_mode_alarms_list);
+ }
+ } else if (category == PRIORITY_CATEGORY_MEDIA) {
+ if (isFirst) {
+ return mContext.getString(R.string.zen_mode_media);
+ } else {
+ return mContext.getString(R.string.zen_mode_media_list);
+ }
+ } else if (category == PRIORITY_CATEGORY_SYSTEM) {
+ if (isFirst) {
+ return mContext.getString(R.string.zen_mode_system);
+ } else {
+ return mContext.getString(R.string.zen_mode_system_list);
+ }
+ } else if (category == Policy.PRIORITY_CATEGORY_MESSAGES) {
+ if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
+ if (isFirst) {
+ return mContext.getString(R.string.zen_mode_all_messages);
+ } else {
+ return mContext.getString(R.string.zen_mode_all_messages_list);
+ }
+ } else {
+ if (isFirst) {
+ return mContext.getString(R.string.zen_mode_selected_messages);
+ } else {
+ return mContext.getString(R.string.zen_mode_selected_messages_list);
+ }
+ }
+ } else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
+ if (isFirst) {
+ return mContext.getString(R.string.zen_mode_events);
+ } else {
+ return mContext.getString(R.string.zen_mode_events_list);
+ }
+ } else if (category == Policy.PRIORITY_CATEGORY_REMINDERS) {
+ if (isFirst) {
+ return mContext.getString(R.string.zen_mode_reminders);
+ } else {
+ return mContext.getString(R.string.zen_mode_reminders_list);
+ }
+ } else if (category == Policy.PRIORITY_CATEGORY_CALLS) {
+ if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
+ return mContext.getString(R.string.zen_mode_all_callers);
+ } else if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_CONTACTS){
+ return mContext.getString(R.string.zen_mode_contacts_callers);
+ } else {
+ return mContext.getString(R.string.zen_mode_starred_callers);
+ }
+ } else if (category == Policy.PRIORITY_CATEGORY_REPEAT_CALLERS) {
+ if (isFirst) {
+ return mContext.getString(R.string.zen_mode_repeat_callers);
+ } else {
+ return mContext.getString(R.string.zen_mode_repeat_callers_list);
+ }
+ }
+
+ return "";
+ }
}
/**
diff --git a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
index a13946e..bdc7d69 100644
--- a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
@@ -138,6 +138,7 @@
public void testIsAvailable_nonSystemApp() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = false;
+ appRow.lockedChannelId = "not this";
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
mController.onResume(appRow, channel, null, null);
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
index 7eeee98..38790b3 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
@@ -262,6 +262,34 @@
}
@Test
+ public void testIsChannelBlockable_notConfigurable() {
+ String sameId = "apples";
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.systemApp = false;
+ appRow.lockedChannelId = sameId;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getId()).thenReturn(sameId);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
+
+ mController.onResume(appRow, channel, null, null);
+ assertFalse(mController.isChannelBlockable());
+ }
+
+ @Test
+ public void testIsChannelBlockable_notConfigurableButBlocked() {
+ String sameId = "apples";
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.systemApp = false;
+ appRow.lockedChannelId = sameId;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getId()).thenReturn(sameId);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
+
+ mController.onResume(appRow, channel, null, null);
+ assertTrue(mController.isChannelBlockable());
+ }
+
+ @Test
public void testIsChannelGroupBlockable_nonSystemBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = false;