diff options
author | Łukasz Paczos <lukas.paczos@gmail.com> | 2019-03-12 12:07:49 +0100 |
---|---|---|
committer | Łukasz Paczos <lukasz.paczos@mapbox.com> | 2019-03-12 13:10:19 +0100 |
commit | 2a4b67f4ae2665d9166b1ceb6d37fa44afa67400 (patch) | |
tree | 9f209c086724f11fdab5897d67e17b2dfb91b583 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox | |
parent | e27f33062994a1b0155b44b9d471e48e93b09f8e (diff) | |
download | qtlocation-mapboxgl-2a4b67f4ae2665d9166b1ceb6d37fa44afa67400.tar.gz |
[android] fix quick-zoom + double-tap gestures combo regression
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index 43dd168016..c9e6e633aa 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -78,6 +78,9 @@ final class MapGestureDetector { private AndroidGesturesManager gesturesManager; + // Manages when to ignore double-tap event because we've started the quick-zoom. See #14013. + private boolean executeDoubleTap; + private Animator scaleAnimator; private Animator rotateAnimator; private final List<Animator> scheduledAnimators = new ArrayList<>(); @@ -353,7 +356,11 @@ final class MapGestureDetector { public boolean onDoubleTapEvent(MotionEvent motionEvent) { int action = motionEvent.getActionMasked(); if (action == MotionEvent.ACTION_DOWN) { - if (!uiSettings.isZoomGesturesEnabled() || !uiSettings.isDoubleTapGesturesEnabled()) { + executeDoubleTap = true; + } + + if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) { + if (!uiSettings.isZoomGesturesEnabled() || !uiSettings.isDoubleTapGesturesEnabled() || !executeDoubleTap) { return false; } @@ -368,9 +375,7 @@ final class MapGestureDetector { } zoomInAnimated(zoomFocalPoint, false); - } - if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) { sendTelemetryEvent(TelemetryConstants.DOUBLE_TAP, new PointF(motionEvent.getX(), motionEvent.getY())); return true; } @@ -474,15 +479,24 @@ final class MapGestureDetector { @Override public boolean onScaleBegin(@NonNull StandardScaleGestureDetector detector) { + quickZoom = detector.getPointersCount() == 1; + if (quickZoom) { + // Unfortunately, the double-tap event is returned by the framework when the second `ACTION_DOWN` event + // is registered in the right interval, regardless of the following `ACTION_MOVE` events. + // That's why, the quick-zoom gives us a handy reference when we've exceeded the movement threshold + // and we should ignore the double-tap. + executeDoubleTap = false; + } + if (!uiSettings.isZoomGesturesEnabled()) { return false; } - quickZoom = detector.getPointersCount() == 1; if (quickZoom) { if (!uiSettings.isQuickZoomGesturesEnabled()) { return false; } + // when quickzoom, disable move gesture gesturesManager.getMoveGestureDetector().setEnabled(false); } |