From 48fa91a818e321208e90d6af234c1d4bed5a945d Mon Sep 17 00:00:00 2001 From: John Spurlock Date: Thu, 15 Aug 2013 09:29:31 -0400 Subject: [PATCH] Recover tracking pointer going up mid-gesture in shade. Keep track of the pointer id used in driving the gesture. If it happens to go up mid-gesture (another pointer is still down), continue the gesture with another down pointer, instead of abruptly jumping on next ACTION_MOVE. Bug:10246050 Change-Id: Ia6e59658635fd696974fe415f37811d27da80519 --- .../systemui/statusbar/phone/PanelView.java | 32 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java index b78239b3d238..a19dcc48e536 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java @@ -76,6 +76,7 @@ public class PanelView extends FrameLayout { private boolean mClosing; private boolean mRubberbanding; private boolean mTracking; + private int mTrackingPointer; private TimeAnimator mTimeAnimator; private ObjectAnimator mPeekAnimator; @@ -380,14 +381,21 @@ public class PanelView extends FrameLayout { mHandleView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { - final float y = event.getY(); - final float rawY = event.getRawY(); - if (DEBUG) logf("handle.onTouch: a=%s y=%.1f rawY=%.1f off=%.1f", + int pointerIndex = event.findPointerIndex(mTrackingPointer); + if (pointerIndex < 0) { + pointerIndex = 0; + mTrackingPointer = event.getPointerId(pointerIndex); + } + final float y = event.getY(pointerIndex); + final float rawDelta = event.getRawY() - event.getY(); + final float rawY = y + rawDelta; + if (DEBUG) logf("handle.onTouch: a=%s p=[%d,%d] y=%.1f rawY=%.1f off=%.1f", MotionEvent.actionToString(event.getAction()), + mTrackingPointer, pointerIndex, y, rawY, mTouchOffset); PanelView.this.getLocationOnScreen(mAbsPos); - switch (event.getAction()) { + switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: mTracking = true; mHandleView.setPressed(true); @@ -397,13 +405,26 @@ public class PanelView extends FrameLayout { trackMovement(event); mTimeAnimator.cancel(); // end any outstanding animations mBar.onTrackingStarted(PanelView.this); - mTouchOffset = (rawY - mAbsPos[1]) - PanelView.this.getExpandedHeight(); + mTouchOffset = (rawY - mAbsPos[1]) - mExpandedHeight; if (mExpandedHeight == 0) { mJustPeeked = true; runPeekAnimation(); } break; + case MotionEvent.ACTION_POINTER_UP: + final int upPointer = event.getPointerId(event.getActionIndex()); + if (mTrackingPointer == upPointer) { + // gesture is ongoing, find a new pointer to track + final int newIndex = event.getPointerId(0) != upPointer ? 0 : 1; + final float newY = event.getY(newIndex); + final float newRawY = newY + rawDelta; + mTrackingPointer = event.getPointerId(newIndex); + mTouchOffset = (newRawY - mAbsPos[1]) - mExpandedHeight; + mInitialTouchY = newY; + } + break; + case MotionEvent.ACTION_MOVE: final float h = rawY - mAbsPos[1] - mTouchOffset; if (h > mPeekHeight) { @@ -424,6 +445,7 @@ public class PanelView extends FrameLayout { case MotionEvent.ACTION_CANCEL: mFinalTouchY = y; mTracking = false; + mTrackingPointer = -1; mHandleView.setPressed(false); postInvalidate(); // catch the press state change mBar.onTrackingStopped(PanelView.this); -- 2.11.0