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

Commit

Permalink
[android] #5737 - disable tracking when a camera change occurs, treat…
Browse files Browse the repository at this point in the history
… camera change equal to gesture (#6414)
  • Loading branch information
tobrun authored and zugaldia committed Sep 22, 2016
1 parent d3eaf98 commit e8d4726
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit e8d4726

Please sign in to comment.