summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java24
1 files changed, 19 insertions, 5 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 33e13c5ecc..3607703ab1 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
@@ -57,6 +57,7 @@ final class MapGestureDetector {
private boolean quickZoom = false;
private boolean scrollInProgress = false;
private boolean scaleGestureOccurred = false;
+ private boolean recentScaleGestureOccurred = false;
MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings,
TrackingSettings trackingSettings, AnnotationManager annotationManager,
@@ -148,7 +149,7 @@ final class MapGestureDetector {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
// First pointer down, reset scaleGestureOccurred, used to avoid triggering a fling after a scale gesture #7666
- scaleGestureOccurred = false;
+ recentScaleGestureOccurred = false;
transform.setGestureInProgress(true);
break;
@@ -274,7 +275,7 @@ final class MapGestureDetector {
break;
case MotionEvent.ACTION_UP:
if (quickZoom) {
- // insert here?
+ cameraChangeDispatcher.onCameraIdle();
quickZoom = false;
break;
}
@@ -341,12 +342,11 @@ final class MapGestureDetector {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
- if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || scaleGestureOccurred) {
+ if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || recentScaleGestureOccurred) {
// don't allow a fling is scroll is disabled
// and ignore when a scale gesture has occurred
return false;
}
- cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
float screenDensity = uiSettings.getPixelRatio();
@@ -362,6 +362,8 @@ final class MapGestureDetector {
// cancel any animation
transform.cancelTransitions();
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
+
// tilt results in a bigger translation, limiting input for #5281
double tilt = transform.getTilt();
double tiltFactor = 1 + ((tilt != 0) ? (tilt / 10) : 0); /* 1 -> 7 */
@@ -391,12 +393,17 @@ final class MapGestureDetector {
return false;
}
+ if (scaleGestureOccurred) {
+ return false;
+ }
+
if (!scrollInProgress) {
scrollInProgress = true;
// Cancel any animation
transform.cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
+
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
getLocationFromGesture(e1.getX(), e1.getY()),
MapboxEvent.GESTURE_PAN_START, transform));
@@ -431,6 +438,7 @@ final class MapGestureDetector {
}
scaleGestureOccurred = true;
+ recentScaleGestureOccurred = true;
beginTime = detector.getEventTime();
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
getLocationFromGesture(detector.getFocusX(), detector.getFocusY()),
@@ -441,9 +449,11 @@ final class MapGestureDetector {
// Called when fingers leave screen
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
+ scaleGestureOccurred = false;
beginTime = 0;
scaleFactor = 1.0f;
zoomStarted = false;
+ cameraChangeDispatcher.onCameraIdle();
}
// Called each time a finger moves
@@ -479,6 +489,9 @@ final class MapGestureDetector {
}
// Gesture is a quickzoom if there aren't two fingers
+ if (!quickZoom && !twoTap) {
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
+ }
quickZoom = !twoTap;
// make an assumption here; if the zoom center is specified by the gesture, it's NOT going
@@ -491,6 +504,7 @@ final class MapGestureDetector {
// arround user provided focal point
transform.zoomBy(Math.log(detector.getScaleFactor()) / Math.log(2), focalPoint.x, focalPoint.y);
} else if (quickZoom) {
+ cameraChangeDispatcher.onCameraMove();
// clamp scale factors we feed to core #7514
float scaleFactor = MathUtils.clamp(detector.getScaleFactor(),
MapboxConstants.MINIMUM_SCALE_FACTOR_CLAMP,
@@ -552,7 +566,7 @@ final class MapGestureDetector {
// If rotate is large enough ignore a tap
// Also is zoom already started, don't rotate
totalAngle += detector.getRotationDegreesDelta();
- if (!zoomStarted && ((totalAngle > 20.0f) || (totalAngle < -20.0f))) {
+ if (totalAngle > 20.0f || totalAngle < -20.0f) {
started = true;
}