From 0baf70a4b37fa83ffa272e8077097bf0355c8302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Hern=C3=A1ndez?= Date: Thu, 14 Nov 2024 15:33:54 +0000 Subject: [PATCH] Exclude implicit modes from the summary of the Modes entry in Settings They are called "Do Not Disturb (App)" which places alphabetically near the top (in English). This can often result in a summary like "DND, Bedtime, DND (App)", which looks silly. Fixes: 379089451 Test: atest ZenModeSummaryHelperTest Flag: android.app.modes_ui Change-Id: Id41caee09cca874297ca12d2ac934aed3f9a43ab --- .../notification/modes/ZenModeSummaryHelper.java | 5 ++++- .../notification/modes/ZenModeSummaryHelperTest.java | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/notification/modes/ZenModeSummaryHelper.java b/src/com/android/settings/notification/modes/ZenModeSummaryHelper.java index 2a0e8b354b5..1ee43fbfe43 100644 --- a/src/com/android/settings/notification/modes/ZenModeSummaryHelper.java +++ b/src/com/android/settings/notification/modes/ZenModeSummaryHelper.java @@ -500,10 +500,13 @@ class ZenModeSummaryHelper { Locale.getDefault()); return buildModesSummary(msgFormat, activeModes); } else { + List modesExcludingImplicit = modes.stream() + .filter(m -> m.getKind() != ZenMode.Kind.IMPLICIT) + .toList(); MessageFormat msgFormat = new MessageFormat( mContext.getString(R.string.zen_modes_summary), Locale.getDefault()); - return buildModesSummary(msgFormat, modes); + return buildModesSummary(msgFormat, modesExcludingImplicit); } } diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeSummaryHelperTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeSummaryHelperTest.java index 1cd3053cb5d..d222a8b9568 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeSummaryHelperTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeSummaryHelperTest.java @@ -526,6 +526,18 @@ public class ZenModeSummaryHelperTest { assertThat(summary).isEqualTo("Juggling, Rhyming, Meandering"); } + @Test + public void getModesSummary_excludesImplicitModes() { + ImmutableList modes = ImmutableList.of( + TestModeBuilder.MANUAL_DND_INACTIVE, + new TestModeBuilder().implicitForPackage("com.annoying.one").build(), + new TestModeBuilder().setName("Chirping").build() + ); + + String summary = mSummaryHelper.getModesSummary(modes); + assertThat(summary).isEqualTo("Do Not Disturb, Chirping"); + } + @Test public void getModesSummary_oneModeActive_listsActiveMode() { ImmutableList modes = ImmutableList.of(