Update summary of Modes entry in Settings
Instead of the number of automatic modes, simply list the first (up to 3) existing modes, according to the standard sort order, when none are active. As a consequence, the summary is never empty now. Fixes: 374179941 Test: atest ZenModeSummaryHelperTest + manual Flag: android.app.modes_ui Change-Id: I04f9d90a5e1e4ed13d66181b85d77fef8c6ff256
This commit is contained in:
@@ -29,7 +29,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.app.AutomaticZenRule;
|
||||
import android.app.Flags;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@@ -38,9 +37,7 @@ import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.service.notification.SystemZenRules;
|
||||
import android.service.notification.ZenDeviceEffects;
|
||||
import android.service.notification.ZenModeConfig;
|
||||
import android.service.notification.ZenPolicy;
|
||||
|
||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
@@ -476,46 +473,61 @@ public class ZenModeSummaryHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModesSummary_noRules_noSummary() {
|
||||
public void getModesSummary_noModesWtf_fallbackSummary() {
|
||||
String summary = mSummaryHelper.getModesSummary(ImmutableList.of());
|
||||
assertThat(summary).isEmpty();
|
||||
assertThat(summary).isEqualTo("Do Not Disturb");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModesSummary_onlyDndAndNotActive_noSummary() {
|
||||
ImmutableList<ZenMode> modes = ImmutableList.of(TestModeBuilder.MANUAL_DND_INACTIVE);
|
||||
String summary = mSummaryHelper.getModesSummary(modes);
|
||||
assertThat(summary).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModesSummary_noRulesActive_countsOnlyEnabledAutomaticModes() {
|
||||
public void getModesSummary_oneMode_listsMode() {
|
||||
ImmutableList<ZenMode> modes = ImmutableList.of(
|
||||
TestModeBuilder.MANUAL_DND_INACTIVE, // Not automatic
|
||||
new TestModeBuilder().setName("Auto 1").build(), // App provided automatic
|
||||
new TestModeBuilder()
|
||||
.setName("Custom manual 1")
|
||||
.setPackage(SystemZenRules.PACKAGE_ANDROID)
|
||||
.setType(AutomaticZenRule.TYPE_OTHER)
|
||||
.setConditionId(ZenModeConfig.toCustomManualConditionId())
|
||||
.build(), // Custom manual, not automatic
|
||||
new TestModeBuilder()
|
||||
.setName("Disabled 1")
|
||||
.setEnabled(false)
|
||||
.build(), // Would be automatic, but it's disabled.
|
||||
new TestModeBuilder()
|
||||
.setName("Sleep")
|
||||
.setPackage(SystemZenRules.PACKAGE_ANDROID)
|
||||
.setType(AutomaticZenRule.TYPE_SCHEDULE_TIME)
|
||||
.build() // Time based, automatic.
|
||||
new TestModeBuilder().setName("Surfing").build()
|
||||
);
|
||||
|
||||
String summary = mSummaryHelper.getModesSummary(modes);
|
||||
assertThat(summary).isEqualTo("2 modes can turn on automatically");
|
||||
assertThat(summary).isEqualTo("Surfing");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModesSummary_oneModeActive_listsMode() {
|
||||
public void getModesSummary_twoModes_listsModes() {
|
||||
ImmutableList<ZenMode> modes = ImmutableList.of(
|
||||
new TestModeBuilder().setName("Cartwheeling").build(),
|
||||
new TestModeBuilder().setName("Hula-hooping").build()
|
||||
);
|
||||
|
||||
String summary = mSummaryHelper.getModesSummary(modes);
|
||||
assertThat(summary).isEqualTo("Cartwheeling, Hula-hooping");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModesSummary_threeModes_listsModes() {
|
||||
ImmutableList<ZenMode> modes = ImmutableList.of(
|
||||
new TestModeBuilder().setName("Prancing").build(),
|
||||
new TestModeBuilder().setName("Hopping").build(),
|
||||
new TestModeBuilder().setName("Skipping").build()
|
||||
);
|
||||
|
||||
String summary = mSummaryHelper.getModesSummary(modes);
|
||||
assertThat(summary).isEqualTo("Prancing, Hopping, Skipping");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModesSummary_manyModes_listsThreeModes() {
|
||||
ImmutableList<ZenMode> modes = ImmutableList.of(
|
||||
new TestModeBuilder().setName("Juggling").build(),
|
||||
new TestModeBuilder().setName("Rhyming").build(),
|
||||
new TestModeBuilder().setName("Meandering").build(),
|
||||
new TestModeBuilder().setName("Doodling").build(),
|
||||
new TestModeBuilder().setName("Whistling").build(),
|
||||
new TestModeBuilder().setName("Lounging").build()
|
||||
);
|
||||
|
||||
String summary = mSummaryHelper.getModesSummary(modes);
|
||||
assertThat(summary).isEqualTo("Juggling, Rhyming, Meandering");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModesSummary_oneModeActive_listsActiveMode() {
|
||||
ImmutableList<ZenMode> modes = ImmutableList.of(
|
||||
TestModeBuilder.MANUAL_DND_ACTIVE,
|
||||
new TestModeBuilder().setName("Inactive").setActive(false).build());
|
||||
@@ -525,7 +537,7 @@ public class ZenModeSummaryHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModesSummary_twoModesActive_listsModes() {
|
||||
public void getModesSummary_twoModesActive_listsActiveModes() {
|
||||
ImmutableList<ZenMode> modes = ImmutableList.of(
|
||||
TestModeBuilder.MANUAL_DND_ACTIVE,
|
||||
new TestModeBuilder().setName("Inactive").setActive(false).build(),
|
||||
@@ -536,7 +548,7 @@ public class ZenModeSummaryHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModesSummary_threeModesActive_listsModes() {
|
||||
public void getModesSummary_threeModesActive_listsActiveModes() {
|
||||
ImmutableList<ZenMode> modes = ImmutableList.of(
|
||||
TestModeBuilder.MANUAL_DND_INACTIVE,
|
||||
new TestModeBuilder().setName("Inactive #1").setActive(false).build(),
|
||||
@@ -550,7 +562,7 @@ public class ZenModeSummaryHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModesSummary_manyModesActive_listsACouple() {
|
||||
public void getModesSummary_manyModesActive_listsSomeActiveModes() {
|
||||
ImmutableList<ZenMode> modes = ImmutableList.of(
|
||||
TestModeBuilder.MANUAL_DND_ACTIVE,
|
||||
new TestModeBuilder().setName("Inactive #1").setActive(false).build(),
|
||||
|
||||
Reference in New Issue
Block a user