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

Commit 8604a6ac authored by Olivier St-Onge's avatar Olivier St-Onge
Browse files

Remove the text from the undo button

This helps to keep space available for the Edit mode title on larger display sizes and different locales
Also center the text of the grid header as a drive by fix

Test: manually undoing changes
Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Fixes: 417535281
Change-Id: Ibe33306d84f42022a9b23b6f966c1512e02f3c26
parent 921f2de4
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")