diff --git a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java index 63d82ecc26..472899862b 100644 --- a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java +++ b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java @@ -445,7 +445,7 @@ public class TargetPointsHelper { Location lastKnownLocation = ctx.getLocationProvider().getLastKnownLocation(); LatLon latLon = lastKnownLocation != null ? new LatLon(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude()) : null; - RoutingHelperUtils.checkAndUpdateStartLocation(ctx, latLon); + RoutingHelperUtils.checkAndUpdateStartLocation(ctx, latLon, false); setMyLocationPoint(latLon, false, null); } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 10fa1a066b..0f27fc6e26 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1408,6 +1408,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven updateMapSettings(); app.getPoiFilters().loadSelectedPoiFilters(); mapViewTrackingUtilities.updateSettings(); + mapViewTrackingUtilities.resetDrivingRegionUpdate(); //app.getRoutingHelper().setAppMode(settings.getApplicationMode()); if (mapLayers.getMapInfoLayer() != null) { mapLayers.getMapInfoLayer().recreateControls(); diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index fa66a5c91a..14a6623eae 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -13,8 +13,6 @@ import net.osmand.data.LatLon; import net.osmand.data.RotatedTileBox; import net.osmand.map.IMapLocationListener; import net.osmand.map.WorldRegion; -import net.osmand.plus.mapmarkers.MapMarker; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; @@ -22,10 +20,14 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.dashboard.DashboardOnMap; +import net.osmand.plus.helpers.enums.DrivingRegion; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu; +import net.osmand.plus.mapmarkers.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelperUtils; +import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmandMapTileView; @@ -176,7 +178,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc locationProvider = location.getProvider(); if (settings.DRIVING_REGION_AUTOMATIC.get() && !drivingRegionUpdated && !app.isApplicationInitializing()) { drivingRegionUpdated = true; - RoutingHelperUtils.checkAndUpdateStartLocation(app, location); + RoutingHelperUtils.checkAndUpdateStartLocation(app, location, true); } } if (mapView != null) { @@ -489,7 +491,15 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc @Override protected void onPostExecute(WorldRegion worldRegion) { if (worldRegion != null) { + DrivingRegion oldRegion = app.getSettings().DRIVING_REGION.get(); + app.setupDrivingRegion(worldRegion); + + DrivingRegion currentRegion = app.getSettings().DRIVING_REGION.get(); + if (oldRegion.leftHandDriving != currentRegion.leftHandDriving) { + ApplicationMode mode = app.getRoutingHelper().getAppMode(); + app.getRoutingHelper().onSettingsChanged(mode, true); + } } } } diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 03af123cc8..1addb2f50a 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -194,7 +194,7 @@ public class RoutingHelper { } public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, List intermediatePoints, Location currentLocation) { - RoutingHelperUtils.checkAndUpdateStartLocation(app, currentLocation); + RoutingHelperUtils.checkAndUpdateStartLocation(app, currentLocation, false); RouteCalculationResult previousRoute = route; clearCurrentRoute(finalLocation, intermediatePoints); // to update route diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelperUtils.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelperUtils.java index b756238eca..6803a2920f 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelperUtils.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelperUtils.java @@ -8,9 +8,6 @@ import net.osmand.data.LatLon; import net.osmand.data.QuadRect; import net.osmand.plus.OsmandApplication; import net.osmand.plus.TargetPointsHelper; -import net.osmand.plus.helpers.enums.MetricsConstants; -import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.util.MapUtils; import java.util.List; @@ -164,19 +161,20 @@ public class RoutingHelperUtils { } - public static void checkAndUpdateStartLocation(@NonNull OsmandApplication app, LatLon newStartLocation) { + public static void checkAndUpdateStartLocation(@NonNull OsmandApplication app, LatLon newStartLocation, boolean force) { if (newStartLocation != null) { LatLon lastStartLocation = app.getSettings().getLastStartPoint(); - if (lastStartLocation == null || MapUtils.getDistance(newStartLocation, lastStartLocation) > CACHE_RADIUS) { + if (lastStartLocation == null || MapUtils.getDistance(newStartLocation, lastStartLocation) > CACHE_RADIUS || force) { app.getMapViewTrackingUtilities().detectDrivingRegion(newStartLocation); app.getSettings().setLastStartPoint(newStartLocation); } } } - public static void checkAndUpdateStartLocation(@NonNull OsmandApplication app, Location nextStartLocation) { + public static void checkAndUpdateStartLocation(@NonNull OsmandApplication app, Location nextStartLocation, boolean force) { if (nextStartLocation != null) { - checkAndUpdateStartLocation(app, new LatLon(nextStartLocation.getLatitude(), nextStartLocation.getLongitude())); + LatLon newStartLocation = new LatLon(nextStartLocation.getLatitude(), nextStartLocation.getLongitude()); + checkAndUpdateStartLocation(app, newStartLocation, force); } } }