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
This commit is contained in:
Matías Hernández
2024-11-14 15:33:54 +00:00
parent 68158ee324
commit 0baf70a4b3
2 changed files with 16 additions and 1 deletions

View File

@@ -500,10 +500,13 @@ class ZenModeSummaryHelper {
Locale.getDefault());
return buildModesSummary(msgFormat, activeModes);
} else {
List<ZenMode> 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);
}
}

View File

@@ -526,6 +526,18 @@ public class ZenModeSummaryHelperTest {
assertThat(summary).isEqualTo("Juggling, Rhyming, Meandering");
}
@Test
public void getModesSummary_excludesImplicitModes() {
ImmutableList<ZenMode> 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<ZenMode> modes = ImmutableList.of(