summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongwei Wang <hwwang@google.com>2013-09-09 15:34:14 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-09-09 15:34:14 -0700
commite5bf7e810da6fe81cfe709fb53ee9df3a4ae65c0 (patch)
tree99c45d2d17a5b2ee4b0652ca38b2a3ac4332c238
parentc788b6d10296ecfa31db19a7495ae1646e06ab90 (diff)
parent362c4441b65f63dfc3cf933d569aba6e00dc168a (diff)
am 362c4441: Tone down the sensitivity of swipe for square contact tiles
* commit '362c4441b65f63dfc3cf933d569aba6e00dc168a': Tone down the sensitivity of swipe for square contact tiles
-rw-r--r--src/com/android/dialer/list/PhoneFavoritesTileAdapter.java3
-rw-r--r--src/com/android/dialer/list/SwipeHelper.java23
2 files changed, 20 insertions, 6 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
index 1c6ffde38..8eba964b2 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -715,6 +715,9 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
.getScaledPagingTouchSlop();
mSwipeHelper = new SwipeHelper(context, SwipeHelper.X, this, densityScale,
pagingTouchSlop);
+ // Increase swipe thresholds for square tiles since they are relatively small.
+ mSwipeHelper.setChildSwipedFarEnoughFactor(0.9f);
+ mSwipeHelper.setChildSwipedFastEnoughFactor(0.1f);
mOnItemSwipeListener = PhoneFavoritesTileAdapter.this;
}
}
diff --git a/src/com/android/dialer/list/SwipeHelper.java b/src/com/android/dialer/list/SwipeHelper.java
index 152171432..ce46ec3eb 100644
--- a/src/com/android/dialer/list/SwipeHelper.java
+++ b/src/com/android/dialer/list/SwipeHelper.java
@@ -89,6 +89,9 @@ public class SwipeHelper {
private float mStartAlpha;
private boolean mProtected = false;
+ private float mChildSwipedFarEnoughFactor = 0.4f;
+ private float mChildSwipedFastEnoughFactor = 0.05f;
+
public SwipeHelper(Context context, int swipeDirection, SwipeHelperCallback callback, float densityScale,
float pagingTouchSlop) {
mCallback = callback;
@@ -118,6 +121,14 @@ public class SwipeHelper {
mPagingTouchSlop = pagingTouchSlop;
}
+ public void setChildSwipedFarEnoughFactor(float factor) {
+ mChildSwipedFarEnoughFactor = factor;
+ }
+
+ public void setChildSwipedFastEnoughFactor(float factor) {
+ mChildSwipedFastEnoughFactor = factor;
+ }
+
private float getVelocity(VelocityTracker vt) {
return mSwipeDirection == X ? vt.getXVelocity() :
vt.getYVelocity();
@@ -407,15 +418,15 @@ public class SwipeHelper {
// swipe/dismiss
float translation = Math.abs(mCurrAnimView.getTranslationX());
float currAnimViewSize = getSize(mCurrAnimView);
- // Long swipe = translation of .4 * width
+ // Long swipe = translation of {@link #mChildSwipedFarEnoughFactor} * width
boolean childSwipedFarEnough = DISMISS_IF_SWIPED_FAR_ENOUGH
- && translation > 0.4 * currAnimViewSize;
- // Fast swipe = > escapeVelocity and translation of .1 *
- // width
+ && translation > mChildSwipedFarEnoughFactor * currAnimViewSize;
+ // Fast swipe = > escapeVelocity and translation of
+ // {@link #mChildSwipedFastEnoughFactor} * width
boolean childSwipedFastEnough = (Math.abs(velocity) > escapeVelocity)
&& (Math.abs(velocity) > Math.abs(perpendicularVelocity))
&& (velocity > 0) == (mCurrAnimView.getTranslationX() > 0)
- && translation > 0.05 * currAnimViewSize;
+ && translation > mChildSwipedFastEnoughFactor * currAnimViewSize;
if (LOG_SWIPE_DISMISS_VELOCITY) {
Log.v(TAG, "Swipe/Dismiss: " + velocity + "/" + escapeVelocity + "/"
+ perpendicularVelocity + ", x: " + translation + "/"
@@ -468,4 +479,4 @@ public class SwipeHelper {
public boolean isSwipeEnabled();
}
-} \ No newline at end of file
+}