diff options
| author | 2024-07-17 19:09:20 +0000 | |
|---|---|---|
| committer | 2024-07-17 19:09:20 +0000 | |
| commit | 81c8ae9d01628182ba57c6d2d0f7cf1b58a879da (patch) | |
| tree | 6dcdc6f435ef97e078ca6c422d9a106edfcb376e | |
| parent | 065d1d20db52943aabed106356ed67607dbf8001 (diff) | |
| parent | 7d4e539badb7673c2e9e8fa1e6fe5c909b5a09c8 (diff) | |
Merge "Added unselect widget accessibility action when in edit mode" into main
| -rw-r--r-- | packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt | 30 | ||||
| -rw-r--r-- | packages/SystemUI/res/values/strings.xml | 2 |
2 files changed, 20 insertions, 12 deletions
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 768e6533ac7d..1c02d3f7662b 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 @@ -969,6 +969,8 @@ private fun WidgetContent( val clickActionLabel = stringResource(R.string.accessibility_action_label_select_widget) val removeWidgetActionLabel = stringResource(R.string.accessibility_action_label_remove_widget) val placeWidgetActionLabel = stringResource(R.string.accessibility_action_label_place_widget) + val unselectWidgetActionLabel = + stringResource(R.string.accessibility_action_label_unselect_widget) val selectedKey by viewModel.selectedKey.collectAsStateWithLifecycle() val selectedIndex = selectedKey?.let { key -> contentListState.list.indexOfFirst { it.key == key } } @@ -1009,18 +1011,7 @@ private fun WidgetContent( contentListState.onSaveList() true } - val selectWidgetAction = - CustomAccessibilityAction(clickActionLabel) { - val currentWidgetKey = - index?.let { - keyAtIndexIfEditable(contentListState.list, index) - } - viewModel.setSelectedKey(currentWidgetKey) - true - } - - val actions = mutableListOf(selectWidgetAction, deleteAction) - + val actions = mutableListOf(deleteAction) if (selectedIndex != null && selectedIndex != index) { actions.add( CustomAccessibilityAction(placeWidgetActionLabel) { @@ -1032,6 +1023,21 @@ private fun WidgetContent( ) } + if (!selected) { + actions.add( + CustomAccessibilityAction(clickActionLabel) { + viewModel.setSelectedKey(model.key) + true + } + ) + } else { + actions.add( + CustomAccessibilityAction(unselectWidgetActionLabel) { + viewModel.setSelectedKey(null) + true + } + ) + } customActions = actions } } diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 7caa2c65c64a..be2850448ca5 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1258,6 +1258,8 @@ <string name="communal_widget_picker_title">Lock screen widgets</string> <!-- Text displayed below the title in the communal widget picker providing additional details about the communal surface. [CHAR LIMIT=80] --> <string name="communal_widget_picker_description">Anyone can view widgets on your lock screen, even if your tablet\'s locked.</string> + <!-- Label for accessibility action to unselect a widget in edit mode. [CHAR LIMIT=NONE] --> + <string name="accessibility_action_label_unselect_widget">unselect widget</string> <!-- Title shown above information regarding lock screen widgets. [CHAR LIMIT=50] --> <string name="communal_widgets_disclaimer_title">Lock screen widgets</string> <!-- Information about lock screen widgets presented to the user. [CHAR LIMIT=NONE] --> |