Loading packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +53 −1 Original line number Diff line number Diff line Loading @@ -469,6 +469,8 @@ private fun BoxScope.CommunalHubLazyGrid( size = size, selected = selected && !isDragging, widgetConfigurator = widgetConfigurator, index = index, contentListState = contentListState ) } } else { Loading @@ -478,6 +480,8 @@ private fun BoxScope.CommunalHubLazyGrid( viewModel = viewModel, size = size, selected = false, index = index, contentListState = contentListState ) } } Loading Loading @@ -782,10 +786,21 @@ private fun CommunalContent( selected: Boolean, modifier: Modifier = Modifier, widgetConfigurator: WidgetConfigurator? = null, index: Int, contentListState: ContentListState, ) { when (model) { is CommunalContentModel.WidgetContent.Widget -> WidgetContent(viewModel, model, size, selected, widgetConfigurator, modifier) WidgetContent( viewModel, model, size, selected, widgetConfigurator, modifier, index, contentListState ) is CommunalContentModel.WidgetPlaceholder -> HighlightedItem(modifier) is CommunalContentModel.WidgetContent.DisabledWidget -> DisabledWidgetPlaceholder(model, viewModel, modifier) Loading Loading @@ -883,6 +898,8 @@ private fun WidgetContent( selected: Boolean, widgetConfigurator: WidgetConfigurator?, modifier: Modifier = Modifier, index: Int, contentListState: ContentListState, ) { val context = LocalContext.current val isFocusable by viewModel.isFocusable.collectAsState(initial = false) Loading @@ -891,6 +908,11 @@ private fun WidgetContent( model.providerInfo.loadLabel(context.packageManager).toString().trim() } 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 selectedKey by viewModel.selectedKey.collectAsState() val selectedIndex = selectedKey?.let { key -> contentListState.list.indexOfFirst { it.key == key } } Box( modifier = modifier Loading @@ -907,6 +929,36 @@ private fun WidgetContent( Modifier.semantics { contentDescription = accessibilityLabel onClick(label = clickActionLabel, action = null) val deleteAction = CustomAccessibilityAction(removeWidgetActionLabel) { contentListState.onRemove(index) contentListState.onSaveList() true } val selectWidgetAction = CustomAccessibilityAction(clickActionLabel) { val currentWidgetKey = index?.let { keyAtIndexIfEditable(contentListState.list, index) } viewModel.setSelectedKey(currentWidgetKey) true } val actions = mutableListOf(deleteAction, selectWidgetAction) if (selectedIndex != null && selectedIndex != index) { actions.add( CustomAccessibilityAction(placeWidgetActionLabel) { contentListState.onMove(selectedIndex!!, index) contentListState.onSaveList() viewModel.setSelectedKey(null) true } ) } customActions = actions } } ) { Loading packages/SystemUI/res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -1186,6 +1186,10 @@ <string name="accessibility_content_description_for_communal_hub">Widgets on lock screen</string> <!-- Label for accessibility action to select a widget in edit mode. [CHAR LIMIT=NONE] --> <string name="accessibility_action_label_select_widget">select widget</string> <!-- Label for accessibility action to remove a widget in edit mode. [CHAR LIMIT=NONE] --> <string name="accessibility_action_label_remove_widget">remove widget</string> <!-- Label for accessibility action to place a widget in edit mode after selecting move widget. [CHAR LIMIT=NONE] --> <string name="accessibility_action_label_place_widget">place selected widget</string> <!-- Related to user switcher --><skip/> Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +53 −1 Original line number Diff line number Diff line Loading @@ -469,6 +469,8 @@ private fun BoxScope.CommunalHubLazyGrid( size = size, selected = selected && !isDragging, widgetConfigurator = widgetConfigurator, index = index, contentListState = contentListState ) } } else { Loading @@ -478,6 +480,8 @@ private fun BoxScope.CommunalHubLazyGrid( viewModel = viewModel, size = size, selected = false, index = index, contentListState = contentListState ) } } Loading Loading @@ -782,10 +786,21 @@ private fun CommunalContent( selected: Boolean, modifier: Modifier = Modifier, widgetConfigurator: WidgetConfigurator? = null, index: Int, contentListState: ContentListState, ) { when (model) { is CommunalContentModel.WidgetContent.Widget -> WidgetContent(viewModel, model, size, selected, widgetConfigurator, modifier) WidgetContent( viewModel, model, size, selected, widgetConfigurator, modifier, index, contentListState ) is CommunalContentModel.WidgetPlaceholder -> HighlightedItem(modifier) is CommunalContentModel.WidgetContent.DisabledWidget -> DisabledWidgetPlaceholder(model, viewModel, modifier) Loading Loading @@ -883,6 +898,8 @@ private fun WidgetContent( selected: Boolean, widgetConfigurator: WidgetConfigurator?, modifier: Modifier = Modifier, index: Int, contentListState: ContentListState, ) { val context = LocalContext.current val isFocusable by viewModel.isFocusable.collectAsState(initial = false) Loading @@ -891,6 +908,11 @@ private fun WidgetContent( model.providerInfo.loadLabel(context.packageManager).toString().trim() } 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 selectedKey by viewModel.selectedKey.collectAsState() val selectedIndex = selectedKey?.let { key -> contentListState.list.indexOfFirst { it.key == key } } Box( modifier = modifier Loading @@ -907,6 +929,36 @@ private fun WidgetContent( Modifier.semantics { contentDescription = accessibilityLabel onClick(label = clickActionLabel, action = null) val deleteAction = CustomAccessibilityAction(removeWidgetActionLabel) { contentListState.onRemove(index) contentListState.onSaveList() true } val selectWidgetAction = CustomAccessibilityAction(clickActionLabel) { val currentWidgetKey = index?.let { keyAtIndexIfEditable(contentListState.list, index) } viewModel.setSelectedKey(currentWidgetKey) true } val actions = mutableListOf(deleteAction, selectWidgetAction) if (selectedIndex != null && selectedIndex != index) { actions.add( CustomAccessibilityAction(placeWidgetActionLabel) { contentListState.onMove(selectedIndex!!, index) contentListState.onSaveList() viewModel.setSelectedKey(null) true } ) } customActions = actions } } ) { Loading
packages/SystemUI/res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -1186,6 +1186,10 @@ <string name="accessibility_content_description_for_communal_hub">Widgets on lock screen</string> <!-- Label for accessibility action to select a widget in edit mode. [CHAR LIMIT=NONE] --> <string name="accessibility_action_label_select_widget">select widget</string> <!-- Label for accessibility action to remove a widget in edit mode. [CHAR LIMIT=NONE] --> <string name="accessibility_action_label_remove_widget">remove widget</string> <!-- Label for accessibility action to place a widget in edit mode after selecting move widget. [CHAR LIMIT=NONE] --> <string name="accessibility_action_label_place_widget">place selected widget</string> <!-- Related to user switcher --><skip/> Loading