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

Commit 49eebda3 authored by tom hsu's avatar tom hsu Committed by Tom Hsu
Browse files

[SPA] Fix GTS failed problem.

 - clearAndSetSemantics cause uiautomater show the UI component to a
   View only. In this case, TextView set this function, so uiautomater
   identify this be a android.view.View but not a TextView.
 - Group Icon and Text to make it be clickable.

Flag: EXEMPT bug fix
Bug: b/416311339
Test: Manual test
Change-Id: I8171a83da8268a254b35f5b9686b9b540bc2eb88
parent 34ddbf7f
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.settingslib.spa.widget.button

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -104,15 +105,16 @@ fun ActionButtons(actionButtons: List<ActionButton>) {
private fun RowScope.ActionButton(actionButton: ActionButton) {
    if (isSpaExpressiveEnabled) {
        Column(
            horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier
            horizontalAlignment = Alignment.CenterHorizontally,
            modifier = Modifier
                .weight(1f)
                .clickable(onClick = actionButton.onClick)
        ) {
            IconButton(actionButton)
            Spacer(Modifier.height(SettingsSpace.extraSmall3))
            Text(
                text = actionButton.text,
                modifier = Modifier
                    .clearAndSetSemantics {} // semantics set in IconButton
                    .padding(horizontal = SettingsSpace.extraSmall4),
                style = MaterialTheme.typography.titleSmallEmphasized,
                textAlign = TextAlign.Center,
@@ -171,7 +173,8 @@ private fun IconButton(actionButton: ActionButton) {
                    IconButtonDefaults.mediumContainerSize(
                        IconButtonDefaults.IconButtonWidthOption.Wide
                    )
                ),
                )
                .clearAndSetSemantics {}, // semantics set in IconButton
        enabled = actionButton.enabled,
        // Because buttons could appear, disappear or change positions, reset the interaction source
        // to prevent highlight the wrong button.