Bug 904245 - Take touch radius into account when calculating pan threshold. r=kats

This commit is contained in:
Wes Johnston 2013-10-15 08:06:01 -07:00
Родитель 326e9c005f
Коммит 7c0d9c1cbd
2 изменённых файлов: 20 добавлений и 1 удалений

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

@ -21,12 +21,14 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.os.Build;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
@ -125,6 +127,18 @@ public class LayerView extends FrameLayout {
GeckoAccessibility.setDelegate(this);
}
private Point getEventRadius(MotionEvent event) {
if (Build.VERSION.SDK_INT >= 9) {
return new Point((int)event.getToolMajor()/2,
(int)event.getToolMinor()/2);
}
float size = event.getSize();
DisplayMetrics displaymetrics = getContext().getResources().getDisplayMetrics();
size = size*Math.min(displaymetrics.heightPixels, displaymetrics.widthPixels);
return new Point((int)size,(int)size);
}
public void geckoConnected() {
// See if we want to force 16-bit colour before doing anything
PrefsHelper.getPref("gfx.android.rgb16.force", new PrefsHelper.PrefHandlerBase() {
@ -157,8 +171,10 @@ public class LayerView extends FrameLayout {
}
if (mInitialTouchPoint != null && action == MotionEvent.ACTION_MOVE) {
Point p = getEventRadius(event);
if (PointUtils.subtract(point, mInitialTouchPoint).length() <
PanZoomController.PAN_THRESHOLD) {
Math.max(PanZoomController.CLICK_THRESHOLD, Math.min(Math.min(p.x, p.y), PanZoomController.PAN_THRESHOLD))) {
// Don't send the touchmove event if if the users finger hasn't moved far.
// Necessary for Google Maps to work correctly. See bug 771099.
return true;

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

@ -18,6 +18,9 @@ public interface PanZoomController {
// between the touch-down and touch-up of a click). In units of density-independent pixels.
public static final float PAN_THRESHOLD = 1/16f * GeckoAppShell.getDpi();
// Threshold for sending touch move events to content
public static final float CLICK_THRESHOLD = 1/50f * GeckoAppShell.getDpi();
static class Factory {
static PanZoomController create(PanZoomTarget target, View view, EventDispatcher dispatcher) {
return new JavaPanZoomController(target, view, dispatcher);