Fix the "missing touch events" problem.

- Bias the slop regions so that it's more likely to think that you're scrolling
  than zooming.
- If it could be a scroll or a zoom, pick the scroll.
This commit is contained in:
Joe Onorato
2009-10-01 14:09:15 -07:00
parent 2bc6b7c2b8
commit f7b0e01880
2 changed files with 17 additions and 13 deletions
+11 -8
View File
@@ -74,11 +74,13 @@ public class AllAppsView extends RSSurfaceView
* TODO: What about scrolling? */
private int mLocks = LOCK_ICONS_PENDING;
private int mSlopX;
private int mMaxFlingVelocity;
private RenderScript mRS;
private RolloRS mRollo;
private ArrayList<ApplicationInfo> mAllAppsList;
private ViewConfiguration mConfig;
private int mPageCount;
private boolean mStartedScrolling;
private VelocityTracker mVelocity;
@@ -126,7 +128,10 @@ public class AllAppsView extends RSSurfaceView
super(context, attrs);
setFocusable(true);
getHolder().setFormat(PixelFormat.TRANSLUCENT);
mConfig = ViewConfiguration.get(context);
final ViewConfiguration config = ViewConfiguration.get(context);
mSlopX = config.getScaledTouchSlop();
mMaxFlingVelocity = config.getScaledMaximumFlingVelocity();
setOnClickListener(this);
setOnLongClickListener(this);
setZOrderOnTop(true);
@@ -217,12 +222,11 @@ public class AllAppsView extends RSSurfaceView
break;
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_OUTSIDE:
int slop = Math.abs(x - mLastMotionX);
if (!mStartedScrolling && slop < mConfig.getScaledTouchSlop()) {
// don't update mLastMotionX so slop is right and when we do start scrolling
int slopX = Math.abs(x - mLastMotionX);
if (!mStartedScrolling && slopX < mSlopX) {
// don't update mLastMotionX so slopX is right and when we do start scrolling
// below, we get the right delta.
} else {
mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX;
mRollo.mState.newTouchDown = 1;
mRollo.mInvokeMove.execute();
@@ -241,8 +245,7 @@ public class AllAppsView extends RSSurfaceView
mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX;
if (!mZoomSwipeInProgress) {
mVelocity.computeCurrentVelocity(1000 /* px/sec */,
mConfig.getScaledMaximumFlingVelocity());
mVelocity.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity);
mRollo.mState.flingVelocityX = mVelocity.getXVelocity() / Defines.SCREEN_WIDTH_PX;
mRollo.clearSelectedIcon();
mRollo.mState.save();
@@ -40,7 +40,8 @@ public class SwipeController {
private static final float SPRING_CONSTANT = 0.0009f;
// configuration
private int mSlop;
private int mSlopX;
private int mSlopY;
private float mSwipeDistance;
private AllAppsView mAllAppsView;
@@ -59,7 +60,8 @@ public class SwipeController {
public SwipeController(Context context) {
ViewConfiguration config = ViewConfiguration.get(context);
mSlop = config.getScaledTouchSlop();
mSlopX = config.getScaledTouchSlop();
mSlopY = 3 * mSlopX / 2; // make it 50% more biased towards horizontal swiping.
DisplayMetrics display = context.getResources().getDisplayMetrics();
mSwipeDistance = display.heightPixels / 2; // one half of the screen
@@ -130,12 +132,11 @@ public class SwipeController {
case MotionEvent.ACTION_MOVE:
if (!mCanceled && !mTracking) {
if (Math.abs(deltaX) > mSlop) {
if (Math.abs(deltaX) > mSlopX) {
mCanceled = true;
mTracking = false;
mAllAppsView.setZoomSwipeInProgress(false, true);
}
if (Math.abs(deltaY) > mSlop) {
} else if (Math.abs(deltaY) > mSlopY) {
mTracking = true;
}
}