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

Commit f2d5bf57 authored by Ryan Lin's avatar Ryan Lin Committed by Android (Google) Code Review
Browse files

Merge "Fix hardly to perform 3-finger swipe from the bottom"

parents ef3a1d0f a67afd3c
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -644,18 +644,9 @@ public class TouchExplorer extends BaseEventStreamTransformation
                if (mGestureDetector.isMultiFingerGesturesEnabled()) {
                    if (mGestureDetector.isTwoFingerPassthroughEnabled()) {
                        if (event.getPointerCount() == 3) {
                            boolean isOnBottomEdge = true;
                            // If three fingers went down on the bottom edge of the screen, delegate
                            // immediately.
                            final long screenHeight =
                                    mContext.getResources().getDisplayMetrics().heightPixels;
                            for (int i = 0; i < TouchState.MAX_POINTER_COUNT; ++i) {
                                if (mReceivedPointerTracker.getReceivedPointerDownY(i)
                                        < (screenHeight - mEdgeSwipeHeightPixels)) {
                                    isOnBottomEdge = false;
                                }
                            }
                            if (isOnBottomEdge) {
                            if (allPointersDownOnBottomEdge(event)) {
                                if (DEBUG) {
                                    Slog.d(LOG_TAG, "Three-finger edge swipe detected.");
                                }
@@ -1063,6 +1054,22 @@ public class TouchExplorer extends BaseEventStreamTransformation
        return downEvent;
    }

    private boolean allPointersDownOnBottomEdge(MotionEvent event) {
        final long screenHeight =
                mContext.getResources().getDisplayMetrics().heightPixels;
        for (int i = 0; i < event.getPointerCount(); ++i) {
            final int pointerId = event.getPointerId(i);
            final float pointerDownY = mReceivedPointerTracker.getReceivedPointerDownY(pointerId);
            if (pointerDownY < (screenHeight - mEdgeSwipeHeightPixels)) {
                if (DEBUG) {
                    Slog.d(LOG_TAG, "The pointer is not on the bottom edge" + pointerDownY);
                }
                return false;
            }
        }
        return true;
    }

    public TouchState getState() {
        return mState;
    }