diff options
author | Mark Renouf <mrenouf@google.com> | 2014-05-02 16:45:34 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-02 16:45:34 +0000 |
commit | 63f728065a7584e3a51bb7b0b58ce8cf0c25390e (patch) | |
tree | f8c026f8c2daf583fb47aba1190b6ad02cba8c5c /core | |
parent | 4f8cd18880f1a63d2db376c3bfbfe11c55e6f1ee (diff) | |
parent | 11b1469144d73ad0280ef9d0c2e478d180f17074 (diff) | |
download | frameworks_base-63f728065a7584e3a51bb7b0b58ce8cf0c25390e.zip frameworks_base-63f728065a7584e3a51bb7b0b58ce8cf0c25390e.tar.gz frameworks_base-63f728065a7584e3a51bb7b0b58ce8cf0c25390e.tar.bz2 |
am 11b14691: Implement cliff guard for swipeDismiss gesture
* commit '11b1469144d73ad0280ef9d0c2e478d180f17074':
Implement cliff guard for swipeDismiss gesture
Diffstat (limited to 'core')
-rw-r--r-- | core/java/com/android/internal/widget/SwipeDismissLayout.java | 20 | ||||
-rw-r--r-- | core/res/res/values-watch/config.xml | 2 |
2 files changed, 10 insertions, 12 deletions
diff --git a/core/java/com/android/internal/widget/SwipeDismissLayout.java b/core/java/com/android/internal/widget/SwipeDismissLayout.java index 467d42e..674d084 100644 --- a/core/java/com/android/internal/widget/SwipeDismissLayout.java +++ b/core/java/com/android/internal/widget/SwipeDismissLayout.java @@ -35,7 +35,7 @@ import android.widget.FrameLayout; public class SwipeDismissLayout extends FrameLayout { private static final String TAG = "SwipeDismissLayout"; - private static final float TRANSLATION_MIN_ALPHA = 0.5f; + private static final float DISMISS_MIN_PROGRESS = 0.6f; public interface OnDismissedListener { void onDismissed(SwipeDismissLayout layout); @@ -77,6 +77,8 @@ public class SwipeDismissLayout extends FrameLayout { private OnDismissedListener mDismissedListener; private OnSwipeProgressChangedListener mProgressListener; + private float mLastX; + public SwipeDismissLayout(Context context) { super(context); init(context); @@ -95,7 +97,7 @@ public class SwipeDismissLayout extends FrameLayout { private void init(Context context) { ViewConfiguration vc = ViewConfiguration.get(getContext()); mSlop = vc.getScaledTouchSlop(); - mMinFlingVelocity = vc.getScaledMinimumFlingVelocity() * 16; + mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mAnimationTime = getContext().getResources().getInteger( android.R.integer.config_shortAnimTime); @@ -193,8 +195,8 @@ public class SwipeDismissLayout extends FrameLayout { case MotionEvent.ACTION_MOVE: mVelocityTracker.addMovement(ev); + mLastX = ev.getRawX(); updateSwiping(ev); - updateDismiss(ev); if (mSwiping) { setProgress(ev.getRawX() - mDownX); break; @@ -256,20 +258,16 @@ public class SwipeDismissLayout extends FrameLayout { float absVelocityX = Math.abs(velocityX); float absVelocityY = Math.abs(mVelocityTracker.getYVelocity()); - if (deltaX > getWidth() / 2) { - mDismissed = true; - } else if (absVelocityX >= mMinFlingVelocity - && absVelocityX <= mMaxFlingVelocity - && absVelocityY < absVelocityX / 2 - && velocityX > 0 - && deltaX > 0) { + if (deltaX > (getWidth() * DISMISS_MIN_PROGRESS) && + absVelocityX < mMinFlingVelocity && + ev.getRawX() >= mLastX) { mDismissed = true; } } // Check if the user tried to undo this. if (mDismissed && mSwiping) { // Check if the user's finger is actually back - if (deltaX < getWidth() / 2) { + if (deltaX < (getWidth() * DISMISS_MIN_PROGRESS)) { mDismissed = false; } } diff --git a/core/res/res/values-watch/config.xml b/core/res/res/values-watch/config.xml index e71fa4a..44e258d 100644 --- a/core/res/res/values-watch/config.xml +++ b/core/res/res/values-watch/config.xml @@ -32,7 +32,7 @@ <dimen name="config_viewConfigurationTouchSlop">4dp</dimen> <!-- Minimum velocity to initiate a fling, as measured in dips per second. --> - <dimen name="config_viewMinFlingVelocity">50dp</dimen> + <dimen name="config_viewMinFlingVelocity">500dp</dimen> <!-- Maximum velocity to initiate a fling, as measured in dips per second. --> <dimen name="config_viewMaxFlingVelocity">8000dp</dimen> |