Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Fix quick-zoom + double-tap gestures combo regression #14084

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<>();
Expand Down Expand Up @@ -353,7 +356,11 @@ public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
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;
}

Expand All @@ -368,9 +375,7 @@ public boolean onDoubleTapEvent(MotionEvent motionEvent) {
}

zoomInAnimated(zoomFocalPoint, false);
}

if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
sendTelemetryEvent(TelemetryConstants.DOUBLE_TAP, new PointF(motionEvent.getX(), motionEvent.getY()));
return true;
}
Expand Down Expand Up @@ -474,15 +479,24 @@ private final class ScaleGestureListener extends StandardScaleGestureDetector.Si

@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);
}

Expand Down