diff --git a/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java b/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java index e024eac2e4..9648565108 100644 --- a/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java +++ b/OsmAnd/src/net/osmand/plus/views/MultiTouchSupport.java @@ -3,6 +3,7 @@ package net.osmand.plus.views; import android.content.Context; import android.graphics.PointF; import android.view.MotionEvent; +import android.view.ViewConfiguration; import net.osmand.PlatformUtil; import net.osmand.util.MapUtils; @@ -77,6 +78,9 @@ public class MultiTouchSupport { private double zoomRelative = 1; private PointF centerPoint = new PointF(); + private final int mMoveZoomCenterSlop2 = ViewConfiguration.getScaledTouchSlop() * ViewConfiguration.getScaledTouchSlop() / 4; + private boolean mScrolling = false; + public boolean onTouchEvent(MotionEvent event){ if(!isMultiTouchSupported()){ return false; @@ -88,6 +92,7 @@ public class MultiTouchSupport { if(inZoomMode){ listener.onZoomOrRotationEnded(zoomRelative, angleRelative); inZoomMode = false; + mScrolling = false; return true; } return false; @@ -115,11 +120,17 @@ public class MultiTouchSupport { if(inZoomMode){ listener.onZoomOrRotationEnded(zoomRelative, angleRelative); inZoomMode = false; + mScrolling = false; } return true; } else if(inZoomMode && actionCode == MotionEvent.ACTION_MOVE){ // Keep zoom center fixed or flexible - centerPoint = new PointF((x1 + x2) / 2, (y1 + y2) / 2); + if (!mScrolling) { + mScrolling = ((centerPoint.x - (x1 + x2) / 2) * (centerPoint.x - (x1 + x2) / 2) + (centerPoint.y - (y1 + y2) / 2) * (centerPoint.y - (y1 + y2) / 2)) > mMoveZoomCenterSlop2; + } + if (mScrolling) { + centerPoint = new PointF((x1 + x2) / 2, (y1 + y2) / 2); + } if(angleDefined) { angleRelative = MapUtils.unifyRotationTo360(angle - angleStarted);