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

Commit 7d4e539b authored by Prince's avatar Prince
Browse files

Added unselect widget accessibility action when in edit mode

Fixes: 347652518
Test: Device Tested
Flag: NONE Accessibility fix
Change-Id: Icdbbddc85f0cbb125208a70b324417a402dd79fb
parent 3a93b970
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
@@ -1249,6 +1249,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] -->