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

Commit e21e136a authored by Bryce Lee's avatar Bryce Lee
Browse files

Add actions to outer CommunalTouchableSurface.

The glanceable hub sits within an outermost container, whose purpose is
to capture touch events, such as press and hold. This container
previously was part of the selection traversal, but did not expose any
actions of its own. To remedy this, the container was hidden from
accessibility. However, this introduced a regression with HSV where
the child elements were no longer traversed and did not appear in the
hierarchy.

To remedy this issue, this changelist makes the outer container once
again visible to accessibility and now surfaces the same actions as the
glanceable hub container (closing the hub and editing widgets). While
this does lead to some action redundancy, the actions do logically map
to this space.

Test: manual - ensured actions are present and hsv can read the
      hierarchy.
Flag: EXEMPT bugfix
Fixes: 385973993
Change-Id: I054e64c2406029f5b2ab21893bf4d0a959638e58
parent 68a2e190
Loading
Loading
Loading
Loading
+33 −5
Original line number Diff line number Diff line
@@ -27,9 +27,14 @@ import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.input.pointer.motionEventSpy
import androidx.compose.ui.semantics.hideFromAccessibility
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.semantics.CustomAccessibilityAction
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.customActions
import androidx.compose.ui.semantics.semantics
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.communal.ui.viewmodel.CommunalViewModel
import com.android.systemui.res.R

@OptIn(ExperimentalFoundationApi::class, ExperimentalComposeUiApi::class)
@Composable
@@ -38,15 +43,38 @@ fun CommunalTouchableSurface(
    modifier: Modifier = Modifier,
    content: @Composable BoxScope.() -> Unit,
) {

    val context = LocalContext.current
    val interactionSource = remember { MutableInteractionSource() }

    Box(
        modifier =
            modifier
                // The touchable surface is hidden for accessibility because these actions are
                // already provided through custom accessibility actions.
                .semantics { hideFromAccessibility() }
                .semantics {
                    contentDescription =
                        context.getString(
                            R.string.accessibility_content_description_for_communal_hub
                        )
                    customActions =
                        listOf(
                            CustomAccessibilityAction(
                                context.getString(
                                    R.string.accessibility_action_label_close_communal_hub
                                )
                            ) {
                                viewModel.changeScene(
                                    CommunalScenes.Blank,
                                    "closed by accessibility",
                                )
                                true
                            },
                            CustomAccessibilityAction(
                                context.getString(R.string.accessibility_action_label_edit_widgets)
                            ) {
                                viewModel.onOpenWidgetEditor()
                                true
                            },
                        )
                }
                .combinedClickable(
                    onLongClick = viewModel::onLongClick,
                    onClick = viewModel::onClick,