diff options
| author | 2024-12-19 15:39:50 -0800 | |
|---|---|---|
| committer | 2024-12-19 15:39:50 -0800 | |
| commit | 87c5c79f8d56710fc683bbc7058403596cf349fd (patch) | |
| tree | 9660b55dadae9ebb1370118f3e249fb3a931d826 | |
| parent | 98d6afef9da0e4f65d6d6c3af40dbb98027112bc (diff) | |
Disable grid scroll when dragging a widget
Grid scrolling and widget dragging gestures can compete with each other
somtimes causing a widget drag to get cancelled. This change disables
user scrolling while dragging a widget. Programatic scrolling is still
allowed for dragging a widget beyond visual boundaries.
Test: manually tested that dragging a widget is more stable, and a drag
gesture does not get canceled once initiated. Also tested that
dragging a widget to the edges of the screen still causes the grid
to scroll.
Fix: 382355534
Flag: EXEMPT bug fix
Change-Id: Iae452a481ff20f96b57604dafad4600f101cdd4c
| -rw-r--r-- | packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt | 11 |
1 files changed, 11 insertions, 0 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 bf3360f0ea14..faf2d1d468c0 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 @@ -757,10 +757,12 @@ fun calculateWidgetSize( private fun HorizontalGridWrapper( minContentPadding: PaddingValues, gridState: LazyGridState, + dragDropState: GridDragDropState?, setContentOffset: (offset: Offset) -> Unit, modifier: Modifier = Modifier, content: LazyGridScope.(sizeInfo: SizeInfo?) -> Unit, ) { + val isDragging = dragDropState?.draggingItemKey != null if (communalResponsiveGrid()) { val flingBehavior = rememberSnapFlingBehavior(lazyGridState = gridState, snapPosition = SnapPosition.Start) @@ -773,6 +775,10 @@ private fun HorizontalGridWrapper( minHorizontalArrangement = Dimensions.ItemSpacing, minVerticalArrangement = Dimensions.ItemSpacing, setContentOffset = setContentOffset, + // Temporarily disable user gesture scrolling while dragging a widget to prevent + // conflicts between the drag and scroll gestures. Programmatic scrolling remains + // enabled to allow dragging a widget beyond the visible boundaries. + userScrollEnabled = !isDragging, content = content, ) } else { @@ -791,6 +797,10 @@ private fun HorizontalGridWrapper( contentPadding = minContentPadding, horizontalArrangement = Arrangement.spacedBy(Dimensions.ItemSpacing), verticalArrangement = Arrangement.spacedBy(Dimensions.ItemSpacing), + // Temporarily disable user gesture scrolling while dragging a widget to prevent + // conflicts between the drag and scroll gestures. Programmatic scrolling remains + // enabled to allow dragging a widget beyond the visible boundaries. + userScrollEnabled = !isDragging, ) { content(null) } @@ -860,6 +870,7 @@ private fun BoxScope.CommunalHubLazyGrid( HorizontalGridWrapper( modifier = gridModifier, gridState = gridState, + dragDropState = dragDropState, minContentPadding = minContentPadding, setContentOffset = setContentOffset, ) { sizeInfo -> |