Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModelTest.kt +57 −1 Original line number Diff line number Diff line Loading @@ -152,7 +152,7 @@ class ModesDialogViewModelTest : SysuiTestCase() { } with(tiles?.elementAt(1)!!) { assertThat(this.text).isEqualTo("Active with manual") assertThat(this.subtext).isEqualTo("trigger description") assertThat(this.subtext).isEqualTo("On • trigger description") assertThat(this.enabled).isEqualTo(true) } with(tiles?.elementAt(2)!!) { Loading Loading @@ -273,6 +273,62 @@ class ModesDialogViewModelTest : SysuiTestCase() { assertThat(tiles?.size).isEqualTo(0) } @Test fun tiles_calculatesSubtext() = testScope.runTest { val tiles by collectLastValue(underTest.tiles) repository.addModes( listOf( TestModeBuilder() .setName("With description, inactive") .setManualInvocationAllowed(true) .setTriggerDescription("When the going gets tough") .setActive(false) .build(), TestModeBuilder() .setName("With description, active") .setManualInvocationAllowed(true) .setTriggerDescription("When in Rome") .setActive(true) .build(), TestModeBuilder() .setName("With description, needs setup") .setManualInvocationAllowed(true) .setTriggerDescription("When you find yourself in a hole") .setEnabled(false, /* byUser= */ false) .build(), TestModeBuilder() .setName("Without description, inactive") .setManualInvocationAllowed(true) .setTriggerDescription(null) .setActive(false) .build(), TestModeBuilder() .setName("Without description, active") .setManualInvocationAllowed(true) .setTriggerDescription(null) .setActive(true) .build(), TestModeBuilder() .setName("Without description, needs setup") .setManualInvocationAllowed(true) .setTriggerDescription(null) .setEnabled(false, /* byUser= */ false) .build(), ) ) runCurrent() assertThat(tiles!!).hasSize(6) assertThat(tiles!![0].subtext).isEqualTo("When the going gets tough") assertThat(tiles!![1].subtext).isEqualTo("On • When in Rome") assertThat(tiles!![2].subtext).isEqualTo("Set up") assertThat(tiles!![3].subtext).isEqualTo("Off") assertThat(tiles!![4].subtext).isEqualTo("On") assertThat(tiles!![5].subtext).isEqualTo("Set up") } @Test fun onClick_togglesTileState() = testScope.runTest { Loading packages/SystemUI/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1106,6 +1106,9 @@ <!-- Priority modes: label for an active mode [CHAR LIMIT=35] --> <string name="zen_mode_on">On</string> <!-- Priority modes: label for an active mode, with details [CHAR LIMIT=10] --> <string name="zen_mode_on_with_details">On • <xliff:g id="trigger_description" example="Mon-Fri, 23:00-7:00">%1$s</xliff:g></string> <!-- Priority modes: label for an inactive mode [CHAR LIMIT=35] --> <string name="zen_mode_off">Off</string> Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt +10 −3 Original line number Diff line number Diff line Loading @@ -135,9 +135,16 @@ constructor( return context.resources.getString(R.string.zen_mode_no_manual_invocation) } val on = context.resources.getString(R.string.zen_mode_on) val off = context.resources.getString(R.string.zen_mode_off) return mode.getDynamicDescription(context) ?: if (mode.isActive) on else off val modeSubtext = mode.getDynamicDescription(context) return if (mode.isActive) { if (modeSubtext != null) { context.getString(R.string.zen_mode_on_with_details, modeSubtext) } else { context.getString(R.string.zen_mode_on) } } else { modeSubtext ?: context.getString(R.string.zen_mode_off) } } private fun makeZenModeDialog(): Dialog { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModelTest.kt +57 −1 Original line number Diff line number Diff line Loading @@ -152,7 +152,7 @@ class ModesDialogViewModelTest : SysuiTestCase() { } with(tiles?.elementAt(1)!!) { assertThat(this.text).isEqualTo("Active with manual") assertThat(this.subtext).isEqualTo("trigger description") assertThat(this.subtext).isEqualTo("On • trigger description") assertThat(this.enabled).isEqualTo(true) } with(tiles?.elementAt(2)!!) { Loading Loading @@ -273,6 +273,62 @@ class ModesDialogViewModelTest : SysuiTestCase() { assertThat(tiles?.size).isEqualTo(0) } @Test fun tiles_calculatesSubtext() = testScope.runTest { val tiles by collectLastValue(underTest.tiles) repository.addModes( listOf( TestModeBuilder() .setName("With description, inactive") .setManualInvocationAllowed(true) .setTriggerDescription("When the going gets tough") .setActive(false) .build(), TestModeBuilder() .setName("With description, active") .setManualInvocationAllowed(true) .setTriggerDescription("When in Rome") .setActive(true) .build(), TestModeBuilder() .setName("With description, needs setup") .setManualInvocationAllowed(true) .setTriggerDescription("When you find yourself in a hole") .setEnabled(false, /* byUser= */ false) .build(), TestModeBuilder() .setName("Without description, inactive") .setManualInvocationAllowed(true) .setTriggerDescription(null) .setActive(false) .build(), TestModeBuilder() .setName("Without description, active") .setManualInvocationAllowed(true) .setTriggerDescription(null) .setActive(true) .build(), TestModeBuilder() .setName("Without description, needs setup") .setManualInvocationAllowed(true) .setTriggerDescription(null) .setEnabled(false, /* byUser= */ false) .build(), ) ) runCurrent() assertThat(tiles!!).hasSize(6) assertThat(tiles!![0].subtext).isEqualTo("When the going gets tough") assertThat(tiles!![1].subtext).isEqualTo("On • When in Rome") assertThat(tiles!![2].subtext).isEqualTo("Set up") assertThat(tiles!![3].subtext).isEqualTo("Off") assertThat(tiles!![4].subtext).isEqualTo("On") assertThat(tiles!![5].subtext).isEqualTo("Set up") } @Test fun onClick_togglesTileState() = testScope.runTest { Loading
packages/SystemUI/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1106,6 +1106,9 @@ <!-- Priority modes: label for an active mode [CHAR LIMIT=35] --> <string name="zen_mode_on">On</string> <!-- Priority modes: label for an active mode, with details [CHAR LIMIT=10] --> <string name="zen_mode_on_with_details">On • <xliff:g id="trigger_description" example="Mon-Fri, 23:00-7:00">%1$s</xliff:g></string> <!-- Priority modes: label for an inactive mode [CHAR LIMIT=35] --> <string name="zen_mode_off">Off</string> Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt +10 −3 Original line number Diff line number Diff line Loading @@ -135,9 +135,16 @@ constructor( return context.resources.getString(R.string.zen_mode_no_manual_invocation) } val on = context.resources.getString(R.string.zen_mode_on) val off = context.resources.getString(R.string.zen_mode_off) return mode.getDynamicDescription(context) ?: if (mode.isActive) on else off val modeSubtext = mode.getDynamicDescription(context) return if (mode.isActive) { if (modeSubtext != null) { context.getString(R.string.zen_mode_on_with_details, modeSubtext) } else { context.getString(R.string.zen_mode_on) } } else { modeSubtext ?: context.getString(R.string.zen_mode_off) } } private fun makeZenModeDialog(): Dialog { Loading