summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Paczos <lukasz.paczos@mapbox.com>2018-02-21 10:51:03 +0100
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2018-02-21 10:59:52 +0100
commite79a07db385dbe9c683393c46c67c6f255bb3567 (patch)
tree7d8b88406cd63faf7cd1b8d7bc8d76458e6d4c32
parent8fe21111f2810cc32eb7c43b2206ca9aa9da4d05 (diff)
downloadqtlocation-mapboxgl-e79a07db385dbe9c683393c46c67c6f255bb3567.tar.gz
[android] new gesture library - removed tracking setting
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java40
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java2
2 files changed, 12 insertions, 30 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 7673b76e26..ca05f54c00 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
@@ -39,16 +39,12 @@ import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener.RE
/**
* Manages gestures events on a MapView.
- * <p>
- * Relies on gesture detection code in almeros.android.multitouch.gesturedetectors.
- * </p>
*/
final class MapGestureDetector {
private final Transform transform;
private final Projection projection;
private final UiSettings uiSettings;
- private final TrackingSettings trackingSettings;
private final AnnotationManager annotationManager;
private final CameraChangeDispatcher cameraChangeDispatcher;
@@ -94,13 +90,11 @@ final class MapGestureDetector {
private Handler mainHandler = new Handler();
MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings,
- TrackingSettings trackingSettings, AnnotationManager annotationManager,
- CameraChangeDispatcher cameraChangeDispatcher) {
+ AnnotationManager annotationManager, CameraChangeDispatcher cameraChangeDispatcher) {
this.annotationManager = annotationManager;
this.transform = transform;
this.projection = projection;
this.uiSettings = uiSettings;
- this.trackingSettings = trackingSettings;
this.cameraChangeDispatcher = cameraChangeDispatcher;
// Touch gesture detectors
@@ -158,8 +152,8 @@ final class MapGestureDetector {
/**
* Get the current active gesture focal point.
* <p>
- * This could be either the user provided focal point in {@link UiSettings#setFocalPoint(PointF)} or the focal point
- * defined as a result of {@link TrackingSettings#setMyLocationEnabled(boolean)}.
+ * This could be either the user provided focal point in {@link UiSettings#setFocalPoint(PointF)} or <code>null</code>.
+ * If it's <code>null</code>, gestures will use focal pointed returned by the detector.
* </p>
*
* @return the current active gesture focal point.
@@ -234,6 +228,7 @@ final class MapGestureDetector {
// Zoom in on gesture
transform.zoom(true, new PointF(motionEvent.getX(), motionEvent.getY()));
}
+
if (isZoomValid(transform)) {
MapEventFactory mapEventFactory = new MapEventFactory();
LatLng latLng = projection.fromScreenLocation(new PointF(motionEvent.getX(), motionEvent.getY()));
@@ -277,7 +272,7 @@ final class MapGestureDetector {
* Examples of such events are mouse scroll events, mouse moves, joystick & trackpad.
* </p>
*
- * @param event The MotionEvent occured
+ * @param event The MotionEvent occurred
* @return True is the event is handled
*/
boolean onGenericMotionEvent(MotionEvent event) {
@@ -369,7 +364,7 @@ final class MapGestureDetector {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
- if ((!trackingSettings.isScrollGestureCurrentlyEnabled())) {
+ if ((!uiSettings.isScrollGesturesEnabled())) {
// don't allow a fling is scroll is disabled
return false;
}
@@ -383,8 +378,6 @@ final class MapGestureDetector {
return false;
}
- trackingSettings.resetTrackingModesIfRequired(true, false, false);
-
cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
// tilt results in a bigger translation, limiting input for #5281
@@ -408,7 +401,7 @@ final class MapGestureDetector {
private final class MoveGestureListener extends MoveGestureDetector.SimpleOnMoveGestureListener {
@Override
public boolean onMoveBegin(MoveGestureDetector detector) {
- if (!trackingSettings.isScrollGestureCurrentlyEnabled()) {
+ if (!uiSettings.isScrollGesturesEnabled()) {
return false;
}
@@ -423,9 +416,6 @@ final class MapGestureDetector {
Events.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, pan));
}
- // reset tracking if needed
- trackingSettings.resetTrackingModesIfRequired(true, false, false);
-
notifyOnMoveBeginListeners(detector);
return true;
@@ -454,7 +444,7 @@ final class MapGestureDetector {
private PointF scaleFocalPoint;
private boolean quickZoom;
- public ScaleGestureListener(float minimumVelocity) {
+ ScaleGestureListener(float minimumVelocity) {
this.minimumVelocity = minimumVelocity;
}
@@ -476,8 +466,6 @@ final class MapGestureDetector {
gesturesManager.getMoveGestureDetector().setEnabled(false);
}
- trackingSettings.resetTrackingModesIfRequired(!quickZoom, false, false);
-
if (focalPoint != null) {
// around user provided focal point
scaleFocalPoint = focalPoint;
@@ -531,10 +519,8 @@ final class MapGestureDetector {
float velocityXY = Math.abs(velocityX) + Math.abs(velocityY);
if (velocityXY > minimumVelocity) {
double zoomAddition = calculateScale(velocityXY, detector.isScalingOut());
- Timber.d("velocity: " + velocityXY + ", zoom: " + zoomAddition);
double currentZoom = transform.getRawZoom();
- //long animationTime = TimeUnit.SECONDS.toMillis((long) Math.abs(zoomAddition)) / 4; //todo make divider public
- long animationTime = (long) (Math.abs(zoomAddition) * 1000 / 4);
+ long animationTime = (long) (Math.abs(zoomAddition) * 1000 / 4); //todo make divider public
scaleAnimator = createScaleAnimator(currentZoom, zoomAddition, animationTime);
scheduleAnimator(scaleAnimator);
}
@@ -601,21 +587,17 @@ final class MapGestureDetector {
private final float minimumScaleSpanWhenRotating;
private final float minimumAngularVelocity;
- public RotateGestureListener(float minimumScaleSpanWhenRotating, float minimumAngularVelocity) {
+ RotateGestureListener(float minimumScaleSpanWhenRotating, float minimumAngularVelocity) {
this.minimumScaleSpanWhenRotating = minimumScaleSpanWhenRotating;
this.minimumAngularVelocity = minimumAngularVelocity;
}
@Override
public boolean onRotateBegin(RotateGestureDetector detector) {
- if (!trackingSettings.isRotateGestureCurrentlyEnabled()) {
+ if (!uiSettings.isRotateGesturesEnabled()) {
return false;
}
- // rotation constitutes translation of anything except the center of
- // rotation, so cancel both location and bearing tracking if required
- trackingSettings.resetTrackingModesIfRequired(true, true, false);
-
// notify camera change listener
cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index 92bbce3d74..42d2489432 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -186,7 +186,7 @@ public class MapView extends FrameLayout {
mapCallback.attachMapboxMap(mapboxMap);
// user input
- mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings, trackingSettings,
+ mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings,
annotationManager, cameraChangeDispatcher);
mapKeyListener = new MapKeyListener(transform, trackingSettings, uiSettings);