Use raw MotionEvent coordinates when tracking velocity
Unfortunately, we have to roll back the commit "use raw coordinates in
velocitytracker" ag/3545962 because it broke some assumptions in the
view hierarchy. That is being done in aosp/800996.
As a result, we have to start working around the revert by manually
adjusting the coordinates. This is effectively a revert of ag/4071758
that has been rebased on ag/4891556.
Test: manual interaction with notification panel (pulling down,
flinging at various points)
Bug: 117921784
Bug: 117475766
Change-Id: I24c5815967381cd4be983ef7e8456fa7d42c53c8
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 57c2439..f29b7ca 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -227,6 +227,16 @@
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 @@
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 @@
}
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 @@
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
- mVelocityTracker.addMovement(event);
+ addMovement(event);
endMotionEvent(event, x, y, false /* forceCancel */);
break;
}
@@ -573,7 +583,7 @@
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 @@
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))