implement auto change rendering style
git-svn-id: https://osmand.googlecode.com/svn/trunk@711 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
a960420436
commit
361af621ec
3 changed files with 31 additions and 4 deletions
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue