diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1b260f8219d..148cd1d3d41 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10673,11 +10673,13 @@
Manage %1$s Notifications
No suggested application
-
-
- - %1$d notification channel. Tap to manage all.
- - %1$d notification channels. Tap to manage all.
+
+
+ - %1$d notification channel.
+ - %1$d notification channels.
+
+ %1$d notification channels. Tap to manage all.
Switch output
diff --git a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
index c2c2ecea601..01526147ea3 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
@@ -415,9 +415,13 @@ public class NotificationChannelSlice implements CustomSliceable {
private CharSequence getSubTitle(String packageName, int uid) {
final int channelCount = mNotificationBackend.getChannelCount(packageName, uid);
+ if (channelCount > DEFAULT_EXPANDED_ROW_COUNT) {
+ return mContext.getString(
+ R.string.notification_many_channel_count_summary, channelCount);
+ }
+
return mContext.getResources().getQuantityString(
- R.plurals.notification_channel_count_summary,
- channelCount, channelCount);
+ R.plurals.notification_few_channel_count_summary, channelCount, channelCount);
}
private Intent getAppAndNotificationPageIntent() {
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
index 7ec131675ca..a744e68a64c 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
@@ -229,6 +229,50 @@ public class NotificationChannelSliceTest {
assertThat(rows).isEqualTo(NotificationChannelSlice.DEFAULT_EXPANDED_ROW_COUNT + 1);
}
+ @Test
+ @Config(shadows = ShadowRestrictedLockUtilsInternal.class)
+ public void getSlice_channelCountIsLessThanDefaultRows_subTitleShouldNotHaveTapToManagerAll() {
+ addMockPackageToPackageManager(true /* isRecentlyInstalled */,
+ ApplicationInfo.FLAG_INSTALLED);
+ mockNotificationBackend(CHANNEL_COUNT - 1, NOTIFICATION_COUNT, false /* banned */);
+
+ final Slice slice = mNotificationChannelSlice.getSlice();
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getSubtitle()).isEqualTo(mContext.getResources().getQuantityString(
+ R.plurals.notification_few_channel_count_summary, CHANNEL_COUNT - 1,
+ CHANNEL_COUNT - 1));
+ }
+
+ @Test
+ @Config(shadows = ShadowRestrictedLockUtilsInternal.class)
+ public void getSlice_channelCountIsEqualToDefaultRows_subTitleShouldNotHaveTapToManagerAll() {
+ addMockPackageToPackageManager(true /* isRecentlyInstalled */,
+ ApplicationInfo.FLAG_INSTALLED);
+ mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+
+ final Slice slice = mNotificationChannelSlice.getSlice();
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getSubtitle()).isEqualTo(mContext.getResources().getQuantityString(
+ R.plurals.notification_few_channel_count_summary, CHANNEL_COUNT, CHANNEL_COUNT));
+ }
+
+ @Test
+ @Config(shadows = ShadowRestrictedLockUtilsInternal.class)
+ public void getSlice_channelCountIsMoreThanDefaultRows_subTitleShouldHaveTapToManagerAll() {
+ addMockPackageToPackageManager(true /* isRecentlyInstalled */,
+ ApplicationInfo.FLAG_INSTALLED);
+ mockNotificationBackend(CHANNEL_COUNT + 1, NOTIFICATION_COUNT, false /* banned */);
+
+ final Slice slice = mNotificationChannelSlice.getSlice();
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getSubtitle()).isEqualTo(
+ mContext.getString(R.string.notification_many_channel_count_summary,
+ CHANNEL_COUNT + 1));
+ }
+
private void addMockPackageToPackageManager(boolean isRecentlyInstalled, int flags) {
final ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.name = APP_LABEL;