Bug 719240 - Delay sending touchmove events until touches have moved a minimum distance. r=mfinkle

This commit is contained in:
Wes Johnston 2012-01-25 01:31:33 +01:00
Родитель da70254b56
Коммит fc899e038a
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -112,6 +112,7 @@ public class LayerController {
private boolean allowDefaultActions = true;
private Timer allowDefaultTimer = null;
private boolean inTouchSession = false;
private PointF initialTouchLocation = null;
public LayerController(Context context) {
mContext = context;
@ -362,7 +363,9 @@ public class LayerController {
*/
public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction();
PointF point = new PointF(event.getX(), event.getY());
if ((action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
initialTouchLocation = point;
post(new Runnable() {
public void run() {
mView.clearEventQueue();
@ -371,6 +374,14 @@ public class LayerController {
});
}
if (initialTouchLocation != null && (action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_MOVE) {
if (PointUtils.subtract(point, initialTouchLocation).length() > PanZoomController.PAN_THRESHOLD * 240) {
initialTouchLocation = null;
} else {
return !allowDefaultActions;
}
}
if (mOnTouchListener != null)
mOnTouchListener.onTouch(mView, event);

Просмотреть файл

@ -79,7 +79,7 @@ public class PanZoomController
private static final float FLING_STOPPED_THRESHOLD = 0.1f;
// The distance the user has to pan before we recognize it as such (e.g. to avoid
// 1-pixel pans between the touch-down and touch-up of a click). In units of inches.
private static final float PAN_THRESHOLD = 0.1f;
public static final float PAN_THRESHOLD = 0.1f;
// Angle from axis within which we stay axis-locked
private static final double AXIS_LOCK_ANGLE = Math.PI / 6.0; // 30 degrees
// The maximum amount we allow you to zoom into a page