diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java index 61adf47196..313638f195 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java @@ -1,24 +1,5 @@ package net.osmand.plus.views; -import gnu.trove.list.array.TIntArrayList; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import net.osmand.data.LatLon; -import net.osmand.data.QuadRect; -import net.osmand.data.QuadTree; -import net.osmand.data.RotatedTileBox; -import net.osmand.plus.ContextMenuAdapter; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.render.OsmandRenderer; -import net.osmand.plus.render.OsmandRenderer.RenderingContext; -import net.osmand.render.RenderingRuleSearchRequest; -import net.osmand.render.RenderingRulesStorage; -import net.osmand.util.MapAlgorithms; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; @@ -34,11 +15,41 @@ import android.os.AsyncTask; import android.support.annotation.NonNull; import android.view.MotionEvent; +import net.osmand.data.LatLon; +import net.osmand.data.QuadRect; +import net.osmand.data.QuadTree; +import net.osmand.data.RotatedTileBox; +import net.osmand.plus.ContextMenuAdapter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.render.OsmandRenderer; +import net.osmand.plus.render.OsmandRenderer.RenderingContext; +import net.osmand.render.RenderingRuleSearchRequest; +import net.osmand.render.RenderingRulesStorage; +import net.osmand.util.MapAlgorithms; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import gnu.trove.list.array.TIntArrayList; + public abstract class OsmandMapLayer { protected List fullObjectsLatLon; protected List smallObjectsLatLon; + public enum MapGestureType { + DOUBLE_TAP_ZOOM_IN, + DOUBLE_TAP_ZOOM_CHANGE, + TWO_POINTERS_ZOOM_OUT + } + + public boolean isMapGestureAllowed(MapGestureType type) { + return true; + } + public abstract void initLayer(OsmandMapTileView view); public abstract void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings); diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 0f670da124..712f26d0c8 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -227,6 +227,11 @@ public class OsmandMapTileView implements IMapDownloaderCallback { public void onTwoFingerTap() { //afterTwoFingersTap = true; if (isZoomingAllowed(getZoom(), -1.1f)) { + for (OsmandMapLayer layer : layers) { + if (!layer.isMapGestureAllowed(OsmandMapLayer.MapGestureType.TWO_POINTERS_ZOOM_OUT)) { + return; + } + } getAnimatedDraggingThread().startZooming(getZoom() - 1, currentViewport.getZoomFloatPart(), false); if (wasMapLinkedBeforeGesture) { ctx.getMapViewTrackingUtilities().setMapLinkedToLocation(true); @@ -1015,6 +1020,11 @@ public class OsmandMapTileView implements IMapDownloaderCallback { @Override public void onZoomEnded(double relativeToStart) { + for (OsmandMapLayer layer : layers) { + if (!layer.isMapGestureAllowed(OsmandMapLayer.MapGestureType.DOUBLE_TAP_ZOOM_CHANGE)) { + return; + } + } // 1.5 works better even on dm.density=1 devices float dz = (float) ((relativeToStart - 1) * DoubleTapScaleDetector.SCALE_PER_SCREEN); setIntZoom(Math.round(dz) + initialViewport.getZoom()); @@ -1089,6 +1099,11 @@ public class OsmandMapTileView implements IMapDownloaderCallback { @Override public void onZooming(double relativeToStart) { + for (OsmandMapLayer layer : layers) { + if (!layer.isMapGestureAllowed(OsmandMapLayer.MapGestureType.DOUBLE_TAP_ZOOM_CHANGE)) { + return; + } + } double dz = (relativeToStart - 1) * DoubleTapScaleDetector.SCALE_PER_SCREEN; changeZoomPosition((float) dz, 0); } @@ -1096,6 +1111,11 @@ public class OsmandMapTileView implements IMapDownloaderCallback { @Override public boolean onDoubleTap(MotionEvent e) { LOG.debug("onDoubleTap getZoom()"); + for (OsmandMapLayer layer : layers) { + if (!layer.isMapGestureAllowed(OsmandMapLayer.MapGestureType.DOUBLE_TAP_ZOOM_IN)) { + return false; + } + } if (!doubleTapScaleDetector.isInZoomMode()) { if (isZoomingAllowed(getZoom(), 1.1f)) { final RotatedTileBox tb = getCurrentRotatedTileBox(); diff --git a/OsmAnd/src/net/osmand/plus/views/RulerControlLayer.java b/OsmAnd/src/net/osmand/plus/views/RulerControlLayer.java index f967df10bb..f6eed167a5 100644 --- a/OsmAnd/src/net/osmand/plus/views/RulerControlLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/RulerControlLayer.java @@ -42,6 +42,7 @@ public class RulerControlLayer extends OsmandMapLayer { private int radius; private double roundedDist; private boolean showTwoFingersDistance; + private boolean twoPointersZoomOutAllowed; private QuadPoint cacheCenter; private int cacheIntZoom; @@ -108,10 +109,20 @@ public class RulerControlLayer extends OsmandMapLayer { }; } + @Override + public boolean isMapGestureAllowed(MapGestureType type) { + if (type != MapGestureType.TWO_POINTERS_ZOOM_OUT) { + return true; + } else { + return twoPointersZoomOutAllowed; + } + } + @Override public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) { if (mapActivity.getMapLayers().getMapWidgetRegistry().isVisible("ruler") && rightWidgetsPanel.getVisibility() == View.VISIBLE) { + twoPointersZoomOutAllowed = false; lineAttrs.updatePaints(view, settings, tb); circleAttrs.updatePaints(view, settings, tb); circleAttrs.paint2.setStyle(Style.FILL); @@ -147,6 +158,8 @@ public class RulerControlLayer extends OsmandMapLayer { drawCircle(canvas, tb, i, center); } } + } else { + twoPointersZoomOutAllowed = true; } }