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

Commit 6d560070 authored by Prince's avatar Prince
Browse files

Talkback focus on Customize Widget button when on screen

Test: Device tested
Fixes: 346905922
Flag: NONE Small Accessibility Fix
Change-Id: I4caeb9e4fee7be26a865725f72cb3aab836f0c16
parent 78f735a9
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.focusable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
@@ -39,11 +41,16 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
@@ -54,6 +61,7 @@ import com.android.systemui.communal.ui.viewmodel.CommunalViewModel
import com.android.systemui.communal.ui.viewmodel.PopupType
import com.android.systemui.res.R
import javax.inject.Inject
import kotlinx.coroutines.delay

class CommunalPopupSection
@Inject
@@ -91,6 +99,17 @@ constructor(
        onClick: () -> Unit,
        onDismissRequest: () -> Unit,
    ) {
        val interactionSource = remember { MutableInteractionSource() }
        val focusRequester = remember { FocusRequester() }

        val context = LocalContext.current

        LaunchedEffect(Unit) {
            // Adding a delay to ensure the animation completes before requesting focus
            delay(250)
            focusRequester.requestFocus()
        }

        Popup(
            alignment = Alignment.TopCenter,
            offset = IntOffset(0, 40),
@@ -100,6 +119,8 @@ constructor(
            Button(
                modifier =
                    Modifier.height(56.dp)
                        .focusRequester(focusRequester)
                        .focusable(interactionSource = interactionSource)
                        .graphicsLayer { transformOrigin = TransformOrigin(0f, 0f) }
                        .animateEnterExit(
                            enter =
@@ -142,8 +163,7 @@ constructor(
                ) {
                    Icon(
                        imageVector = Icons.Outlined.Widgets,
                        contentDescription =
                            stringResource(R.string.button_to_configure_widgets_text),
                        contentDescription = null,
                        tint = colors.onSecondary,
                        modifier = Modifier.size(20.dp)
                    )