diff --git a/OsmAnd/src/net/osmand/activities/MapActivity.java b/OsmAnd/src/net/osmand/activities/MapActivity.java index 867e7e2ec1..3b35310a9f 100644 --- a/OsmAnd/src/net/osmand/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/activities/MapActivity.java @@ -1098,10 +1098,11 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso public void onClick(DialogInterface dialog, int which) { ApplicationMode mode = getAppMode(buttons); // change global settings - if (OsmandSettings.getApplicationMode(settings) != mode) { + ApplicationMode old = OsmandSettings.getApplicationMode(settings); + if (old != mode) { Editor edit = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, MODE_WORLD_WRITEABLE).edit(); edit.putString(OsmandSettings.APPLICATION_MODE, mode.name()); - SettingsActivity.setAppMode(mode, edit); + SettingsActivity.setAppMode(mode, edit, (OsmandApplication) getApplication(), old); edit.commit(); updateApplicationModeSettings(); mapView.refreshMap(); diff --git a/OsmAnd/src/net/osmand/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/activities/SettingsActivity.java index fe768c0158..a377b4d588 100644 --- a/OsmAnd/src/net/osmand/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/activities/SettingsActivity.java @@ -413,8 +413,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference edit.commit(); } else if(preference == applicationMode){ + ApplicationMode old = OsmandSettings.getApplicationMode(prefs); edit.putString(OsmandSettings.APPLICATION_MODE, (String) newValue); - setAppMode(ApplicationMode.valueOf(newValue.toString()), edit); + setAppMode(ApplicationMode.valueOf(newValue.toString()), edit, (OsmandApplication) getApplication(), old); edit.commit(); updateAllSettings(); } else if(preference == mapScreenOrientation){ @@ -563,7 +564,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference } } - public static void setAppMode(ApplicationMode preset, Editor edit){ + public static void setAppMode(ApplicationMode preset, Editor edit, OsmandApplication application, ApplicationMode old){ if(preset == ApplicationMode.CAR){ OsmandSettings.setUseInternetToDownloadTiles(true, edit); // edit.putBoolean(OsmandSettings.SHOW_POI_OVER_MAP, _); @@ -621,6 +622,23 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference // edit.putString(OsmandSettings.MAP_TILE_SOURCES, _); } + + BaseOsmandRender current = RendererRegistry.getRegistry().getCurrentSelectedRenderer(); + BaseOsmandRender defaultRender = RendererRegistry.getRegistry().defaultRender(); + boolean change = current == defaultRender || (old == ApplicationMode.CAR && + current == RendererRegistry.getRegistry().carRender()); + if(change){ + BaseOsmandRender newRenderer; + if(preset == ApplicationMode.CAR){ + newRenderer = RendererRegistry.getRegistry().carRender(); + } else { + newRenderer = defaultRender; + } + if(newRenderer != current){ + RendererRegistry.getRegistry().setCurrentSelectedRender(newRenderer); + application.getResourceManager().getRenderer().clearCache(); + } + } } @Override diff --git a/OsmAnd/src/net/osmand/render/RendererRegistry.java b/OsmAnd/src/net/osmand/render/RendererRegistry.java index b1c94316b8..595ffea147 100644 --- a/OsmAnd/src/net/osmand/render/RendererRegistry.java +++ b/OsmAnd/src/net/osmand/render/RendererRegistry.java @@ -66,6 +66,14 @@ public class RendererRegistry { return defaultRender; } + public BaseOsmandRender carRender() { + BaseOsmandRender renderer = getRenderer(CAR_RENDER); + if(renderer == null){ + return defaultRender(); + } + return renderer; + } + public BaseOsmandRender getRenderer(String name){ if(renderers.containsKey(name)){ return renderers.get(name);