diff --git a/docs/Changelog.md b/docs/Changelog.md index 1ecfbf2a..c2b3d68d 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -8,6 +8,7 @@ - Mapbox vector tiles [#57](https://github.com/mapsforge/vtm/issues/57) - PathLayer (vtm) fix disappearing segments [#108](https://github.com/mapsforge/vtm/issues/108) - House numbers (nodes) fix visibility [#168](https://github.com/mapsforge/vtm/issues/168) +- Android fix quick scale vs long press [#250](https://github.com/mapsforge/vtm/issues/250) - Use baseline 160dpi in scaling [#236](https://github.com/mapsforge/vtm/issues/236) - MapFileTileSource zoom level API enhancements [#219](https://github.com/mapsforge/vtm/issues/219) - Animator enhancements with easing functions [#246](https://github.com/mapsforge/vtm/issues/246) diff --git a/vtm-android/src/org/oscim/android/input/GestureHandler.java b/vtm-android/src/org/oscim/android/input/GestureHandler.java index 03ffc8b7..fc875a06 100644 --- a/vtm-android/src/org/oscim/android/input/GestureHandler.java +++ b/vtm-android/src/org/oscim/android/input/GestureHandler.java @@ -1,3 +1,20 @@ +/* + * Copyright 2013 Hannes Janetzek + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.android.input; import android.view.GestureDetector.OnDoubleTapListener; @@ -11,16 +28,18 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener { private final AndroidMotionEvent mMotionEvent; private final Map mMap; + // Quick scale (double tap + swipe) + protected boolean quickScale; + public GestureHandler(Map map) { mMotionEvent = new AndroidMotionEvent(); mMap = map; } - /* GesturListener */ + /* OnGestureListener */ @Override public boolean onSingleTapUp(MotionEvent e) { - // return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e)); return false; } @@ -35,6 +54,10 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener { @Override public void onLongPress(MotionEvent e) { + // Quick scale (no long press) + if (quickScale) + return; + mMap.handleGesture(Gesture.LONG_PRESS, mMotionEvent.wrap(e)); } @@ -45,10 +68,13 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener { @Override public boolean onDown(MotionEvent e) { + quickScale = false; + return mMap.handleGesture(Gesture.PRESS, mMotionEvent.wrap(e)); } - /* DoubleTapListener */ + /* OnDoubleTapListener */ + @Override public boolean onSingleTapConfirmed(MotionEvent e) { return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e)); @@ -56,6 +82,11 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener { @Override public boolean onDoubleTapEvent(MotionEvent e) { + int action = e.getActionMasked(); + + // Quick scale + quickScale = (action == MotionEvent.ACTION_MOVE); + return false; }