From f1408442231c756da8a931c9b221a148ab6d3eba Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Wed, 12 Nov 2014 17:53:52 +0100 Subject: [PATCH] Increases the falsing threshold when for the keyguard affordances The minimum amount has been increased by 20dp and in addition the Motion is cancelled whenever a POINTER_DOWN occurs, which should help a lot with falsing. Bug: 18298401 Change-Id: I04b1f30fd2555c08209224f4e84c610ecd7a33f1 (cherry picked from commit 1dc406505cdcbbf98ece4f15a2f98f621e24abdb) --- packages/SystemUI/res/values/dimens.xml | 2 +- .../phone/KeyguardAffordanceHelper.java | 49 ++++++++----------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index fabdf2979f015..fcdc0154cfeeb 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -320,7 +320,7 @@ 250dp - 90dp + 110dp 30dp diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java index 6653254bbb530..f1dcffbc0e1c4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java @@ -46,7 +46,6 @@ public class KeyguardAffordanceHelper { private FlingAnimationUtils mFlingAnimationUtils; private Callback mCallback; - private int mTrackingPointer; private VelocityTracker mVelocityTracker; private boolean mSwipingInProgress; private float mInitialTouchX; @@ -65,6 +64,7 @@ public class KeyguardAffordanceHelper { private Animator mSwipeAnimator; private int mMinBackgroundRadius; private boolean mMotionPerformedByUser; + private boolean mMotionCancelled; private AnimatorListenerAdapter mFlingEndListener = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -117,13 +117,11 @@ private void initIcons() { } public boolean onTouchEvent(MotionEvent event) { - int pointerIndex = event.findPointerIndex(mTrackingPointer); - if (pointerIndex < 0) { - pointerIndex = 0; - mTrackingPointer = event.getPointerId(pointerIndex); + if (mMotionCancelled && event.getActionMasked() != MotionEvent.ACTION_DOWN) { + return false; } - final float y = event.getY(pointerIndex); - final float x = event.getX(pointerIndex); + final float y = event.getY(); + final float x = event.getX(); boolean isUp = false; switch (event.getActionMasked()) { @@ -137,22 +135,12 @@ public boolean onTouchEvent(MotionEvent event) { initVelocityTracker(); trackMovement(event); mMotionPerformedByUser = false; + mMotionCancelled = false; 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 newX = event.getX(newIndex); - mTrackingPointer = event.getPointerId(newIndex); - mInitialTouchY = newY; - mInitialTouchX = newX; - mTranslationOnDown = mTranslation; - } + case MotionEvent.ACTION_POINTER_DOWN: + mMotionCancelled = true; + endMotion(event, true /* forceSnapBack */); break; - case MotionEvent.ACTION_MOVE: final float w = x - mInitialTouchX; trackMovement(event); @@ -174,20 +162,23 @@ public boolean onTouchEvent(MotionEvent event) { case MotionEvent.ACTION_UP: isUp = true; case MotionEvent.ACTION_CANCEL: - mTrackingPointer = -1; trackMovement(event); - if (mSwipingInProgress) { - flingWithCurrentVelocity(!isUp); - } - if (mVelocityTracker != null) { - mVelocityTracker.recycle(); - mVelocityTracker = null; - } + endMotion(event, !isUp); break; } return true; } + private void endMotion(MotionEvent event, boolean forceSnapBack) { + if (mSwipingInProgress) { + flingWithCurrentVelocity(forceSnapBack); + } + if (mVelocityTracker != null) { + mVelocityTracker.recycle(); + mVelocityTracker = null; + } + } + private void setSwipingInProgress(boolean inProgress) { mSwipingInProgress = inProgress; if (inProgress) {