Merge pull request #1640 from osmandapp/crimean

Fix - double tap vs single tap
This commit is contained in:
Alexey 2015-09-02 10:08:24 +03:00
commit 24a32716d3
2 changed files with 17 additions and 26 deletions

View file

@ -16,25 +16,27 @@ import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView;
import android.graphics.PointF;
import android.os.Build;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
// Provide touch exploration mode for map view
// when scrolling it by gestures is disabled.
//
public class MapExplorer implements OnGestureListener, IContextMenuProvider {
public class MapExplorer extends SimpleOnGestureListener implements IContextMenuProvider {
private static final float VICINITY_RADIUS = 15;
private OsmandMapTileView mapView;
private OnGestureListener fallback;
private SimpleOnGestureListener fallback;
private Map<Object, IContextMenuProvider> selectedObjects = null;
// OnGestureListener specified as a second argument
// will be used when scrolling map by gestures
// is enabled.
public MapExplorer(OsmandMapTileView mapView, OnGestureListener fallback) {
public MapExplorer(OsmandMapTileView mapView, SimpleOnGestureListener fallback) {
this.mapView = mapView;
this.fallback = fallback;
}
@ -126,13 +128,17 @@ public class MapExplorer implements OnGestureListener, IContextMenuProvider {
fallback.onShowPress(e);
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return fallback.onSingleTapUp(e);
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
return fallback.onSingleTapConfirmed(e);
}
@Override
public boolean onDoubleTap(MotionEvent e) {
return fallback.onDoubleTap(e);
}
// IContextMenuProvider interface implementation.
// IContextMenuProvider interface implementation.
@Override
public boolean disableSingleTap() {

View file

@ -47,8 +47,7 @@ import android.os.Message;
import android.os.SystemClock;
import android.util.DisplayMetrics;
import android.view.GestureDetector;
import android.view.GestureDetector.OnDoubleTapListener;
import android.view.GestureDetector.OnGestureListener;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
@ -212,7 +211,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
animatedDraggingThread = new AnimateDraggingMapThread(this);
gestureDetector = new GestureDetector(ctx, new MapExplorer(this, new MapTileViewOnGestureListener()));
multiTouchSupport = new MultiTouchSupport(ctx, new MapTileViewMultiTouchZoomListener());
gestureDetector.setOnDoubleTapListener(new MapTileViewOnDoubleTapListener());
WindowManager mgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
dm = new DisplayMetrics();
@ -914,7 +912,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
private class MapTileViewOnGestureListener implements OnGestureListener {
private class MapTileViewOnGestureListener extends SimpleOnGestureListener {
@Override
public boolean onDown(MotionEvent e) {
return false;
@ -961,7 +959,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
public boolean onSingleTapConfirmed(MotionEvent e) {
PointF point = new PointF(e.getX(), e.getY());
if (log.isDebugEnabled()) {
log.debug("On click event " + point.x + " " + point.y); //$NON-NLS-1$ //$NON-NLS-2$
@ -979,10 +977,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
return false;
}
}
private class MapTileViewOnDoubleTapListener implements OnDoubleTapListener {
@Override
public boolean onDoubleTap(MotionEvent e) {
final RotatedTileBox tb = getCurrentRotatedTileBox();
@ -991,16 +986,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
getAnimatedDraggingThread().startMoving(lat, lon, getZoom() + 1, true);
return true;
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
return false;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
return false;
}
}
public Resources getResources() {