diff options
| author | 2024-09-10 12:45:52 +0000 | |
|---|---|---|
| committer | 2024-09-10 12:45:52 +0000 | |
| commit | 78794fbb3d26c76b5e0cee474787d25f1ea9b086 (patch) | |
| tree | 43e5eb475cabc1849cac7191dce991c02f921ebb | |
| parent | 82fc526cf8d16fc90381b15346f37505454ea6c6 (diff) | |
| parent | 16afc6f456afc8b90b2e4e44c873bad63b083cd6 (diff) | |
Merge "Arrow down navigates from search bar in shortcut helper" into main
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt index 63f3d52b2d2d..dcca12f29287 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt +++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt @@ -82,6 +82,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.drawWithContent +import androidx.compose.ui.focus.FocusDirection import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.geometry.CornerRadius @@ -92,8 +93,12 @@ import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.drawscope.Stroke import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.input.key.Key +import androidx.compose.ui.input.key.key +import androidx.compose.ui.input.key.onKeyEvent import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.rememberNestedScrollInteropConnection import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -824,9 +829,18 @@ private fun ShortcutsSearchBar(onQueryChange: (String) -> Unit) { // from the ViewModel. var queryInternal by remember { mutableStateOf("") } val focusRequester = remember { FocusRequester() } + val focusManager = LocalFocusManager.current LaunchedEffect(Unit) { focusRequester.requestFocus() } SearchBar( - modifier = Modifier.fillMaxWidth().focusRequester(focusRequester), + modifier = + Modifier.fillMaxWidth().focusRequester(focusRequester).onKeyEvent { + if (it.key == Key.DirectionDown) { + focusManager.moveFocus(FocusDirection.Down) + return@onKeyEvent true + } else { + return@onKeyEvent false + } + }, colors = SearchBarDefaults.colors(containerColor = MaterialTheme.colorScheme.surfaceBright), query = queryInternal, active = false, |