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

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

Merge "Added unselect widget accessibility action when in edit mode" into main

parents 065d1d20 7d4e539b
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -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
                    }
                }
+2 −0
Original line number Diff line number Diff line
@@ -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] -->