diff options
| author | 2024-12-09 14:38:24 -0800 | |
|---|---|---|
| committer | 2024-12-11 23:48:00 +0000 | |
| commit | efd8239c1f07ff8fce3453e233548682cb47072e (patch) | |
| tree | c55ba78804e5d7230ee8398be6246e0c3b3587e7 | |
| parent | 9a81b7d2af54ce96e81f95850ec35c50246e95b7 (diff) | |
Adjust edit mode selection behavior.
This changelist updates the edit mode selection behavior with the
following changes:
- Widgets can be unselected by tapping the widget again. Previously,
clearing selection required tapping a blank spot.
- Remove/Add Widgets buttons are mutually exclusive and are never shown
at the same time.
Fixes: 383160667
Test: manual - verified new touch and layout changes.
Flag: com.android.systemui.hub_edit_mode_touch_adjustments
Change-Id: Idab26de851f9110f14196866ad073ad08519f204
| -rw-r--r-- | packages/SystemUI/aconfig/systemui.aconfig | 7 | ||||
| -rw-r--r-- | packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt | 46 |
2 files changed, 42 insertions, 11 deletions
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig index 777f6d35c1de..8cfae2bcc547 100644 --- a/packages/SystemUI/aconfig/systemui.aconfig +++ b/packages/SystemUI/aconfig/systemui.aconfig @@ -1871,6 +1871,13 @@ flag { } flag { + name: "hub_edit_mode_touch_adjustments" + namespace: "systemui" + description: "Makes selected widget toggleable in edit mode and modifier buttons mutually exclusive." + bug: "383160667" +} + +flag { name: "glanceable_hub_direct_edit_mode" namespace: "systemui" description: "Invokes edit mode directly from long press in glanceable hub" 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 315dc342dcd0..d5eaf829b746 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 @@ -296,9 +296,19 @@ fun CommunalHub( offset.y, ) - contentOffset val index = firstIndexAtOffset(gridState, adjustedOffset) - val key = + val tappedKey = index?.let { keyAtIndexIfEditable(contentListState.list, index) } - viewModel.setSelectedKey(key) + + viewModel.setSelectedKey( + if ( + Flags.hubEditModeTouchAdjustments() && + selectedKey.value == tappedKey + ) { + null + } else { + tappedKey + } + ) } } } @@ -1080,17 +1090,27 @@ private fun Toolbar( .onSizeChanged { setToolbarSize(it) } ) { val addWidgetText = stringResource(R.string.hub_mode_add_widget_button_text) - ToolbarButton( - isPrimary = !removeEnabled, - modifier = Modifier.align(Alignment.CenterStart), - onClick = onOpenWidgetPicker, - ) { - Icon(Icons.Default.Add, null) - Text(text = addWidgetText) + + if (!(Flags.hubEditModeTouchAdjustments() && removeEnabled)) { + ToolbarButton( + isPrimary = !removeEnabled, + modifier = Modifier.align(Alignment.CenterStart), + onClick = onOpenWidgetPicker, + ) { + Icon(Icons.Default.Add, null) + Text(text = addWidgetText) + } } AnimatedVisibility( - modifier = Modifier.align(Alignment.Center), + modifier = + Modifier.align( + if (Flags.hubEditModeTouchAdjustments()) { + Alignment.CenterStart + } else { + Alignment.Center + } + ), visible = removeEnabled, enter = fadeIn(), exit = fadeOut(), @@ -1113,7 +1133,11 @@ private fun Toolbar( horizontalArrangement = Arrangement.spacedBy( ButtonDefaults.IconSpacing, - Alignment.CenterHorizontally, + if (Flags.hubEditModeTouchAdjustments()) { + Alignment.Start + } else { + Alignment.CenterHorizontally + }, ), verticalAlignment = Alignment.CenterVertically, ) { |