Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a484412 authored by Liana Kazanova (xWF)'s avatar Liana Kazanova (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Announce new state of modes when toggled in Modes Dialog"

This reverts commit 008cfe42.

Reason for revert: DroidMonitor: Potential culprit for b/361111266 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: I84ac879209d4d01c036d2750cf588ad497815610
parent 008cfe42
Loading
Loading
Loading
Loading
+0 −61
Original line number Diff line number Diff line
@@ -329,67 +329,6 @@ class ModesDialogViewModelTest : SysuiTestCase() {
            assertThat(tiles!![5].subtext).isEqualTo("Set up")
        }

    @Test
    fun tiles_calculatesContentDescription() =
        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].contentDescription)
                .isEqualTo("With description, inactive\nOff\nWhen the going gets tough")
            assertThat(tiles!![1].contentDescription)
                .isEqualTo("With description, active\nOn\nWhen in Rome")
            assertThat(tiles!![2].contentDescription)
                .isEqualTo("With description, needs setup\nSet up")
            assertThat(tiles!![3].contentDescription)
                .isEqualTo("Without description, inactive\nOff")
            assertThat(tiles!![4].contentDescription).isEqualTo("Without description, active\nOn")
            assertThat(tiles!![5].contentDescription)
                .isEqualTo("Without description, needs setup\nSet up")
        }

    @Test
    fun onClick_togglesTileState() =
        testScope.runTest {
+1 −6
Original line number Diff line number Diff line
@@ -33,9 +33,6 @@ import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.android.systemui.common.ui.compose.Icon
@@ -61,9 +58,7 @@ fun ModeTile(viewModel: ModeTileViewModel) {
                            onClick = viewModel.onClick,
                            onLongClick = viewModel.onLongClick
                        )
                        .padding(20.dp)
                        .semantics(mergeDescendants = true) {}
                        .clearAndSetSemantics { contentDescription = viewModel.contentDescription },
                        .padding(20.dp),
                verticalAlignment = Alignment.CenterVertically,
                horizontalArrangement =
                    Arrangement.spacedBy(
+0 −1
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ data class ModeTileViewModel(
    val icon: Icon,
    val text: String,
    val subtext: String,
    val contentDescription: String,
    val enabled: Boolean,
    val onClick: () -> Unit,
    val onLongClick: () -> Unit,
+1 −21
Original line number Diff line number Diff line
@@ -89,9 +89,8 @@ constructor(
                    ModeTileViewModel(
                        id = mode.id,
                        icon = zenModeInteractor.getModeIcon(mode, context),
                        text = mode.name,
                        text = mode.rule.name,
                        subtext = getTileSubtext(mode),
                        contentDescription = getTileContentDescription(mode),
                        enabled = mode.isActive,
                        onClick = {
                            if (!mode.rule.isEnabled) {
@@ -148,25 +147,6 @@ constructor(
        }
    }

    private fun getTileContentDescription(mode: ZenMode): String {
        return buildList {
                add(mode.name)
                if (!mode.rule.isEnabled) {
                    add(context.getString(R.string.zen_mode_set_up))
                } else if (!mode.rule.isManualInvocationAllowed && !mode.isActive) {
                    add(context.getString(R.string.zen_mode_no_manual_invocation))
                } else {
                    add(
                        context.getString(
                            if (mode.isActive) R.string.zen_mode_on else R.string.zen_mode_off
                        )
                    )
                    mode.getDynamicDescription(context)?.let { add(it) }
                }
            }
            .joinToString(separator = "\n")
    }

    private fun makeZenModeDialog(): Dialog {
        val dialog =
            EnableZenModeDialog(