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

Commit 13b676ca authored by Prince Donkor's avatar Prince Donkor Committed by Android (Google) Code Review
Browse files

Merge "Talkback highlights selected widget in edit mode" into main

parents 8592e887 49ccb657
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ object AllElements : ElementMatcher {
    override fun matches(key: ElementKey, content: ContentKey) = true
}

private object TransitionDuration {
object TransitionDuration {
    const val BETWEEN_HUB_AND_EDIT_MODE_MS = 1000
    const val EDIT_MODE_TO_HUB_CONTENT_MS = 167
    const val EDIT_MODE_TO_HUB_GRID_DELAY_MS = 167
+15 −1
Original line number Diff line number Diff line
@@ -108,6 +108,8 @@ import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
@@ -179,6 +181,7 @@ import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView
import com.android.systemui.communal.widgets.WidgetConfigurator
import com.android.systemui.res.R
import com.android.systemui.statusbar.phone.SystemUIDialogFactory
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
@@ -1155,6 +1158,15 @@ private fun WidgetContent(
    val selectedIndex =
        selectedKey?.let { key -> contentListState.list.indexOfFirst { it.key == key } }

    val interactionSource = remember { MutableInteractionSource() }
    val focusRequester = remember { FocusRequester() }
    if (viewModel.isEditMode && selected) {
        LaunchedEffect(Unit) {
            delay(TransitionDuration.BETWEEN_HUB_AND_EDIT_MODE_MS.toLong())
            focusRequester.requestFocus()
        }
    }

    val isSelected = selectedKey == model.key

    val selectableModifier =
@@ -1162,7 +1174,7 @@ private fun WidgetContent(
            Modifier.selectable(
                selected = isSelected,
                onClick = { viewModel.setSelectedKey(model.key) },
                interactionSource = remember { MutableInteractionSource() },
                interactionSource = interactionSource,
                indication = null,
            )
        } else {
@@ -1172,6 +1184,8 @@ private fun WidgetContent(
    Box(
        modifier =
            modifier
                .focusRequester(focusRequester)
                .focusable(interactionSource = interactionSource)
                .then(selectableModifier)
                .thenIf(!viewModel.isEditMode && !model.inQuietMode) {
                    Modifier.pointerInput(Unit) {