From 1f0fdc331140f69d5389ef35f405fe3076fdcf48 Mon Sep 17 00:00:00 2001 From: sonora Date: Tue, 3 Jan 2017 12:40:32 +0100 Subject: [PATCH] test having slop distance for pinch zoom center move --- .../net/osmand/plus/views/MultiTouchSupport.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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);