From e8d47269f808845acdc5b3d76033428ac1fb630e Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 22 Sep 2016 16:30:24 +0200 Subject: [PATCH] [android] #5737 - disable tracking when a camera change occurs, treat camera change equal to gesture (#6414) --- .../java/com/mapbox/mapboxsdk/maps/MapView.java | 5 +++-- .../java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) 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 02d352c7f4c..6896e9a2369 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 @@ -2571,7 +2571,7 @@ boolean isPermissionsAccepted() { ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED; } - private void resetTrackingModesIfRequired() { + void resetTrackingModesIfRequired() { TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); if (trackingSettings.isDismissLocationTrackingOnGesture()) { resetLocationTrackingMode(); @@ -2592,7 +2592,8 @@ private void resetLocationTrackingMode() { private void resetBearingTrackingMode() { try { - setMyBearingTrackingMode(MyBearingTracking.NONE); + TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); + trackingSettings.setMyBearingTrackingMode(MyBearingTracking.NONE); } catch (SecurityException ignore) { // User did not accept location permissions } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index d99800863ee..2abf6f53fd7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -368,6 +368,11 @@ public final void moveCamera(CameraUpdate update) { */ @UiThread public final void moveCamera(CameraUpdate update, MapboxMap.CancelableCallback callback) { + // dismiss tracking, moving camera is equal to a gesture + if (!trackingSettings.isLocationTrackingDisabled()) { + mapView.resetTrackingModesIfRequired(); + } + cameraPosition = update.getCameraPosition(this); mapView.jumpTo(cameraPosition.bearing, cameraPosition.target, cameraPosition.tilt, cameraPosition.zoom); if (callback != null) { @@ -433,6 +438,11 @@ public final void easeCamera(CameraUpdate update, int durationMs, boolean easing @UiThread public final void easeCamera( CameraUpdate update, int durationMs, boolean easingInterpolator, final MapboxMap.CancelableCallback callback) { + // dismiss tracking, moving camera is equal to a gesture + if (!trackingSettings.isLocationTrackingDisabled()) { + mapView.resetTrackingModesIfRequired(); + } + cameraPosition = update.getCameraPosition(this); mapView.easeTo(cameraPosition.bearing, cameraPosition.target, getDurationNano(durationMs), cameraPosition.tilt, cameraPosition.zoom, easingInterpolator, new CancelableCallback() { @@ -521,6 +531,11 @@ public final void animateCamera(CameraUpdate update, int durationMs) { */ @UiThread public final void animateCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) { + // dismiss tracking, moving camera is equal to a gesture + if (!trackingSettings.isLocationTrackingDisabled() && trackingSettings.isDismissLocationTrackingOnGesture()) { + mapView.resetTrackingModesIfRequired(); + } + cameraPosition = update.getCameraPosition(this); mapView.flyTo(cameraPosition.bearing, cameraPosition.target, getDurationNano(durationMs), cameraPosition.tilt, cameraPosition.zoom, new CancelableCallback() {