Android: fix quick scale vs long press, fixes #250
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
- Mapbox vector tiles [#57](https://github.com/mapsforge/vtm/issues/57)
|
- Mapbox vector tiles [#57](https://github.com/mapsforge/vtm/issues/57)
|
||||||
- PathLayer (vtm) fix disappearing segments [#108](https://github.com/mapsforge/vtm/issues/108)
|
- 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)
|
- 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)
|
- 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)
|
- 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)
|
- Animator enhancements with easing functions [#246](https://github.com/mapsforge/vtm/issues/246)
|
||||||
|
|||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package org.oscim.android.input;
|
package org.oscim.android.input;
|
||||||
|
|
||||||
import android.view.GestureDetector.OnDoubleTapListener;
|
import android.view.GestureDetector.OnDoubleTapListener;
|
||||||
@@ -11,16 +28,18 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener {
|
|||||||
private final AndroidMotionEvent mMotionEvent;
|
private final AndroidMotionEvent mMotionEvent;
|
||||||
private final Map mMap;
|
private final Map mMap;
|
||||||
|
|
||||||
|
// Quick scale (double tap + swipe)
|
||||||
|
protected boolean quickScale;
|
||||||
|
|
||||||
public GestureHandler(Map map) {
|
public GestureHandler(Map map) {
|
||||||
mMotionEvent = new AndroidMotionEvent();
|
mMotionEvent = new AndroidMotionEvent();
|
||||||
mMap = map;
|
mMap = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GesturListener */
|
/* OnGestureListener */
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTapUp(MotionEvent e) {
|
public boolean onSingleTapUp(MotionEvent e) {
|
||||||
// return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +54,10 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLongPress(MotionEvent e) {
|
public void onLongPress(MotionEvent e) {
|
||||||
|
// Quick scale (no long press)
|
||||||
|
if (quickScale)
|
||||||
|
return;
|
||||||
|
|
||||||
mMap.handleGesture(Gesture.LONG_PRESS, mMotionEvent.wrap(e));
|
mMap.handleGesture(Gesture.LONG_PRESS, mMotionEvent.wrap(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,10 +68,13 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onDown(MotionEvent e) {
|
public boolean onDown(MotionEvent e) {
|
||||||
|
quickScale = false;
|
||||||
|
|
||||||
return mMap.handleGesture(Gesture.PRESS, mMotionEvent.wrap(e));
|
return mMap.handleGesture(Gesture.PRESS, mMotionEvent.wrap(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DoubleTapListener */
|
/* OnDoubleTapListener */
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTapConfirmed(MotionEvent e) {
|
public boolean onSingleTapConfirmed(MotionEvent e) {
|
||||||
return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
|
return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
|
||||||
@@ -56,6 +82,11 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onDoubleTapEvent(MotionEvent e) {
|
public boolean onDoubleTapEvent(MotionEvent e) {
|
||||||
|
int action = e.getActionMasked();
|
||||||
|
|
||||||
|
// Quick scale
|
||||||
|
quickScale = (action == MotionEvent.ACTION_MOVE);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user