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

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

Fix talkback issues in edit mode

- Set a label to the removal badge
- Remove duplicate content descriptions on tiles
- Move the available tiles clickable modifier up to the parent to encapsulate the labels

Test: manually using Talkback
Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Fixes: 406826901
Fixes: 396177516
Change-Id: If7328951da9bb8ce4c288f41977b693e3b43a4fc
parent 293d0839
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2614,8 +2614,8 @@
    <!-- Accessibility description of action to toggle QS tile size on click. It will read as "Double-tap to toggle the tile's size" in screen readers [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_toggle_tile_size_action">toggle the tile\'s size</string>

    <!-- Accessibility description of action to remove QS tile on click. It will read as "Double-tap to remove tile" in screen readers [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_remove_tile_action">remove tile</string>
    <!-- Accessibility description of action to remove QS tile on click. [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_remove_tile_action">Remove tile</string>

    <!-- Accessibility description of action to select the QS tile to place on click. It will read as "Double-tap to toggle placement mode" in screen readers [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_toggle_placement_mode">toggle placement mode</string>
@@ -2623,8 +2623,8 @@
    <!-- Accessibility description of action to toggle the QS tile selection. It will read as "Double-tap to toggle selection" in screen readers [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_toggle_selection">toggle selection</string>

    <!-- Accessibility action of action to add QS tile to end. It will read as "Double-tap to add tile to the last position" in screen readers [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_tile_add_action">add tile to the last position</string>
    <!-- Accessibility action of action to add QS tile to end. [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_tile_add_action">Add tile to the last position</string>

    <!-- Accessibility action for context menu to move QS tile [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_tile_start_move">Move tile</string>
+11 −16
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.CustomAccessibilityAction
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.customActions
import androidx.compose.ui.semantics.semantics
@@ -834,7 +835,7 @@ private fun TileGridCell(
                coroutineScope.launch { resizingState.toggleCurrentValue() }
            }
        },
        onClickLabel = decorationClickLabel,
        contentDescription = decorationClickLabel,
    ) {
        val placeableColor = MaterialTheme.colorScheme.primary.copy(alpha = .4f)
        val backgroundColor by
@@ -857,7 +858,7 @@ private fun TileGridCell(

        Box(
            Modifier.fillMaxSize()
                .semantics(mergeDescendants = true) {
                .clearAndSetSemantics {
                    this.stateDescription = stateDescription
                    contentDescription = cell.tile.label.text
                    customActions =
@@ -922,6 +923,10 @@ private fun AvailableTileGridCell(

    val alpha by animateFloatAsState(if (cell.isCurrent) .38f else 1f)
    val colors = EditModeTileDefaults.editTileColors()
    val onClick: () -> Unit = {
        onAddTile(cell.tileSpec)
        selectionState.select(cell.tileSpec)
    }

    // Displays the tile as an icon tile with the label underneath
    Column(
@@ -930,9 +935,8 @@ private fun AvailableTileGridCell(
        modifier =
            modifier
                .graphicsLayer { this.alpha = alpha }
                .semantics(mergeDescendants = true) {
                    stateDescription?.let { this.stateDescription = it }
                },
                .clickable(enabled = !cell.isCurrent, onClick = onClick)
                .semantics { stateDescription?.let { this.stateDescription = it } },
    ) {
        Box(Modifier.fillMaxWidth().height(TileHeight)) {
            val draggableModifier =
@@ -947,22 +951,13 @@ private fun AvailableTileGridCell(
                        selectionState.unSelect()
                    }
                }
            val onClick: () -> Unit = {
                onAddTile(cell.tileSpec)
                selectionState.select(cell.tileSpec)
            }
            Box(
                draggableModifier
                    .fillMaxSize()
                    .clickable(enabled = !cell.isCurrent, onClick = onClick)
                    .tileBackground { colors.background }
            ) {
            Box(draggableModifier.fillMaxSize().tileBackground { colors.background }) {
                // Icon
                SmallTileContent(
                    iconProvider = { cell.icon },
                    color = colors.icon,
                    animateToEnd = true,
                    modifier = Modifier.align(Alignment.Center),
                    modifier = Modifier.align(Alignment.Center).clearAndSetSemantics {},
                )
            }

+4 −17
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ fun InteractiveTileContainer(
    resizingState: ResizingState,
    modifier: Modifier = Modifier,
    onClick: () -> Unit = {},
    onClickLabel: String? = null,
    contentDescription: String? = null,
    content: @Composable BoxScope.() -> Unit = {},
) {
    val transition: Transition<TileState> = updateTransition(tileState)
@@ -150,18 +150,12 @@ fun InteractiveTileContainer(
                        state = resizingState.anchoredDraggableState,
                        orientation = Orientation.Horizontal,
                    )
                    .clickable(
                        enabled = tileState != None,
                        interactionSource = null,
                        indication = null,
                        onClickLabel = onClickLabel,
                        onClick = onClick,
                    )
                    .clickable(enabled = tileState != None, onClick = onClick)
            ) {
                val size = with(LocalDensity.current) { BadgeIconSize.toDp() }
                Icon(
                    Icons.Default.Remove,
                    contentDescription = null,
                    contentDescription = contentDescription,
                    tint = MaterialTheme.colorScheme.onPrimaryContainer,
                    modifier =
                        Modifier.size(size).align(Alignment.Center).graphicsLayer {
@@ -217,14 +211,7 @@ fun StaticTileBadge(
        Box(
            Modifier.fillMaxSize()
                .graphicsLayer { this.alpha = alpha }
                .thenIf(enabled) {
                    Modifier.clickable(
                        interactionSource = null,
                        indication = null,
                        onClickLabel = contentDescription,
                        onClick = onClick,
                    )
                }
                .thenIf(enabled) { Modifier.clickable(onClick = onClick) }
        ) {
            val size = with(LocalDensity.current) { BadgeIconSize.toDp() }
            val primaryColor = MaterialTheme.colorScheme.primary
+4 −6
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.test.doubleClick
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onFirst
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
@@ -105,7 +103,7 @@ class EditModeTest : SysuiTestCase() {
        composeRule.setContent { EditTileGridUnderTest() }
        composeRule.waitForIdle()

        composeRule.onNodeWithContentDescription("tileF").performClick() // Tap to add
        composeRule.onNodeWithText("tileF").performClick() // Tap to add

        composeRule.assertCurrentTilesGridContainsExactly(
            listOf("tileA", "tileB", "tileC", "tileD_large", "tileE", "tileF")
@@ -119,10 +117,10 @@ class EditModeTest : SysuiTestCase() {
        composeRule.waitForIdle()

        // Double tap first "tileA", i.e. the one in the current grid
        composeRule.onAllNodesWithText("tileA").onFirst().performTouchInput { doubleClick() }
        composeRule.onNodeWithContentDescription("tileA").performTouchInput { doubleClick() }

        // Tap on tileE to position tileA in its spot
        composeRule.onAllNodesWithText("tileE").onFirst().performClick()
        composeRule.onNodeWithContentDescription("tileE").performClick()

        // Assert tileA moved to tileE's position
        composeRule.assertCurrentTilesGridContainsExactly(
@@ -135,7 +133,7 @@ class EditModeTest : SysuiTestCase() {
        composeRule.setContent { EditTileGridUnderTest() }
        composeRule.waitForIdle()

        composeRule.onNodeWithContentDescription("tileF").performClick() // Tap to add
        composeRule.onNodeWithText("tileF").performClick() // Tap to add
        composeRule.waitForIdle()

        composeRule.onNodeWithText("Undo").assertExists()
+7 −14
Original line number Diff line number Diff line
@@ -23,8 +23,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.click
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onFirst
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performCustomAccessibilityActionWithLabel
import androidx.compose.ui.test.performTouchInput
@@ -92,8 +91,7 @@ class ResizingTest : SysuiTestCase() {
        composeRule.waitForIdle()

        composeRule
            .onAllNodesWithText("tileA")
            .onFirst()
            .onNodeWithContentDescription("tileA")
            .performCustomAccessibilityActionWithLabel(
                context.getString(R.string.accessibility_qs_edit_toggle_tile_size_action)
            )
@@ -109,8 +107,7 @@ class ResizingTest : SysuiTestCase() {
        composeRule.waitForIdle()

        composeRule
            .onAllNodesWithText("tileD_large")
            .onFirst()
            .onNodeWithContentDescription("tileD_large")
            .performCustomAccessibilityActionWithLabel(
                context.getString(R.string.accessibility_qs_edit_toggle_tile_size_action)
            )
@@ -126,8 +123,7 @@ class ResizingTest : SysuiTestCase() {
        composeRule.waitForIdle()

        composeRule
            .onAllNodesWithText("tileA")
            .onFirst()
            .onNodeWithContentDescription("tileA")
            .performClick() // Select
            .performTouchInput { // Tap on resizing handle
                click(centerRight)
@@ -145,8 +141,7 @@ class ResizingTest : SysuiTestCase() {
        composeRule.waitForIdle()

        composeRule
            .onAllNodesWithText("tileD_large")
            .onFirst()
            .onNodeWithContentDescription("tileD_large")
            .performClick() // Select
            .performTouchInput { // Tap on resizing handle
                click(centerRight)
@@ -164,8 +159,7 @@ class ResizingTest : SysuiTestCase() {
        composeRule.waitForIdle()

        composeRule
            .onAllNodesWithText("tileA")
            .onFirst()
            .onNodeWithContentDescription("tileA")
            .performClick() // Select
            .performTouchInput { // Resize up
                swipeRight(startX = right, endX = right * 2)
@@ -183,8 +177,7 @@ class ResizingTest : SysuiTestCase() {
        composeRule.waitForIdle()

        composeRule
            .onAllNodesWithText("tileD_large")
            .onFirst()
            .onNodeWithContentDescription("tileD_large")
            .performClick() // Select
            .performTouchInput { // Resize down
                swipeLeft()