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

Commit 45450dfd authored by Olivier St-Onge's avatar Olivier St-Onge Committed by Android (Google) Code Review
Browse files

Merge "Remove the text from the undo button" into main

parents 747fc448 8604a6ac
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
@@ -280,26 +281,22 @@ fun DefaultEditTileGrid(
        topBar = {
            EditModeTopBar(onStopEditing = onStopEditing, modifier = Modifier.statusBarsPadding()) {
                AnimatedVisibility(snapshotViewModel.canUndo, enter = fadeIn(), exit = fadeOut()) {
                    TextButton(
                    IconButton(
                        enabled = snapshotViewModel.canUndo,
                        onClick = {
                            selectionState.unSelect()
                            snapshotViewModel.undo()
                        },
                        colors =
                            ButtonDefaults.textButtonColors(
                            IconButtonDefaults.iconButtonColors(
                                containerColor = MaterialTheme.colorScheme.primary,
                                contentColor = MaterialTheme.colorScheme.onPrimary,
                            ),
                    ) {
                        Icon(
                            Icons.AutoMirrored.Default.Undo,
                            contentDescription = null,
                            modifier = Modifier.padding(end = 8.dp),
                        )
                        Text(
                            text = stringResource(id = com.android.internal.R.string.undo),
                            style = MaterialTheme.typography.labelLarge,
                            contentDescription =
                                stringResource(id = com.android.internal.R.string.undo),
                        )
                    }
                }
@@ -523,7 +520,12 @@ private fun EditGridHeader(

@Composable
private fun EditGridCenteredText(text: String, modifier: Modifier = Modifier) {
    Text(text = text, style = MaterialTheme.typography.titleSmall, modifier = modifier)
    Text(
        text = text,
        style = MaterialTheme.typography.titleSmall,
        textAlign = TextAlign.Center,
        modifier = modifier,
    )
}

@Composable
+3 −3
Original line number Diff line number Diff line
@@ -201,12 +201,12 @@ class EditModeTest : SysuiTestCase() {
        composeRule.onNodeWithText("tileF").performClick() // Tap to add
        composeRule.waitForIdle()

        composeRule.onNodeWithText("Undo").assertExists()
        composeRule.onNodeWithContentDescription("Undo").assertExists()

        composeRule.onNodeWithText("Undo").performClick() // Undo addition
        composeRule.onNodeWithContentDescription("Undo").performClick() // Undo addition
        composeRule.waitForIdle()

        composeRule.onNodeWithText("Undo").assertDoesNotExist()
        composeRule.onNodeWithContentDescription("Undo").assertDoesNotExist()
    }

    private fun ComposeContentTestRule.assertCurrentTilesGridContainsExactly(specs: List<String>) =
+8 −8
Original line number Diff line number Diff line
@@ -147,14 +147,14 @@ class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() {
                .inOrder()

            // Perform first undo
            composeRule.onNodeWithText("Undo").performClick()
            composeRule.onNodeWithContentDescription("Undo").performClick()
            // Assert we're back to the first move state
            assertThat(currentTilesInteractor.currentTilesSpecs.map { it.spec })
                .containsExactlyElementsIn(stateOnFirstMove)
                .inOrder()

            // Perform second undo
            composeRule.onNodeWithText("Undo").performClick()
            composeRule.onNodeWithContentDescription("Undo").performClick()
            // Assert we're back to the initial state
            assertThat(currentTilesInteractor.currentTilesSpecs.map { it.spec })
                .containsExactlyElementsIn(TestEditTiles.map { it.spec })
@@ -189,12 +189,12 @@ class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() {
            assertThat(latest!!.find { it.tile.tileSpec == "mictoggle" }).isNotNull()

            // Perform first undo
            composeRule.onNodeWithText("Undo").performClick()
            composeRule.onNodeWithContentDescription("Undo").performClick()
            // Assert that mictoggle is no longer current
            assertThat(latest!!.find { it.tile.tileSpec == "mictoggle" }).isNull()

            // Perform second undo
            composeRule.onNodeWithText("Undo").performClick()
            composeRule.onNodeWithContentDescription("Undo").performClick()
            // Assert that rotation is no longer current
            assertThat(latest!!.find { it.tile.tileSpec == "rotation" }).isNull()
        }
@@ -225,12 +225,12 @@ class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() {
            assertThat(latest!!.find { it.tile.tileSpec == "bt" }).isNull()

            // Perform first undo
            composeRule.onNodeWithText("Undo").performClick()
            composeRule.onNodeWithContentDescription("Undo").performClick()
            // Assert that bluetooth is current
            assertThat(latest!!.find { it.tile.tileSpec == "bt" }).isNotNull()

            // Perform second undo
            composeRule.onNodeWithText("Undo").performClick()
            composeRule.onNodeWithContentDescription("Undo").performClick()
            // Assert that internet is current
            assertThat(latest!!.find { it.tile.tileSpec == "internet" }).isNotNull()
        }
@@ -266,11 +266,11 @@ class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() {
            assertLargeTiles(setOf("bt", "dnd", "cast", "flashlight"))

            // Perform first undo
            composeRule.onNodeWithText("Undo").performClick()
            composeRule.onNodeWithContentDescription("Undo").performClick()
            assertLargeTiles(setOf("bt", "dnd", "cast"))

            // Perform second undo
            composeRule.onNodeWithText("Undo").performClick()
            composeRule.onNodeWithContentDescription("Undo").performClick()
            assertLargeTiles(setOf("internet", "bt", "dnd", "cast"))
            assertThat(dynamicIconTilesViewModel.largeTilesState.value.map { it.spec })
                .containsExactly("internet", "bt", "dnd", "cast")