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

Commit 9b0a2c92 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Improve dismiss/scrolling handling in recents

Make sure to only enter dismiss mode if xDiff is bigger than yDiff,
and only start scrolling if yDiff is bigger than xDiff.

Change-Id: Id898752ff7a08df549e234678aed0dad074b202d
parent 8f8155ba
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public class SwipeHelper implements Gefingerpoken {
    private FalsingManager mFalsingManager;

    private float mInitialTouchPos;
    private float mPerpendicularInitialTouchPos;
    private boolean mDragging;
    private View mCurrView;
    private View mCurrAnimView;
@@ -117,6 +118,10 @@ public class SwipeHelper implements Gefingerpoken {
        return mSwipeDirection == X ? ev.getX() : ev.getY();
    }

    private float getPerpendicularPos(MotionEvent ev) {
        return mSwipeDirection == X ? ev.getY() : ev.getX();
    }

    private float getTranslation(View v) {
        return mSwipeDirection == X ? v.getTranslationX() : v.getTranslationY();
    }
@@ -240,6 +245,7 @@ public class SwipeHelper implements Gefingerpoken {
                    mCanCurrViewBeDimissed = mCallback.canChildBeDismissed(mCurrView);
                    mVelocityTracker.addMovement(ev);
                    mInitialTouchPos = getPos(ev);
                    mPerpendicularInitialTouchPos = getPerpendicularPos(ev);

                    if (mLongPressListener != null) {
                        if (mWatchLongPress == null) {
@@ -271,8 +277,11 @@ public class SwipeHelper implements Gefingerpoken {
                if (mCurrView != null && !mLongPressSent) {
                    mVelocityTracker.addMovement(ev);
                    float pos = getPos(ev);
                    float perpendicularPos = getPerpendicularPos(ev);
                    float delta = pos - mInitialTouchPos;
                    if (Math.abs(delta) > mPagingTouchSlop) {
                    float deltaPerpendicular = perpendicularPos - mPerpendicularInitialTouchPos;
                    if (Math.abs(delta) > mPagingTouchSlop
                            && Math.abs(delta) > Math.abs(deltaPerpendicular)) {
                        mCallback.onBeginDrag(mCurrView);
                        mDragging = true;
                        mInitialTouchPos = getPos(ev) - getTranslation(mCurrAnimView);
@@ -280,7 +289,6 @@ public class SwipeHelper implements Gefingerpoken {
                        removeLongPressCallback();
                    }
                }

                break;

            case MotionEvent.ACTION_UP:
+4 −1
Original line number Diff line number Diff line
@@ -215,8 +215,11 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
            case MotionEvent.ACTION_MOVE: {
                int activePointerIndex = ev.findPointerIndex(mActivePointerId);
                int y = (int) ev.getY(activePointerIndex);
                int x = (int) ev.getX(activePointerIndex);
                if (!mIsScrolling) {
                    if (Math.abs(y - mDownY) > mScrollTouchSlop) {
                    int yDiff = Math.abs(y - mDownY);
                    int xDiff = Math.abs(x - mDownX);
                    if (Math.abs(y - mDownY) > mScrollTouchSlop && yDiff > xDiff) {
                        mIsScrolling = true;

                        // Disallow parents from intercepting touch events