protected boolean setValue(SharedPreferences prefs, String val) { if (val == null) { val = RendererRegistry.DEFAULT_RENDER; } BaseOsmandRender loaded = ctx.getRendererRegistry().getRenderer(val); if (loaded != null) { ctx.getRendererRegistry().setCurrentSelectedRender(loaded); super.setValue(prefs, val); ctx.getResourceManager().getRenderer().clearCache(); return true; } return false; };
protected void switchApplicationMode(ApplicationMode oldMode) { // change some global settings/ for car if (currentMode == ApplicationMode.CAR) { SHOW_TRANSPORT_OVER_MAP.set(false); SHOW_OSM_BUGS.set(false); } // update vector renderer RendererRegistry registry = ctx.getRendererRegistry(); BaseOsmandRender newRenderer = registry.getRenderer(RENDERER.get()); if (newRenderer == null) { newRenderer = registry.defaultRender(); } if (registry.getCurrentSelectedRenderer() != newRenderer) { registry.setCurrentSelectedRender(newRenderer); ctx.getResourceManager().getRenderer().clearCache(); } }
public PoiFilter getPoiFilterForMap(OsmandApplication application) { String filterId = globalPreferences.getString(SELECTED_POI_FILTER_FOR_MAP, null); PoiFilter filter = application.getPoiFilters().getFilterById(filterId); if (filter != null) { return filter; } return new PoiFilter(null, application); }
// TODO make all layers profile preferenced???? private OsmandSettings(OsmandApplication ctx) { this.ctx = ctx; globalPreferences = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); // start from default settings currentMode = ApplicationMode.DEFAULT; defaultProfilePreferences = getProfilePreferences(ApplicationMode.DEFAULT); profilePreferences = defaultProfilePreferences; // if(FOLLOW_TO_THE_ROUTE.get()){ currentMode = readApplicationMode(); profilePreferences = getProfilePreferences(currentMode); // } }
public boolean isInternetConnectionAvailable(boolean update) { long delta = System.currentTimeMillis() - lastTimeInternetConnectionChecked; if (delta < 0 || delta > 15000 || update) { ConnectivityManager mgr = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo active = mgr.getActiveNetworkInfo(); if (active == null) { internetConnectionAvailable = false; } else { NetworkInfo.State state = active.getState(); internetConnectionAvailable = state != NetworkInfo.State.DISCONNECTED && state != NetworkInfo.State.DISCONNECTING; } } return internetConnectionAvailable; }
public ITileSource getTileSourceByName(String tileName, boolean warnWhenSelected) { if (tileName == null || tileName.length() == 0) { return null; } List<TileSourceTemplate> knownTemplates = TileSourceManager.getKnownSourceTemplates(); File tPath = extendOsmandPath(ResourceManager.TILES_PATH); File dir = new File(tPath, tileName); if (!dir.exists()) { TileSourceTemplate ret = checkAmongAvailableTileSources(dir, knownTemplates); if (ret != null) { return ret; } // try to find among other templates ret = checkAmongAvailableTileSources(dir, getInternetAvailableSourceTemplates()); if (ret != null) { return ret; } } else if (tileName.endsWith(SQLiteTileSource.EXT)) { return new SQLiteTileSource(dir, knownTemplates); } else if (dir.isDirectory() && !dir.getName().startsWith(".")) { TileSourceTemplate t = TileSourceManager.createTileSourceTemplate(dir); if (warnWhenSelected && !t.isRuleAcceptable()) { Toast.makeText( ctx, ctx.getString(R.string.warning_tile_layer_not_downloadable, dir.getName()), Toast.LENGTH_SHORT) .show(); } if (!TileSourceManager.isTileSourceMetaInfoExist(dir)) { TileSourceTemplate ret = checkAmongAvailableTileSources(dir, knownTemplates); if (ret != null) { t = ret; } else { // try to find among other templates ret = checkAmongAvailableTileSources(dir, getInternetAvailableSourceTemplates()); if (ret != null) { t = ret; } } } return t; } return null; }
private SharedPreferences getProfilePreferences(ApplicationMode mode) { return ctx.getSharedPreferences(getSharedPreferencesName(mode), Context.MODE_WORLD_READABLE); }
protected boolean setValue(SharedPreferences prefs, DayNightMode val) { ctx.getDaynightHelper().setDayNightMode(val); return super.setValue(prefs, val); }