diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index f41b510533..85401207aa 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -456,6 +456,11 @@ public class MapActivity extends AccessibleActivity implements } } + public void changeZoom(int stp, long time) { + mapViewTrackingUtilities.setZoomTime(time); + changeZoom(stp); + } + public void changeZoom(int stp){ // delta = Math.round(delta * OsmandMapTileView.ZOOM_DELTA) * OsmandMapTileView.ZOOM_DELTA_1; boolean changeLocation = false; diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index f51e2c75c2..05eea78699 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -1,5 +1,7 @@ package net.osmand.plus.base; +import java.util.Calendar; +import java.util.Date; import java.util.List; import net.osmand.Location; @@ -36,7 +38,8 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc private boolean followingMode; private boolean routePlanningMode; private boolean showViewAngle = false; - + private boolean isUserZoomed = false; + public MapViewTrackingUtilities(OsmandApplication app){ this.app = app; settings = app.getSettings(); @@ -196,7 +199,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc // decrease a bit zdelta += 1; } - if (now - lastTimeAutoZooming > 4500) { + int threshold = settings.AUTO_FOLLOW_ROUTE.get(); + if (now - lastTimeAutoZooming > 4500 && (now - lastTimeAutoZooming > threshold || !isUserZoomed)) { + isUserZoomed = false; lastTimeAutoZooming = now; double settingsZoomScale = mapView.getSettingsZoomScale(); double complexZoom = tb.getZoom() + tb.getZoomScale() + zdelta; @@ -320,5 +325,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc public void routeWasCancelled() { } + public void setZoomTime(long time) { + lastTimeAutoZooming = time; + isUserZoomed = true; + } } diff --git a/OsmAnd/src/net/osmand/plus/views/controls/MapZoomControls.java b/OsmAnd/src/net/osmand/plus/views/controls/MapZoomControls.java index 548a290b57..bdd7cc729f 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/MapZoomControls.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/MapZoomControls.java @@ -4,6 +4,7 @@ import android.view.Gravity; import gnu.trove.list.array.TIntArrayList; import java.util.ArrayList; +import java.util.Calendar; import java.util.List; import net.osmand.data.RotatedTileBox; @@ -83,9 +84,9 @@ public class MapZoomControls extends MapControls { public void onClick(View v) { notifyClicked(); if (view.isZooming()) { - mapActivity.changeZoom(2); + mapActivity.changeZoom(2, System.currentTimeMillis()); } else { - mapActivity.changeZoom(1); + mapActivity.changeZoom(1, System.currentTimeMillis()); } } @@ -95,8 +96,9 @@ public class MapZoomControls extends MapControls { zoomOutButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + long time = Calendar.getInstance().getTime().getTime(); notifyClicked(); - mapActivity.changeZoom(-1); + mapActivity.changeZoom(-1, System.currentTimeMillis()); } }); zoomOutButton.setOnLongClickListener(listener);