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

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

Merge "Use raw MotionEvent coordinates when tracking velocity"

parents ac197316 c8548557
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -227,6 +227,16 @@ public abstract class PanelView extends FrameLayout {
        mUnlockFalsingThreshold = res.getDimensionPixelSize(R.dimen.unlock_falsing_threshold);
    }

    private void addMovement(MotionEvent event) {
        // Add movement to velocity tracker using raw screen X and Y coordinates instead
        // of window coordinates because the window frame may be moving at the same time.
        float deltaX = event.getRawX() - event.getX();
        float deltaY = event.getRawY() - event.getY();
        event.offsetLocation(deltaX, deltaY);
        mVelocityTracker.addMovement(event);
        event.offsetLocation(-deltaX, -deltaY);
    }

    public void setTouchAndAnimationDisabled(boolean disabled) {
        mTouchDisabled = disabled;
        if (mTouchDisabled) {
@@ -307,7 +317,7 @@ public abstract class PanelView extends FrameLayout {
                mTouchAboveFalsingThreshold = false;
                mCollapsedAndHeadsUpOnDown = isFullyCollapsed()
                        && mHeadsUpManager.hasPinnedHeadsUp();
                mVelocityTracker.addMovement(event);
                addMovement(event);
                if (!mGestureWaitForTouchSlop || (mHeightAnimator != null && !mHintAnimationRunning)
                        || mPeekAnimator != null) {
                    mTouchSlopExceeded = (mHeightAnimator != null && !mHintAnimationRunning)
@@ -341,7 +351,7 @@ public abstract class PanelView extends FrameLayout {
                }
                break;
            case MotionEvent.ACTION_MOVE:
                mVelocityTracker.addMovement(event);
                addMovement(event);
                float h = y - mInitialTouchY;

                // If the panel was collapsed when touching, we only need to check for the
@@ -386,7 +396,7 @@ public abstract class PanelView extends FrameLayout {

            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                mVelocityTracker.addMovement(event);
                addMovement(event);
                endMotionEvent(event, x, y, false /* forceCancel */);
                break;
        }
@@ -573,7 +583,7 @@ public abstract class PanelView extends FrameLayout {
                mHasLayoutedSinceDown = false;
                mUpdateFlingOnLayout = false;
                mTouchAboveFalsingThreshold = false;
                mVelocityTracker.addMovement(event);
                addMovement(event);
                break;
            case MotionEvent.ACTION_POINTER_UP:
                final int upPointer = event.getPointerId(event.getActionIndex());
@@ -593,7 +603,7 @@ public abstract class PanelView extends FrameLayout {
                break;
            case MotionEvent.ACTION_MOVE:
                final float h = y - mInitialTouchY;
                mVelocityTracker.addMovement(event);
                addMovement(event);
                if (scrolledToBottom || mTouchStartedInEmptyArea || mAnimatingOnDown) {
                    float hAbs = Math.abs(h);
                    if ((h < -mTouchSlop || (mAnimatingOnDown && hAbs > mTouchSlop))