diff --git a/res/values/strings.xml b/res/values/strings.xml index 033989d9dae..37badce2d6e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -8924,6 +8924,9 @@ App exceptions + + No apps can override Do Not Disturb + No apps can override Do Not Disturb diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml index ce2d1322c9a..f8a3aa59240 100644 --- a/res/xml/zen_mode_settings.xml +++ b/res/xml/zen_mode_settings.xml @@ -43,6 +43,7 @@ diff --git a/src/com/android/settings/notification/zen/ZenModeAllBypassingAppsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeAllBypassingAppsPreferenceController.java index b3630a0a951..9484a09cb92 100644 --- a/src/com/android/settings/notification/zen/ZenModeAllBypassingAppsPreferenceController.java +++ b/src/com/android/settings/notification/zen/ZenModeAllBypassingAppsPreferenceController.java @@ -105,9 +105,7 @@ public class ZenModeAllBypassingAppsPreferenceController extends AbstractPrefere ApplicationsState.AppFilter filter = ApplicationsState.FILTER_ALL_ENABLED; List apps = mAppSession.rebuild(filter, ApplicationsState.ALPHA_COMPARATOR); - if (apps != null) { - updateNotificationChannelList(apps); - } + updateNotificationChannelList(apps); } @VisibleForTesting @@ -116,6 +114,8 @@ public class ZenModeAllBypassingAppsPreferenceController extends AbstractPrefere return; } + boolean showEmptyState = true; + List channelsBypassingDnd = new ArrayList<>(); for (ApplicationsState.AppEntry entry : apps) { String pkg = entry.info.packageName; @@ -148,6 +148,7 @@ public class ZenModeAllBypassingAppsPreferenceController extends AbstractPrefere return true; }); channelsBypassingDnd.add(pref); + showEmptyState = false; } mPreferenceScreen.removeAll(); @@ -156,6 +157,11 @@ public class ZenModeAllBypassingAppsPreferenceController extends AbstractPrefere mPreferenceScreen.addPreference(prefToAdd); } } + if (showEmptyState) { + Preference pref = new Preference(mPrefContext); + pref.setTitle(R.string.zen_mode_bypassing_apps_subtext_none); + mPreferenceScreen.addPreference(pref); + } } } diff --git a/src/com/android/settings/notification/zen/ZenModeBypassingAppsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeBypassingAppsPreferenceController.java index 9ef9380a745..a93fa1b9856 100644 --- a/src/com/android/settings/notification/zen/ZenModeBypassingAppsPreferenceController.java +++ b/src/com/android/settings/notification/zen/ZenModeBypassingAppsPreferenceController.java @@ -9,7 +9,7 @@ import com.android.settingslib.core.lifecycle.Lifecycle; public class ZenModeBypassingAppsPreferenceController extends AbstractZenModePreferenceController { - protected static final String KEY = "zen_mode_bypassing_apps"; + protected static final String KEY = "zen_mode_behavior_apps"; private NotificationBackend mNotificationBackend = new NotificationBackend(); public ZenModeBypassingAppsPreferenceController(Context context, Lifecycle lifecycle) { @@ -18,13 +18,16 @@ public class ZenModeBypassingAppsPreferenceController extends AbstractZenModePre @Override public boolean isAvailable() { - return mNotificationBackend.getNumAppsBypassingDnd(UserHandle.getCallingUserId()) != 0; + return true; } @Override public String getSummary() { final int channelsBypassing = mNotificationBackend.getNumAppsBypassingDnd(UserHandle.getCallingUserId()); + if (channelsBypassing == 0) { + return mContext.getResources().getString(R.string.zen_mode_bypassing_apps_subtext_none); + } return mContext.getResources().getQuantityString(R.plurals.zen_mode_bypassing_apps_subtext, channelsBypassing, channelsBypassing); }