Merge "Zen priority settings update" into oc-dr1-dev

am: 9dec71f7d7

Change-Id: I81e2609637537413bfd36ed9e0658d49d533a9cd
This commit is contained in:
Julia Reynolds
2017-07-20 14:23:51 +00:00
committed by android-build-merger
4 changed files with 58 additions and 10 deletions

View File

@@ -356,10 +356,10 @@ public class ZenModeSettings extends ZenModeSettingsBase {
String getPrioritySettingSummary(Policy policy) {
String s = mContext.getString(R.string.zen_mode_alarms);
s = append(s, isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_REMINDERS),
s = prepend(s, isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_EVENTS),
R.string.zen_mode_events);
s = prepend(s, isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_REMINDERS),
R.string.zen_mode_reminders);
s = append(s, isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_EVENTS),
R.string.zen_mode_events);
if (isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_MESSAGES)) {
if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
s = append(s, true, R.string.zen_mode_all_messages);
@@ -424,6 +424,15 @@ public class ZenModeSettings extends ZenModeSettingsBase {
return s;
}
@VisibleForTesting
String prepend(String s, boolean condition, int resId) {
if (condition) {
return mContext.getString(
R.string.join_many_items_middle, mContext.getString(resId), s);
}
return s;
}
private boolean isCategoryEnabled(Policy policy, int categoryType) {
return (policy.priorityCategories & categoryType) != 0;
}