Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e78d74d2 authored by Xiaowen Lei's avatar Xiaowen Lei Committed by Automerger Merge Worker
Browse files

Merge "Don't set expansion for downward (upward) scroll when the bouncer is...

Merge "Don't set expansion for downward (upward) scroll when the bouncer is hidden (shown)." into tm-dev am: 81a5f75d am: 6294c4f2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17533603



Change-Id: I8078fe2ebda62f3c9ec5657c8601124a286f05ad
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 636897b9 6294c4f2
Loading
Loading
Loading
Loading
+12 −4
Original line number Original line Diff line number Diff line
@@ -117,15 +117,23 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
                        return false;
                        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
                    // For consistency, we adopt the expansion definition found in the
                    // PanelViewController. In this case, expansion refers to the view above the
                    // PanelViewController. In this case, expansion refers to the view above the
                    // bouncer. As that view's expansion shrinks, the bouncer appears. The bouncer
                    // 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
                    // is fully hidden at full expansion (1) and fully visible when fully collapsed
                    // (0).
                    // (0).
                    final float dy = mBouncerInitiallyShowing ? e2.getY() - e1.getY()
                    final float screenTravelPercentage = Math.abs(e1.getY() - e2.getY())
                            : e1.getY() - e2.getY();
                            / mCentralSurfaces.getDisplayHeight();
                    final float screenTravelPercentage = Math.max(0,
                            dy / mCentralSurfaces.getDisplayHeight());
                    setPanelExpansion(mBouncerInitiallyShowing
                    setPanelExpansion(mBouncerInitiallyShowing
                            ? screenTravelPercentage : 1 - screenTravelPercentage);
                            ? screenTravelPercentage : 1 - screenTravelPercentage);
                    return true;
                    return true;
+4 −16
Original line number Original line Diff line number Diff line
@@ -169,7 +169,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
     * Makes sure swiping up when bouncer initially showing doesn't change the expansion amount.
     * Makes sure swiping up when bouncer initially showing doesn't change the expansion amount.
     */
     */
    @Test
    @Test
    public void testSwipeUp_whenBouncerInitiallyShowing_keepsExpansionAtZero() {
    public void testSwipeUp_whenBouncerInitiallyShowing_doesNotSetExpansion() {
        when(mCentralSurfaces.isBouncerShowing()).thenReturn(true);
        when(mCentralSurfaces.isBouncerShowing()).thenReturn(true);


        mTouchHandler.onSessionStart(mTouchSession);
        mTouchHandler.onSessionStart(mTouchSession);
@@ -191,21 +191,15 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
        assertThat(gestureListener.onScroll(event1, event2, 0, distanceY))
        assertThat(gestureListener.onScroll(event1, event2, 0, distanceY))
                .isTrue();
                .isTrue();


        // Ensure only called once
        verify(mStatusBarKeyguardViewManager, never())
        verify(mStatusBarKeyguardViewManager)
                .onPanelExpansionChanged(anyFloat(), anyBoolean(), anyBoolean());
                .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.
     * Makes sure swiping down when bouncer initially hidden doesn't change the expansion amount.
     */
     */
    @Test
    @Test
    public void testSwipeDown_whenBouncerInitiallyHidden_keepsExpansionAtOne() {
    public void testSwipeDown_whenBouncerInitiallyHidden_doesNotSetExpansion() {
        mTouchHandler.onSessionStart(mTouchSession);
        mTouchHandler.onSessionStart(mTouchSession);
        ArgumentCaptor<GestureDetector.OnGestureListener> gestureListenerCaptor =
        ArgumentCaptor<GestureDetector.OnGestureListener> gestureListenerCaptor =
                ArgumentCaptor.forClass(GestureDetector.OnGestureListener.class);
                ArgumentCaptor.forClass(GestureDetector.OnGestureListener.class);
@@ -225,14 +219,8 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
        assertThat(gestureListener.onScroll(event1, event2, 0, distanceY))
        assertThat(gestureListener.onScroll(event1, event2, 0, distanceY))
                .isTrue();
                .isTrue();


        // Ensure only called once
        verify(mStatusBarKeyguardViewManager, never())
        verify(mStatusBarKeyguardViewManager)
                .onPanelExpansionChanged(anyFloat(), anyBoolean(), anyBoolean());
                .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));
    }
    }


    /**
    /**