Merge "Exclude implicit modes from the summary of the Modes entry in Settings" into main

This commit is contained in:
Treehugger Robot
2024-11-14 17:55:43 +00:00
committed by Android (Google) Code Review
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(