diff options
| author | 2022-04-04 16:11:37 +0000 | |
|---|---|---|
| committer | 2022-04-04 16:11:37 +0000 | |
| commit | 81a5f75d0fe4b1b1d45ce7473af6f3092faec8a6 (patch) | |
| tree | ee4dfeeb426f921f3ca24f2b1ab577c0640c3e1a | |
| parent | 3c984e8bf5b881de13534e132c142ca9d56a1535 (diff) | |
| parent | a6209a69b72c571db981f369e7e8f07a956e01b9 (diff) | |
Merge "Don't set expansion for downward (upward) scroll when the bouncer is hidden (shown)." into tm-dev
2 files changed, 16 insertions, 20 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java index 5c99cd1b8722..990f04b58f95 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java @@ -117,15 +117,23 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { return false; } + // Don't set expansion for downward scroll when the bouncer is hidden. + if (!mBouncerInitiallyShowing && (e1.getY() < e2.getY())) { + return true; + } + + // Don't set expansion for upward scroll when the bouncer is shown. + if (mBouncerInitiallyShowing && (e1.getY() > e2.getY())) { + return true; + } + // For consistency, we adopt the expansion definition found in the // PanelViewController. In this case, expansion refers to the view above the // bouncer. As that view's expansion shrinks, the bouncer appears. The bouncer // is fully hidden at full expansion (1) and fully visible when fully collapsed // (0). - final float dy = mBouncerInitiallyShowing ? e2.getY() - e1.getY() - : e1.getY() - e2.getY(); - final float screenTravelPercentage = Math.max(0, - dy / mCentralSurfaces.getDisplayHeight()); + final float screenTravelPercentage = Math.abs(e1.getY() - e2.getY()) + / mCentralSurfaces.getDisplayHeight(); setPanelExpansion(mBouncerInitiallyShowing ? screenTravelPercentage : 1 - screenTravelPercentage); return true; diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java index 74cf49758ac6..a016a1d8ca70 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java @@ -169,7 +169,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { * Makes sure swiping up when bouncer initially showing doesn't change the expansion amount. */ @Test - public void testSwipeUp_whenBouncerInitiallyShowing_keepsExpansionAtZero() { + public void testSwipeUp_whenBouncerInitiallyShowing_doesNotSetExpansion() { when(mCentralSurfaces.isBouncerShowing()).thenReturn(true); mTouchHandler.onSessionStart(mTouchSession); @@ -191,21 +191,15 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { assertThat(gestureListener.onScroll(event1, event2, 0, distanceY)) .isTrue(); - // Ensure only called once - verify(mStatusBarKeyguardViewManager) + verify(mStatusBarKeyguardViewManager, never()) .onPanelExpansionChanged(anyFloat(), anyBoolean(), anyBoolean()); - - // TODO(b/227348372): update the logic and also this test. - // Ensure the expansion is kept at 0. - verify(mStatusBarKeyguardViewManager).onPanelExpansionChanged(eq(0f), eq(false), - eq(true)); } /** * Makes sure swiping down when bouncer initially hidden doesn't change the expansion amount. */ @Test - public void testSwipeDown_whenBouncerInitiallyHidden_keepsExpansionAtOne() { + public void testSwipeDown_whenBouncerInitiallyHidden_doesNotSetExpansion() { mTouchHandler.onSessionStart(mTouchSession); ArgumentCaptor<GestureDetector.OnGestureListener> gestureListenerCaptor = ArgumentCaptor.forClass(GestureDetector.OnGestureListener.class); @@ -225,14 +219,8 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { assertThat(gestureListener.onScroll(event1, event2, 0, distanceY)) .isTrue(); - // Ensure only called once - verify(mStatusBarKeyguardViewManager) + verify(mStatusBarKeyguardViewManager, never()) .onPanelExpansionChanged(anyFloat(), anyBoolean(), anyBoolean()); - - // TODO(b/227348372): update the logic and also this test. - // Ensure the expansion is kept at 1. - verify(mStatusBarKeyguardViewManager).onPanelExpansionChanged(eq(1f), eq(false), - eq(true)); } /** |