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

Commit bde7058b authored by Yuri Lin's avatar Yuri Lin
Browse files

Add semantics actions to BundleHeader.

This adds the handling for dismiss, expand, and collapse actions at the level of the BundleHeader node, which is the one that gets focus in the accessibility tree. It was previously inheriting its actions from the ExpandableNotificationRow, which meant that the actions were available but not being announced.

Fixes: 424345757
Bug: 425559441
Test: manual by selecting the bundle header using talkback and confirming available actions and dismiss/expand/collapse behavior
Flag: com.android.systemui.notification_bundle_ui
Change-Id: I7128960ce4199670b8be3f08ed286485e9196894
parent 9b466783
Loading
Loading
Loading
Loading
+31 −7
Original line number Diff line number Diff line
@@ -45,6 +45,10 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.collapse
import androidx.compose.ui.semantics.dismiss
import androidx.compose.ui.semantics.expand
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.constrainHeight
@@ -87,6 +91,7 @@ fun BundleHeader(
    modifier: Modifier = Modifier,
    onHeaderClicked: () -> Unit = {},
    onHeaderLongClicked: () -> Unit = {},
    onA11yDismissAction: () -> Unit = {}, // only for dismissing via accessibility action
) {
    val state =
        rememberMutableSceneTransitionLayoutState(
@@ -137,18 +142,37 @@ fun BundleHeader(

    Box(modifier) {
        Background(background = viewModel.backgroundDrawable, modifier = Modifier.matchParentSize())
        fun toggle() {
            viewModel.onHeaderClicked()
            onHeaderClicked()
        }
        SceneTransitionLayout(
            state = state,
            modifier =
                Modifier.combinedClickable(
                    onClick = {
                        viewModel.onHeaderClicked()
                        onHeaderClicked()
                    },
                        onClick = { toggle() },
                        onLongClick = { onHeaderLongClicked() },
                        interactionSource = null,
                        indication = null,
                ),
                    )
                    .semantics {
                        when (state.currentScene) {
                            BundleHeader.Scenes.Collapsed ->
                                expand {
                                    toggle()
                                    true
                                }
                            BundleHeader.Scenes.Expanded ->
                                collapse {
                                    toggle()
                                    true
                                }
                        }
                        dismiss {
                            onA11yDismissAction()
                            true
                        }
                    },
        ) {
            scene(BundleHeader.Scenes.Collapsed) {
                BundleHeaderContent(viewModel, collapsed = true)
+2 −0
Original line number Diff line number Diff line
@@ -180,6 +180,8 @@ private fun HeaderComposeViewContent(
            viewModel,
            onHeaderClicked = { row.expandNotification() },
            onHeaderLongClicked = { row.performLongClick() },
            // to be used only for dismissal coming from an accessibility action.
            onA11yDismissAction = { row.performDismiss(true) },
        )
    }
}