diff --git a/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java b/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java index 0a0064d9ad..728dbdd9f8 100644 --- a/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java +++ b/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java @@ -52,7 +52,7 @@ public class DoubleTapScaleDetector { secondDown = null; if (isDoubleTapping) { isDoubleTapping = false; - listener.onZoomEnded(scale, 0); + listener.onZoomEnded(scale); return true; } else { firstUp = MotionEvent.obtain(event); @@ -77,7 +77,7 @@ public class DoubleTapScaleDetector { float delta = convertPxToDp((int) (firstDown.getY() - event.getY())); float scaleDelta = delta / (displayHeightPx / SCALE_PER_SCREEN); scale = 1 - scaleDelta; - listener.onZoomingOrRotating(scale, 0); + listener.onZooming(scale); return true; } } @@ -130,9 +130,9 @@ public class DoubleTapScaleDetector { public interface DoubleTapZoomListener { public void onZoomStarted(PointF centerPoint); - public void onZoomingOrRotating(double relativeToStart, float angle); + public void onZooming(double relativeToStart); - public void onZoomEnded(double relativeToStart, float angleRelative); + public void onZoomEnded(double relativeToStart); public void onGestureInit(float x1, float y1, float x2, float y2); } diff --git a/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java b/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java index 0858795e53..c91c4d5869 100644 --- a/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java +++ b/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java @@ -1,16 +1,16 @@ package net.osmand.plus.views; -import java.lang.reflect.Method; - -import net.osmand.PlatformUtil; - -import net.osmand.util.MapUtils; -import org.apache.commons.logging.Log; - import android.content.Context; import android.graphics.PointF; import android.view.MotionEvent; +import net.osmand.PlatformUtil; +import net.osmand.util.MapUtils; + +import org.apache.commons.logging.Log; + +import java.lang.reflect.Method; + public class MultiTouchSupport { @@ -29,7 +29,7 @@ public class MultiTouchSupport { public void onZoomingOrRotating(double relativeToStart, float angle); - public void onZoomEnded(double relativeToStart, float angleRelative); + public void onZoomOrRotationEnded(double relativeToStart, float angleRelative); public void onGestureInit(float x1, float y1, float x2, float y2); @@ -87,7 +87,7 @@ public class MultiTouchSupport { Integer pointCount = (Integer) getPointerCount.invoke(event); if(pointCount < 2){ if(inZoomMode){ - listener.onZoomEnded(zoomRelative, angleRelative); + listener.onZoomOrRotationEnded(zoomRelative, angleRelative); } return false; } @@ -112,7 +112,7 @@ public class MultiTouchSupport { return true; } else if(actionCode == ACTION_POINTER_UP){ if(inZoomMode){ - listener.onZoomEnded(zoomRelative, angleRelative); + listener.onZoomOrRotationEnded(zoomRelative, angleRelative); inZoomMode = false; } return true; diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 0a0bdf1101..438e1642ab 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -859,7 +859,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback { private static final float ANGLE_THRESHOLD = 15; @Override - public void onZoomEnded(double relativeToStart, float angleRelative) { + public void onZoomOrRotationEnded(double relativeToStart, float angleRelative) { // 1.5 works better even on dm.density=1 devices float dz = (float) (Math.log(relativeToStart) / Math.log(2)) * 1.5f; setIntZoom(Math.round(dz) + initialViewport.getZoom()); @@ -880,6 +880,24 @@ public class OsmandMapTileView implements IMapDownloaderCallback { } } + @Override + public void onZoomEnded(double relativeToStart) { + // 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()); + final int newZoom = getZoom(); + if (application.accessibilityEnabled()) { + if (newZoom != initialViewport.getZoom()) { + showMessage(application.getString(R.string.zoomIs) + " " + newZoom); //$NON-NLS-1$ + } else { + final LatLon p1 = initialViewport.getLatLonFromPixel(x1, y1); + final LatLon p2 = initialViewport.getLatLonFromPixel(x2, y2); + showMessage(OsmAndFormatter.getFormattedDistance((float) MapUtils.getDistance(p1.getLatitude(), p1.getLongitude(), p2.getLatitude(), p2.getLongitude()), application)); + } + } + } + + @Override public void onGestureInit(float x1, float y1, float x2, float y2) { this.x1 = x1; @@ -912,7 +930,12 @@ public class OsmandMapTileView implements IMapDownloaderCallback { if (dz != 0 || relAngle != 0) { changeZoomPosition((float) dz, relAngle); } + } + @Override + public void onZooming(double relativeToStart) { + double dz = (relativeToStart - 1) * DoubleTapScaleDetector.SCALE_PER_SCREEN; + changeZoomPosition((float) dz, 0); } private void changeZoomPosition(float dz, float angle) {