summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-02-14 22:46:57 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-02-14 22:47:00 +0000
commitc61cd1a6354bce0a34f3a44989b4412bef71b7bd (patch)
treea733028749de9d989eb0c72bb34b1103f5648e20
parentc510e19d18cf00886c9810dab5509527282f9d3d (diff)
parent390120b925398c754b4f785fc12a8def0d09c09b (diff)
downloadbase-c61cd1a6354bce0a34f3a44989b4412bef71b7bd.tar.gz
Merge "Fix incorrect values for VelocityTracker in SwipeDismissLayout." into cw-f-dev
-rw-r--r--core/java/com/android/internal/widget/SwipeDismissLayout.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/core/java/com/android/internal/widget/SwipeDismissLayout.java b/core/java/com/android/internal/widget/SwipeDismissLayout.java
index 261fa4327494..6d814bf14bc0 100644
--- a/core/java/com/android/internal/widget/SwipeDismissLayout.java
+++ b/core/java/com/android/internal/widget/SwipeDismissLayout.java
@@ -79,7 +79,6 @@ public class SwipeDismissLayout extends FrameLayout {
private boolean mDismissed;
private boolean mDiscardIntercept;
private VelocityTracker mVelocityTracker;
- private float mTranslationX;
private boolean mBlockGesture = false;
private boolean mActivityTranslucencyConverted = false;
@@ -166,8 +165,10 @@ public class SwipeDismissLayout extends FrameLayout {
return super.onInterceptTouchEvent(ev);
}
- // offset because the view is translated during swipe
- ev.offsetLocation(mTranslationX, 0);
+ // Offset because the view is translated during swipe, match X with raw X. Active touch
+ // coordinates are mostly used by the velocity tracker, so offset it to match the raw
+ // coordinates which is what is primarily used elsewhere.
+ ev.offsetLocation(ev.getRawX() - ev.getX(), 0);
switch (ev.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
@@ -232,8 +233,12 @@ public class SwipeDismissLayout extends FrameLayout {
if (mVelocityTracker == null || !mDismissable) {
return super.onTouchEvent(ev);
}
- // offset because the view is translated during swipe
- ev.offsetLocation(mTranslationX, 0);
+
+ // Offset because the view is translated during swipe, match X with raw X. Active touch
+ // coordinates are mostly used by the velocity tracker, so offset it to match the raw
+ // coordinates which is what is primarily used elsewhere.
+ ev.offsetLocation(ev.getRawX() - ev.getX(), 0);
+
switch (ev.getActionMasked()) {
case MotionEvent.ACTION_UP:
updateDismiss(ev);
@@ -266,7 +271,6 @@ public class SwipeDismissLayout extends FrameLayout {
}
private void setProgress(float deltaX) {
- mTranslationX = deltaX;
if (mProgressListener != null && deltaX >= 0) {
mProgressListener.onSwipeProgressChanged(
this, progressToAlpha(deltaX / getWidth()), deltaX);
@@ -300,7 +304,6 @@ public class SwipeDismissLayout extends FrameLayout {
mVelocityTracker.recycle();
}
mVelocityTracker = null;
- mTranslationX = 0;
mDownX = 0;
mLastX = Integer.MIN_VALUE;
mDownY = 0;