diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 44555db8b0a..746ada73d85 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -754,17 +754,17 @@
android:value="true" />
-
-
+
+ android:value="com.android.settings.notification.ZenModeBehaviorSettings" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8f6cc9c40dc..7c2eb55a50f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6693,10 +6693,25 @@
- Do Not Disturb preferences
+ Do Not Disturb
-
- Priority only allows
+
+ Behavior
+
+
+ Allow sounds and vibrations from
+
+
+ No sound
+
+
+ No sound (Total Silence)
+
+
+ No sound except %1$s
+
+
+ No sound except alarms, media and system (Alarms only)
Automatic rules
@@ -7231,8 +7246,8 @@
Alarms
-
- Alarms are always a priority and make sound
+
+ Media and system sounds
Reminders
@@ -7250,7 +7265,7 @@
Repeat callers
- If the same person calls a second time within a %d minute period, allow it
+ If the same person calls a second time within a %d minute period
Automatically turn on
diff --git a/res/xml/zen_mode_behavior_settings.xml b/res/xml/zen_mode_behavior_settings.xml
new file mode 100644
index 00000000000..8281f6567fa
--- /dev/null
+++ b/res/xml/zen_mode_behavior_settings.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/zen_mode_priority_settings.xml b/res/xml/zen_mode_priority_settings.xml
deleted file mode 100644
index e4f8f5e0f6f..00000000000
--- a/res/xml/zen_mode_priority_settings.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index 5fc72aaf240..b8ee41debd9 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -19,20 +19,19 @@
android:key="zen_mode_settings"
android:title="@string/zen_mode_settings_title" >
-
+ android:key="zen_mode_behavior_settings"
+ android:title="@string/zen_mode_behavior_settings_title"
+ android:fragment="com.android.settings.notification.ZenModeBehaviorSettings" />
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index cd479a5e141..8d4c71d744e 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -123,7 +123,7 @@ public class Settings extends SettingsActivity {
public static class PrintSettingsActivity extends SettingsActivity { /* empty */ }
public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ }
- public static class ZenModePrioritySettingsActivity extends SettingsActivity { /* empty */ }
+ public static class ZenModeBehaviorSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeAutomationSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeScheduleRuleSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeEventRuleSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 8ee61c6fd0a..f2d59d2623f 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -40,8 +40,8 @@ import com.android.settings.accounts.AccountSyncSettings;
import com.android.settings.accounts.ChooseAccountActivity;
import com.android.settings.accounts.ManagedProfileSettings;
import com.android.settings.accounts.UserAndAccountDashboardFragment;
-import com.android.settings.applications.DefaultAppSettings;
import com.android.settings.applications.AppAndNotificationDashboardFragment;
+import com.android.settings.applications.DefaultAppSettings;
import com.android.settings.applications.DrawOverlayDetails;
import com.android.settings.applications.ExternalSourcesDetails;
import com.android.settings.applications.InstalledAppDetails;
@@ -100,15 +100,15 @@ import com.android.settings.network.NetworkDashboardFragment;
import com.android.settings.nfc.AndroidBeam;
import com.android.settings.nfc.PaymentSettings;
import com.android.settings.notification.AppNotificationSettings;
-import com.android.settings.notification.ChannelNotificationSettings;
import com.android.settings.notification.ChannelGroupNotificationSettings;
+import com.android.settings.notification.ChannelNotificationSettings;
import com.android.settings.notification.ConfigureNotificationSettings;
import com.android.settings.notification.NotificationAccessSettings;
import com.android.settings.notification.NotificationStation;
import com.android.settings.notification.SoundSettings;
import com.android.settings.notification.ZenAccessSettings;
+import com.android.settings.notification.ZenModeBehaviorSettings;
import com.android.settings.notification.ZenModeEventRuleSettings;
-import com.android.settings.notification.ZenModePrioritySettings;
import com.android.settings.notification.ZenModeScheduleRuleSettings;
import com.android.settings.notification.ZenModeSettings;
import com.android.settings.notification.ZenModeVisualInterruptionSettings;
@@ -216,7 +216,7 @@ public class SettingsGateway {
ApnSettings.class.getName(),
ApnEditor.class.getName(),
WifiCallingSettings.class.getName(),
- ZenModePrioritySettings.class.getName(),
+ ZenModeBehaviorSettings.class.getName(),
ZenModeScheduleRuleSettings.class.getName(),
ZenModeEventRuleSettings.class.getName(),
ZenModeVisualInterruptionSettings.class.getName(),
diff --git a/src/com/android/settings/notification/ZenModePrioritySettings.java b/src/com/android/settings/notification/ZenModeBehaviorSettings.java
similarity index 70%
rename from src/com/android/settings/notification/ZenModePrioritySettings.java
rename to src/com/android/settings/notification/ZenModeBehaviorSettings.java
index b164407d76d..1b5e69f8697 100644
--- a/src/com/android/settings/notification/ZenModePrioritySettings.java
+++ b/src/com/android/settings/notification/ZenModeBehaviorSettings.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ package com.android.settings.notification;
import android.app.NotificationManager;
import android.app.NotificationManager.Policy;
import android.os.Bundle;
+import android.provider.Settings;
import android.service.notification.ZenModeConfig;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.DropDownPreference;
@@ -29,14 +30,15 @@ import android.util.Log;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
-import com.android.settings.search.Indexable;
-public class ZenModePrioritySettings extends ZenModeSettingsBase {
- private static final String KEY_REMINDERS = "reminders";
- private static final String KEY_EVENTS = "events";
- private static final String KEY_MESSAGES = "messages";
- private static final String KEY_CALLS = "calls";
- private static final String KEY_REPEAT_CALLERS = "repeat_callers";
+public class ZenModeBehaviorSettings extends ZenModeSettingsBase {
+ private static final String KEY_ALARMS = "zen_mode_alarms";
+ private static final String KEY_MEDIA = "zen_mode_media";
+ private static final String KEY_REMINDERS = "zen_mode_reminders";
+ private static final String KEY_EVENTS = "zen_mode_events";
+ private static final String KEY_MESSAGES = "zen_mode_messages";
+ private static final String KEY_CALLS = "zen_mode_calls";
+ private static final String KEY_REPEAT_CALLERS = "zen_mode_repeat_callers";
private static final int SOURCE_NONE = -1;
@@ -46,13 +48,15 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase {
private DropDownPreference mMessages;
private DropDownPreference mCalls;
private SwitchPreference mRepeatCallers;
+ private SwitchPreference mAlarms;
+ private SwitchPreference mMediaSystemOther;
private Policy mPolicy;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.zen_mode_priority_settings);
+ addPreferencesFromResource(R.xml.zen_mode_behavior_settings);
final PreferenceScreen root = getPreferenceScreen();
mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
@@ -141,19 +145,50 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase {
val);
if (DEBUG) Log.d(TAG, "onPrefChange allowRepeatCallers=" + val);
int priorityCategories = getNewPriorityCategories(val,
- NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS);
+ Policy.PRIORITY_CATEGORY_REPEAT_CALLERS);
savePolicy(priorityCategories, mPolicy.priorityCallSenders,
mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects);
return true;
}
});
+ mAlarms = (SwitchPreference) root.findPreference(KEY_ALARMS);
+ mAlarms.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mDisableListeners) return true;
+ final boolean val = (Boolean) newValue;
+ mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_ALARMS, val);
+ if (DEBUG) Log.d(TAG, "onPrefChange allowAlarms=" + val);
+ savePolicy(getNewPriorityCategories(val, Policy.PRIORITY_CATEGORY_ALARMS),
+ mPolicy.priorityCallSenders, mPolicy.priorityMessageSenders,
+ mPolicy.suppressedVisualEffects);
+ return true;
+ }
+ });
+
+ mMediaSystemOther = (SwitchPreference) root.findPreference(KEY_MEDIA);
+ mMediaSystemOther.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mDisableListeners) return true;
+ final boolean val = (Boolean) newValue;
+ mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_ZEN_ALLOW_MEDIA, val);
+ if (DEBUG) Log.d(TAG, "onPrefChange allowMediaSystemOther=" + val);
+ savePolicy(getNewPriorityCategories(val,
+ Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER),
+ mPolicy.priorityCallSenders, mPolicy.priorityMessageSenders,
+ mPolicy.suppressedVisualEffects);
+ return true;
+ }
+ });
+
updateControls();
}
@Override
protected void onZenModeChanged() {
- // don't care
+ updateControls();
}
@Override
@@ -162,8 +197,7 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase {
updateControls();
}
- private void updateControls() {
- mDisableListeners = true;
+ private void updateControlsPolicy() {
if (mCalls != null) {
mCalls.setValue(Integer.toString(
isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_CALLS)
@@ -172,15 +206,62 @@ public class ZenModePrioritySettings extends ZenModeSettingsBase {
mMessages.setValue(Integer.toString(
isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_MESSAGES)
? mPolicy.priorityMessageSenders : SOURCE_NONE));
+ mAlarms.setChecked(isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_ALARMS));
+ mMediaSystemOther.setChecked(isPriorityCategoryEnabled(
+ Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER));
mReminders.setChecked(isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_REMINDERS));
mEvents.setChecked(isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_EVENTS));
mRepeatCallers.setChecked(
isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS));
mRepeatCallers.setVisible(!isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_CALLS)
|| mPolicy.priorityCallSenders != Policy.PRIORITY_SENDERS_ANY);
+
+ }
+
+ private void updateControls() {
+ mDisableListeners = true;
+ switch(mZenMode) {
+ case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+ toggleBasicNoInterruptions();
+ mAlarms.setChecked(false);
+ mMediaSystemOther.setChecked(false);
+ setTogglesEnabled(false);
+ break;
+ case Settings.Global.ZEN_MODE_ALARMS:
+ toggleBasicNoInterruptions();
+ mAlarms.setChecked(true);
+ mMediaSystemOther.setChecked(true);
+ setTogglesEnabled(false);
+ break;
+ default:
+ updateControlsPolicy();
+ setTogglesEnabled(true);
+ }
mDisableListeners = false;
}
+ private void toggleBasicNoInterruptions() {
+ if (mCalls != null) {
+ mCalls.setValue(Integer.toString(SOURCE_NONE));
+ }
+ mMessages.setValue(Integer.toString(SOURCE_NONE));
+ mReminders.setChecked(false);
+ mEvents.setChecked(false);
+ mRepeatCallers.setChecked(false);
+ }
+
+ private void setTogglesEnabled(boolean enable) {
+ if (mCalls != null) {
+ mCalls.setEnabled(enable);
+ }
+ mMessages.setEnabled(enable);
+ mReminders.setEnabled(enable);
+ mEvents.setEnabled(enable);
+ mRepeatCallers.setEnabled(enable);
+ mAlarms.setEnabled(enable);
+ mMediaSystemOther.setEnabled(enable);
+ }
+
@Override
public int getMetricsCategory() {
return MetricsEvent.NOTIFICATION_ZEN_MODE_PRIORITY;
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index 8cb700b8504..f112c1b9b26 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -28,14 +28,10 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.Settings;
import android.service.notification.ConditionProviderService;
import android.service.notification.ZenModeConfig;
-import com.android.settings.utils.ManagedServiceSettings;
-import com.android.settings.utils.ZenServiceListing;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
@@ -45,25 +41,27 @@ import android.view.View;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
+import com.android.settings.utils.ManagedServiceSettings;
+import com.android.settings.utils.ZenServiceListing;
import com.android.settingslib.TwoTargetPreference;
-import java.lang.ref.WeakReference;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class ZenModeSettings extends ZenModeSettingsBase {
- public static final String KEY_VISUAL_SETTINGS = "visual_interruptions_settings";
-
- private static final String KEY_PRIORITY_SETTINGS = "priority_settings";
- private static final String KEY_AUTOMATIC_RULES = "automatic_rules";
+ public static final String KEY_VISUAL_SETTINGS = "zen_mode_visual_interruptions_settings";
+ private static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_behavior_settings";
+ private static final String KEY_AUTOMATIC_RULES = "zen_mode_automatic_rules";
static final ManagedServiceSettings.Config CONFIG = getConditionProviderConfig();
private PreferenceCategory mAutomaticRules;
- private Preference mPrioritySettings;
+ private Preference mBehaviorSettings;
private Preference mVisualSettings;
private Policy mPolicy;
private SummaryBuilder mSummaryBuilder;
@@ -78,7 +76,7 @@ public class ZenModeSettings extends ZenModeSettingsBase {
final PreferenceScreen root = getPreferenceScreen();
mAutomaticRules = (PreferenceCategory) root.findPreference(KEY_AUTOMATIC_RULES);
- mPrioritySettings = root.findPreference(KEY_PRIORITY_SETTINGS);
+ mBehaviorSettings = root.findPreference(KEY_BEHAVIOR_SETTINGS);
mVisualSettings = root.findPreference(KEY_VISUAL_SETTINGS);
mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
mSummaryBuilder = new SummaryBuilder(getContext());
@@ -113,13 +111,13 @@ public class ZenModeSettings extends ZenModeSettingsBase {
}
private void updateControls() {
- updatePrioritySettingsSummary();
+ updateBehaviorSettingsSummary();
updateVisualSettingsSummary();
updateAutomaticRules();
}
- private void updatePrioritySettingsSummary() {
- mPrioritySettings.setSummary(mSummaryBuilder.getPrioritySettingSummary(mPolicy));
+ private void updateBehaviorSettingsSummary() {
+ mBehaviorSettings.setSummary(mSummaryBuilder.getBehaviorSettingSummary(mPolicy, mZenMode));
}
private void updateVisualSettingsSummary() {
@@ -352,29 +350,44 @@ public class ZenModeSettings extends ZenModeSettingsBase {
mContext = context;
}
- String getPrioritySettingSummary(Policy policy) {
- String s = mContext.getString(R.string.zen_mode_alarms);
- 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);
- if (isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_MESSAGES)) {
- if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
- s = append(s, true, R.string.zen_mode_all_messages);
+ private static final int[] ALL_PRIORITY_CATEGORIES = {
+ Policy.PRIORITY_CATEGORY_ALARMS,
+ Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER,
+ Policy.PRIORITY_CATEGORY_REMINDERS,
+ Policy.PRIORITY_CATEGORY_EVENTS,
+ Policy.PRIORITY_CATEGORY_MESSAGES,
+ Policy.PRIORITY_CATEGORY_CALLS,
+ Policy.PRIORITY_CATEGORY_REPEAT_CALLERS,
+ };
+
+ String getBehaviorSettingSummary(Policy policy, int zenMode) {
+ List enabledCategories;
+
+ 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);
+ }
+
+ int numCategories = enabledCategories.size();
+ if (numCategories == 0) {
+ return mContext.getString(R.string.zen_mode_behavior_no_sound);
+ }
+
+ 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 = append(s, true, R.string.zen_mode_selected_messages);
+ s = mContext.getString(R.string.join_many_items_middle,
+ s, enabledCategories.get(i).toLowerCase());
}
}
- if (isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_CALLS)) {
- if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
- s = append(s, true, R.string.zen_mode_all_callers);
- } else {
- s = append(s, true, R.string.zen_mode_selected_callers);
- }
- } else if (isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_REPEAT_CALLERS)) {
- s = append(s, true, R.string.zen_mode_repeat_callers);
- }
- return s;
+
+ return mContext.getString(R.string.zen_mode_behavior_no_sound_except, s);
}
String getVisualSettingSummary(Policy policy) {
@@ -413,22 +426,45 @@ public class ZenModeSettings extends ZenModeSettingsBase {
return count;
}
- @VisibleForTesting
- String append(String s, boolean condition, int resId) {
- if (condition) {
- return mContext.getString(
- R.string.join_many_items_middle, s, mContext.getString(resId));
+ private List getEnabledCategories(Policy policy) {
+ List enabledCategories = new ArrayList<>();
+ for (int category : ALL_PRIORITY_CATEGORIES) {
+ if (isCategoryEnabled(policy, category)) {
+ if (category == Policy.PRIORITY_CATEGORY_ALARMS) {
+ enabledCategories.add(mContext.getString(R.string.zen_mode_alarms));
+ } else if (category == Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) {
+ enabledCategories.add(mContext.getString(
+ R.string.zen_mode_media_system_other));
+ } else if (category == Policy.PRIORITY_CATEGORY_REMINDERS) {
+ enabledCategories.add(mContext.getString(R.string.zen_mode_reminders));
+ } else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
+ enabledCategories.add(mContext.getString(R.string.zen_mode_events));
+ } 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_CALLS) {
+ if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
+ enabledCategories.add(mContext.getString(
+ R.string.zen_mode_all_callers));
+ } else {
+ enabledCategories.add(mContext.getString(
+ R.string.zen_mode_selected_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));
+ }
+ }
+ }
}
- 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;
+ return enabledCategories;
}
private boolean isCategoryEnabled(Policy policy, int categoryType) {
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index c946d46dc10..9608aea5920 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -74,7 +74,7 @@ import com.android.settings.nfc.PaymentSettings;
import com.android.settings.notification.ChannelImportanceSettings;
import com.android.settings.notification.ConfigureNotificationSettings;
import com.android.settings.notification.SoundSettings;
-import com.android.settings.notification.ZenModePrioritySettings;
+import com.android.settings.notification.ZenModeBehaviorSettings;
import com.android.settings.notification.ZenModeSettings;
import com.android.settings.notification.ZenModeVisualInterruptionSettings;
import com.android.settings.print.PrintSettingsFragment;
@@ -152,8 +152,8 @@ public final class SearchIndexableResources {
"android.settings.SOUND_SETTINGS");
addIndex(ZenModeSettings.class,
R.xml.zen_mode_settings, R.drawable.ic_settings_notifications);
- addIndex(ZenModePrioritySettings.class,
- R.xml.zen_mode_priority_settings, R.drawable.ic_settings_notifications);
+ addIndex(ZenModeBehaviorSettings.class,
+ R.xml.zen_mode_behavior_settings, R.drawable.ic_settings_notifications);
addIndex(StorageSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_storage);
addIndex(PowerUsageSummary.class,
R.xml.power_usage_summary, R.drawable.ic_settings_battery);
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index bbb4bb20039..6ee58d24703 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -1,5 +1,4 @@
com.android.settings.location.LocationMode
-com.android.settings.notification.ZenModePrioritySettings
com.android.settings.notification.ZenModeVisualInterruptionSettings
com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment
com.android.settings.deviceinfo.SimStatus
@@ -70,6 +69,7 @@ com.android.settings.applications.UsageAccessDetails
com.android.settings.applications.AppStorageSettings
com.android.settings.notification.NotificationAccessSettings
com.android.settings.notification.ZenModeSettings
+com.android.settings.notification.ZenModeBehaviorSettings
com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment
com.android.settings.localepicker.LocaleListEditor
com.android.settings.qstile.DevelopmentTileConfigActivity$DevelopmentTileConfigFragment
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
index 716e2b274e5..1135d7c1b16 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
@@ -16,12 +16,17 @@
package com.android.settings.notification;
+import static com.google.common.truth.Truth.assertThat;
+
+import static junit.framework.Assert.assertTrue;
+
import android.app.NotificationManager;
import android.content.Context;
+import android.provider.Settings;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -29,10 +34,6 @@ import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import static com.google.common.truth.Truth.assertThat;
-
-import static junit.framework.Assert.assertTrue;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class ZenModeSettingsTest {
@@ -47,54 +48,28 @@ public class ZenModeSettingsTest {
}
@Test
- public void testAppend_conditionFalse_shouldNotAppend() {
- String original = "test";
-
- final String result = mBuilder.append(original, false, R.string.zen_mode_alarms);
-
- assertThat(result).isEqualTo(original);
- }
-
- @Test
- public void testAppend_conditionTrue_shouldAppend() {
- String original = "test";
- String alarm = mContext.getString(R.string.zen_mode_alarms);
-
- final String result = mBuilder.append(original, true, R.string.zen_mode_alarms);
-
- assertThat(result).contains(alarm);
- assertThat(result).contains(original);
- assertTrue(result.indexOf(original) < result.indexOf(alarm));
- }
-
- @Test
- public void testPrepend() {
- String original = mContext.getString(R.string.zen_mode_alarms);
- String reminders = mContext.getString(R.string.zen_mode_reminders);
-
- final String result = mBuilder.prepend(original, true, R.string.zen_mode_reminders);
- assertThat(result).contains(original);
- assertThat(result).contains(reminders);
- assertTrue(result.indexOf(reminders) < result.indexOf(original));
- }
-
- @Test
- public void testGetPrioritySettingSummary_sameOrderAsTargetPage() {
+ public void testGetBehaviorSettingSummary_sameOrderAsTargetPage() {
NotificationManager.Policy policy = new NotificationManager.Policy(
NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS
- | NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS,
+ | NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS
+ | NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS
+ | NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER,
0, 0);
- final String result = mBuilder.getPrioritySettingSummary(policy);
+ final String result = mBuilder.getBehaviorSettingSummary(policy,
+ Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- String alarms = mContext.getString(R.string.zen_mode_alarms);
- String reminders = mContext.getString(R.string.zen_mode_reminders);
- String events = mContext.getString(R.string.zen_mode_events);
+ 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();
assertThat(result).contains(alarms);
assertThat(result).contains(reminders);
assertThat(result).contains(events);
- assertTrue(result.indexOf(reminders) < result.indexOf(events) &&
- result.indexOf(events) < result.indexOf(alarms));
+ assertThat(result).contains(media);
+ assertTrue(result.indexOf(alarms) < result.indexOf(media)
+ && result.indexOf(media) < result.indexOf(reminders)
+ && result.indexOf(reminders) < result.indexOf(events));
}
}