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

Commit c1b6dc9e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do directional swipes even on edge if no edge action assigned"

parents 05ab573f 95dd764d
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -296,13 +296,15 @@ public class QuickStepController implements GestureHelper {
                    } else if (exceededSwipeHorizontalTouchSlop) {
                        if (mDragHPositive ? (posH < touchDownH) : (posH > touchDownH)) {
                            // Swiping left (rtl) gesture
                            int index = isEdgeSwipeAlongNavBar(touchDownH, !mDragHPositive)
                            int index = mGestureActions[ACTION_SWIPE_LEFT_FROM_EDGE_INDEX] != null
                                        && isEdgeSwipeAlongNavBar(touchDownH, !mDragHPositive)
                                    ? ACTION_SWIPE_LEFT_FROM_EDGE_INDEX : ACTION_SWIPE_LEFT_INDEX;
                            tryToStartGesture(mGestureActions[index], true /* alignedWithNavBar */,
                                    event);
                        } else {
                            // Swiping right (ltr) gesture
                            int index = isEdgeSwipeAlongNavBar(touchDownH, mDragHPositive)
                            int index = mGestureActions[ACTION_SWIPE_RIGHT_FROM_EDGE_INDEX] != null
                                        && isEdgeSwipeAlongNavBar(touchDownH, mDragHPositive)
                                    ? ACTION_SWIPE_RIGHT_FROM_EDGE_INDEX : ACTION_SWIPE_RIGHT_INDEX;
                            tryToStartGesture(mGestureActions[index], true /* alignedWithNavBar */,
                                    event);
+19 −1
Original line number Diff line number Diff line
@@ -601,6 +601,25 @@ public class QuickStepControllerTest extends SysuiTestCase {
        assertGestureDragsHitTargetAllDirections(buttonView, true /* isRTL */, NAV_BAR_LEFT);
    }

    @Test
    public void testNoEdgeActionsTriggerNormalActions() {
        doReturn(NAVBAR_WIDTH).when(mNavigationBarView).getWidth();
        doReturn(NAVBAR_HEIGHT).when(mNavigationBarView).getHeight();

        NavigationGestureAction swipeUp = mockAction(true);
        NavigationGestureAction swipeDown = mockAction(true);
        NavigationGestureAction swipeLeft = mockAction(true);
        NavigationGestureAction swipeRight = mockAction(true);
        mController.setGestureActions(swipeUp, swipeDown, swipeLeft, swipeRight,
                null /* swipeLeftFromEdgeAction */,
                null /* swipeLeftFromEdgeAction */);

        // Swipe Left from Edge
        assertGestureTriggersAction(swipeLeft, NAVBAR_WIDTH, 1, 5, 1);
        // Swipe Right from Edge
        assertGestureTriggersAction(swipeRight, 0, 1, NAVBAR_WIDTH, 5);
    }

    private void assertGestureDragsHitTargetAllDirections(View buttonView, boolean isRTL,
            int navPos) {
        mController.setBarState(isRTL, navPos);
@@ -665,7 +684,6 @@ public class QuickStepControllerTest extends SysuiTestCase {
        reset(buttonView);
    }


    private MotionEvent event(int action, float x, float y) {
        final MotionEvent event = mock(MotionEvent.class);
        doReturn(x).when(event).getX();