Merge change I476339d6 into eclair

* changes:
  Implement safer test for min click velocity.
This commit is contained in:
Android (Google) Code Review committed 2009-09-29 21:23:20 -04:00
commit 4f3bdc2e66
1 file changed
+17 -7
+17 -7
View File
@@ -204,7 +204,7 @@ public class AllAppsView extends RSSurfaceView
mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX; mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX;
mRollo.mState.newTouchDown = 1; mRollo.mState.newTouchDown = 1;
if (mRollo.mReadback.velocity != 0) { if (!mRollo.checkClickOK()) {
mRollo.clearSelectedIcon(); mRollo.clearSelectedIcon();
} else { } else {
mRollo.selectIcon(x, (int)ev.getY(), mRollo.mReadback.posX); mRollo.selectIcon(x, (int)ev.getY(), mRollo.mReadback.posX);
@@ -237,17 +237,21 @@ public class AllAppsView extends RSSurfaceView
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL:
if (!mZoomSwipeInProgress) { mRollo.mState.newTouchDown = 0;
mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX; mRollo.mState.newPositionX = ev.getRawX() / Defines.SCREEN_WIDTH_PX;
mRollo.mState.newTouchDown = 0;
if (!mZoomSwipeInProgress) {
mVelocity.computeCurrentVelocity(1000 /* px/sec */, mVelocity.computeCurrentVelocity(1000 /* px/sec */,
mConfig.getScaledMaximumFlingVelocity()); mConfig.getScaledMaximumFlingVelocity());
mRollo.mState.flingVelocityX = mVelocity.getXVelocity() / Defines.SCREEN_WIDTH_PX; mRollo.mState.flingVelocityX = mVelocity.getXVelocity() / Defines.SCREEN_WIDTH_PX;
mRollo.clearSelectedIcon(); mRollo.clearSelectedIcon();
mRollo.mState.save(); mRollo.mState.save();
mRollo.mInvokeFling.execute(); mRollo.mInvokeFling.execute();
} else {
mRollo.mState.save();
mRollo.mInvokeMove.execute();
} }
mLastMotionX = -10000; mLastMotionX = -10000;
mVelocity.recycle(); mVelocity.recycle();
mVelocity = null; mVelocity = null;
@@ -262,7 +266,7 @@ public class AllAppsView extends RSSurfaceView
return; return;
} }
int index = mRollo.mState.selectedIconIndex; int index = mRollo.mState.selectedIconIndex;
if (mRollo.mReadback.velocity < 1 && index >= 0 && index < mAllAppsList.size()) { if (mRollo.checkClickOK() && index >= 0 && index < mAllAppsList.size()) {
ApplicationInfo app = mAllAppsList.get(index); ApplicationInfo app = mAllAppsList.get(index);
mLauncher.startActivitySafely(app.intent); mLauncher.startActivitySafely(app.intent);
} }
@@ -273,8 +277,8 @@ public class AllAppsView extends RSSurfaceView
return true; return true;
} }
int index = mRollo.mState.selectedIconIndex; int index = mRollo.mState.selectedIconIndex;
Log.d(TAG, "long click! velocity=" + mRollo.mState.flingVelocityX + " index=" + index); Log.d(TAG, "long click! velocity=" + mRollo.mReadback.velocity + " index=" + index);
if (mRollo.mState.flingVelocityX == 0 && index >= 0 && index < mAllAppsList.size()) { if (mRollo.checkClickOK() && index >= 0 && index < mAllAppsList.size()) {
ApplicationInfo app = mAllAppsList.get(index); ApplicationInfo app = mAllAppsList.get(index);
// We don't really have an accurate location to use. This will do. // We don't really have an accurate location to use. This will do.
@@ -456,6 +460,12 @@ public class AllAppsView extends RSSurfaceView
} }
} }
private boolean checkClickOK() {
//android.util.Log.e("rs", "check click " + Float.toString(mReadback.velocity) + ", " + Float.toString(mReadback.posX));
return (Math.abs(mReadback.velocity) < 0.1f) &&
(Math.abs(mReadback.posX - Math.round(mReadback.posX)) < 0.1f);
}
class Params extends BaseAlloc { class Params extends BaseAlloc {
Params() { Params() {
mType = Type.createFromClass(mRS, Params.class, 1, "ParamsClass"); mType = Type.createFromClass(mRS, Params.class, 1, "ParamsClass");