Merge "Use raw MotionEvent coordinates when tracking velocity"
This commit is contained in:
committed by
Android (Google) Code Review
commit
148eba158c
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user