diff options
| author | 2025-03-17 17:42:27 -0700 | |
|---|---|---|
| committer | 2025-03-17 17:42:27 -0700 | |
| commit | f77b0177fb28816aad0c43c4553f3fb78aa93740 (patch) | |
| tree | 1d6568b8f690073fb642167e8e7f65e96274125d | |
| parent | e4dd14c7efaa9e77c944583a0f2a58bfbccc18ab (diff) | |
[flexiglass] Don't expand other dual shade when swiping in this one
Bug was that swiping down, on the other half of an overlay would expand
the other overlay. This was because the user actions were bound to the
left/right half. Instead, they should be bound to the right/left half of
the top edge.
Fix: 402375503
Test: verified manually by swiping down from the status bar or from the
middle, on either side (left/right) in both gone and lockscreen with or
without either overlay being expanded
Flag: com.android.systemui.scene_container
Change-Id: I6a08f49817a69fba52707a23c3fe3fa48cee63a1
7 files changed, 55 insertions, 12 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModelTest.kt index 74906749a1c6..7fb66ce21919 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModelTest.kt @@ -76,7 +76,7 @@ class NotificationsShadeOverlayActionsViewModelTest : SysuiTestCase() { underTest.activateIn(this) val action = - (actions?.get(Swipe.Down(fromSource = SceneContainerArea.EndHalf)) + (actions?.get(Swipe.Down(fromSource = SceneContainerArea.TopEdgeEndHalf)) as? ReplaceByOverlay) assertThat(action?.overlay).isEqualTo(Overlays.QuickSettingsShade) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModelTest.kt index 0207a30572e4..882d296d94b4 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModelTest.kt @@ -89,7 +89,7 @@ class QuickSettingsShadeOverlayActionsViewModelTest : SysuiTestCase() { underTest.activateIn(this) val action = - (actions?.get(Swipe.Down(fromSource = SceneContainerArea.StartHalf)) + (actions?.get(Swipe.Down(fromSource = SceneContainerArea.TopEdgeStartHalf)) as? ReplaceByOverlay) assertThat(action?.overlay).isEqualTo(Overlays.NotificationsShade) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerSwipeDetectorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerSwipeDetectorTest.kt index a09e5cd9de9b..7536bb3cc02a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerSwipeDetectorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerSwipeDetectorTest.kt @@ -32,6 +32,8 @@ import com.android.systemui.scene.ui.viewmodel.SceneContainerArea.Resolved.LeftE import com.android.systemui.scene.ui.viewmodel.SceneContainerArea.Resolved.LeftHalf import com.android.systemui.scene.ui.viewmodel.SceneContainerArea.Resolved.RightEdge import com.android.systemui.scene.ui.viewmodel.SceneContainerArea.Resolved.RightHalf +import com.android.systemui.scene.ui.viewmodel.SceneContainerArea.Resolved.TopEdgeLeftHalf +import com.android.systemui.scene.ui.viewmodel.SceneContainerArea.Resolved.TopEdgeRightHalf import com.android.systemui.scene.ui.viewmodel.SceneContainerArea.StartEdge import com.android.systemui.scene.ui.viewmodel.SceneContainerArea.StartHalf import com.google.common.truth.Truth.assertThat @@ -55,9 +57,9 @@ class SceneContainerSwipeDetectorTest : SysuiTestCase() { } @Test - fun source_swipeVerticallyOnTopLeft_detectsLeftHalf() { + fun source_swipeVerticallyOnTopLeft_detectsTopEdgeLeftHalf() { val detectedEdge = swipeVerticallyFrom(x = 1, y = edgeSize - 1) - assertThat(detectedEdge).isEqualTo(LeftHalf) + assertThat(detectedEdge).isEqualTo(TopEdgeLeftHalf) } @Test @@ -69,7 +71,7 @@ class SceneContainerSwipeDetectorTest : SysuiTestCase() { @Test fun source_swipeVerticallyOnTopRight_detectsRightHalf() { val detectedEdge = swipeVerticallyFrom(x = screenWidth - 1, y = edgeSize - 1) - assertThat(detectedEdge).isEqualTo(RightHalf) + assertThat(detectedEdge).isEqualTo(TopEdgeRightHalf) } @Test @@ -79,14 +81,26 @@ class SceneContainerSwipeDetectorTest : SysuiTestCase() { } @Test - fun source_swipeVerticallyToLeftOfSplit_detectsLeftHalf() { + fun source_swipeVerticallyOnTopEdge_ToLeftOfSplit_detectsTopEdgeLeftHalf() { val detectedEdge = swipeVerticallyFrom(x = (screenWidth / 2) - 1, y = edgeSize - 1) + assertThat(detectedEdge).isEqualTo(TopEdgeLeftHalf) + } + + @Test + fun source_swipeVerticallyBelowTopEdge_ToLeftOfSplit_detectsLeftHalf() { + val detectedEdge = swipeVerticallyFrom(x = (screenWidth / 2) - 1, y = edgeSize + 1) assertThat(detectedEdge).isEqualTo(LeftHalf) } @Test - fun source_swipeVerticallyToRightOfSplit_detectsRightHalf() { + fun source_swipeVerticallyOnTopEdge_toRightOfSplit_detectsTopEdgeRightHalf() { val detectedEdge = swipeVerticallyFrom(x = (screenWidth / 2) + 1, y = edgeSize - 1) + assertThat(detectedEdge).isEqualTo(TopEdgeRightHalf) + } + + @Test + fun source_swipeVerticallyBelowTopEdge_toRightOfSplit_detectsRightHalf() { + val detectedEdge = swipeVerticallyFrom(x = (screenWidth / 2) + 1, y = edgeSize + 1) assertThat(detectedEdge).isEqualTo(RightHalf) } diff --git a/packages/SystemUI/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModel.kt b/packages/SystemUI/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModel.kt index cc1170285d6c..0a5222e3df44 100644 --- a/packages/SystemUI/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/notifications/ui/viewmodel/NotificationsShadeOverlayActionsViewModel.kt @@ -37,7 +37,7 @@ class NotificationsShadeOverlayActionsViewModel @AssistedInject constructor() : mapOf( Swipe.Up to HideOverlay(Overlays.NotificationsShade), Back to HideOverlay(Overlays.NotificationsShade), - Swipe.Down(fromSource = SceneContainerArea.EndHalf) to + Swipe.Down(fromSource = SceneContainerArea.TopEdgeEndHalf) to ReplaceByOverlay(Overlays.QuickSettingsShade), ) ) diff --git a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModel.kt index c86454ed7a1f..2f7bc0992411 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsShadeOverlayActionsViewModel.kt @@ -46,7 +46,7 @@ constructor(private val editModeViewModel: EditModeViewModel) : UserActionsViewM put(Back, HideOverlay(Overlays.QuickSettingsShade)) } put( - Swipe.Down(fromSource = SceneContainerArea.StartHalf), + Swipe.Down(fromSource = SceneContainerArea.TopEdgeStartHalf), ReplaceByOverlay(Overlays.NotificationsShade), ) } diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerSwipeDetector.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerSwipeDetector.kt index ede453dbe6b3..760b97e6245b 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerSwipeDetector.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerSwipeDetector.kt @@ -58,6 +58,22 @@ sealed class SceneContainerArea(private val resolveArea: (LayoutDirection) -> Re } ) + data object TopEdgeStartHalf : + SceneContainerArea( + resolveArea = { + if (it == LayoutDirection.Ltr) Resolved.TopEdgeLeftHalf + else Resolved.TopEdgeRightHalf + } + ) + + data object TopEdgeEndHalf : + SceneContainerArea( + resolveArea = { + if (it == LayoutDirection.Ltr) Resolved.TopEdgeRightHalf + else Resolved.TopEdgeLeftHalf + } + ) + override fun resolve(layoutDirection: LayoutDirection): Resolved { return resolveArea(layoutDirection) } @@ -72,6 +88,12 @@ sealed class SceneContainerArea(private val resolveArea: (LayoutDirection) -> Re data object RightEdge : Resolved data object RightHalf : Resolved + + /** The left half of the top edge of the display. */ + data object TopEdgeLeftHalf : Resolved + + /** The right half of the top edge of the display. */ + data object TopEdgeRightHalf : Resolved } } @@ -108,9 +130,14 @@ class SceneContainerSwipeDetector(val edgeSize: Dp) : SwipeSourceDetector { Edge.Resolved.Left -> SceneContainerArea.Resolved.LeftEdge Edge.Resolved.Bottom -> SceneContainerArea.Resolved.BottomEdge Edge.Resolved.Right -> SceneContainerArea.Resolved.RightEdge - else -> { - // Note: This intentionally includes Edge.Resolved.Top. At the moment, we don't need - // to detect swipes on the top edge, and consider them part of the right/left half. + Edge.Resolved.Top -> { + if (position.x < layoutSize.width * 0.5f) { + SceneContainerArea.Resolved.TopEdgeLeftHalf + } else { + SceneContainerArea.Resolved.TopEdgeRightHalf + } + } + null -> { if (position.x < layoutSize.width * 0.5f) { SceneContainerArea.Resolved.LeftHalf } else { diff --git a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActions.kt b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActions.kt index cf3b08c041be..8d2d9efb56eb 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActions.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeUserActions.kt @@ -71,6 +71,8 @@ fun dualShadeActions(): Array<Pair<UserAction, UserActionResult>> { Swipe.Down to ShowOverlay(Overlays.NotificationsShade), Swipe.Down(fromSource = SceneContainerArea.EndHalf) to ShowOverlay(Overlays.QuickSettingsShade), + Swipe.Down(fromSource = SceneContainerArea.TopEdgeEndHalf) to + ShowOverlay(Overlays.QuickSettingsShade), ) } |