summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Prince Donkor <princedonkor@google.com> 2024-09-13 14:34:34 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-09-13 14:34:34 +0000
commit13b676ca5a48f0c757ed770576dde2af42b96e9f (patch)
tree7a727a0cac7e9240cd08410edda227767494ef4b
parent8592e887d3ace8dd18282a2d3b86f1426001fe0d (diff)
parent49ccb6579255eed677c209cf9a88f395b1fb855d (diff)
Merge "Talkback highlights selected widget in edit mode" into main
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt2
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt16
2 files changed, 16 insertions, 2 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
index a4dc8fc565f6..557257d6bdc0 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
@@ -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
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
index efe0f2e815da..f4d1242098f9 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
@@ -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) {