@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings_pref); String[] entries; String[] entrieValues; PreferenceScreen screen = getPreferenceScreen(); osmandSettings = OsmandSettings.getOsmandSettings(this); registerBooleanPreference(osmandSettings.SHOW_VIEW_ANGLE, screen); registerBooleanPreference(osmandSettings.USE_TRACKBALL_FOR_MOVEMENTS, screen); registerBooleanPreference(osmandSettings.USE_HIGH_RES_MAPS, screen); registerBooleanPreference(osmandSettings.USE_ENGLISH_NAMES, screen); registerBooleanPreference(osmandSettings.SHOW_MORE_MAP_DETAIL, screen); registerBooleanPreference(osmandSettings.AUTO_ZOOM_MAP, screen); registerBooleanPreference(osmandSettings.SAVE_TRACK_TO_GPX, screen); registerBooleanPreference(osmandSettings.DEBUG_RENDERING_INFO, screen); registerBooleanPreference(osmandSettings.USE_STEP_BY_STEP_RENDERING, screen); registerBooleanPreference(osmandSettings.FAST_ROUTE_MODE, screen); registerBooleanPreference(osmandSettings.USE_OSMAND_ROUTING_SERVICE_ALWAYS, screen); registerBooleanPreference(osmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES, screen); registerBooleanPreference(osmandSettings.MAP_VECTOR_DATA, screen); registerEditTextPreference(osmandSettings.USER_NAME, screen); registerEditTextPreference(osmandSettings.USER_PASSWORD, screen); registerSeekBarPreference(osmandSettings.MAP_OVERLAY_TRANSPARENCY, screen); registerSeekBarPreference(osmandSettings.MAP_TRANSPARENCY, screen); // List preferences registerListPreference( osmandSettings.ROTATE_MAP, screen, new String[] { getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt) }, new Integer[] { OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS }); registerListPreference( osmandSettings.MAP_SCREEN_ORIENTATION, screen, new String[] { getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default) }, new Integer[] { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED }); registerListPreference( osmandSettings.POSITION_ON_MAP, screen, new String[] { getString(R.string.position_on_map_center), getString(R.string.position_on_map_bottom) }, new Integer[] {OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT}); registerListPreference( osmandSettings.AUDIO_STREAM_GUIDANCE, screen, new String[] { getString(R.string.voice_stream_music), getString(R.string.voice_stream_notification), getString(R.string.voice_stream_voice_call) }, new Integer[] { AudioManager.STREAM_MUSIC, AudioManager.STREAM_NOTIFICATION, AudioManager.STREAM_VOICE_CALL }); entries = new String[DayNightMode.values().length]; for (int i = 0; i < entries.length; i++) { entries[i] = DayNightMode.values()[i].toHumanString(this); } registerListPreference(osmandSettings.DAYNIGHT_MODE, screen, entries, DayNightMode.values()); entries = new String[MetricsConstants.values().length]; for (int i = 0; i < entries.length; i++) { entries[i] = MetricsConstants.values()[i].toHumanString(this); } registerListPreference( osmandSettings.METRIC_SYSTEM, screen, entries, MetricsConstants.values()); // getResources().getAssets().getLocales(); entrieValues = new String[] {"", "en", "cs", "de", "es", "fr", "hu", "it", "pt", "ru", "sk"}; entries = new String[entrieValues.length]; entries[0] = getString(R.string.system_locale); for (int i = 1; i < entries.length; i++) { entries[i] = entrieValues[i]; } registerListPreference(osmandSettings.PREFERRED_LOCALE, screen, entries, entrieValues); int startZoom = 12; int endZoom = 19; entries = new String[endZoom - startZoom + 1]; Integer[] intValues = new Integer[endZoom - startZoom + 1]; for (int i = startZoom; i <= endZoom; i++) { entries[i - startZoom] = i + ""; // $NON-NLS-1$ intValues[i - startZoom] = i; } registerListPreference(osmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE, screen, entries, intValues); Float[] floatValues = new Float[] {0.6f, 0.8f, 1.0f, 1.2f, 1.5f}; entries = new String[floatValues.length]; for (int i = 0; i < floatValues.length; i++) { entries[i] = (int) (floatValues[i] * 100) + " %"; } registerListPreference(osmandSettings.MAP_TEXT_SIZE, screen, entries, floatValues); startZoom = 1; endZoom = 18; entries = new String[endZoom - startZoom + 1]; intValues = new Integer[endZoom - startZoom + 1]; for (int i = startZoom; i <= endZoom; i++) { entries[i - startZoom] = i + ""; // $NON-NLS-1$ intValues[i - startZoom] = i; } registerListPreference( osmandSettings.LEVEL_TO_SWITCH_VECTOR_RASTER, screen, entries, intValues); entries = new String[RouteService.values().length]; for (int i = 0; i < entries.length; i++) { entries[i] = RouteService.values()[i].getName(); } registerListPreference(osmandSettings.ROUTER_SERVICE, screen, entries, RouteService.values()); entries = new String[] {getString(R.string.gps_provider), getString(R.string.network_provider)}; entrieValues = new String[] {LocationManager.GPS_PROVIDER, LocationManager.NETWORK_PROVIDER}; registerListPreference(osmandSettings.SERVICE_OFF_PROVIDER, screen, entries, entrieValues); registerTimeListPreference( osmandSettings.SAVE_TRACK_INTERVAL, screen, new int[] {1, 2, 3, 5, 10, 15, 20, 30}, new int[] {1, 2, 3, 5}, 1); registerTimeListPreference( osmandSettings.SERVICE_OFF_INTERVAL, screen, new int[] {0, 30, 45, 60}, new int[] {2, 3, 5, 8, 10, 15, 20, 30, 40, 50, 70, 90}, 1000); registerTimeListPreference( osmandSettings.SERVICE_OFF_WAIT_INTERVAL, screen, new int[] {15, 30, 45, 60, 90}, new int[] {2, 3, 5, 10}, 1000); entries = new String[ApplicationMode.values().length]; for (int i = 0; i < entries.length; i++) { entries[i] = ApplicationMode.toHumanString(ApplicationMode.values()[i], this); } registerListPreference( osmandSettings.APPLICATION_MODE, screen, entries, ApplicationMode.values()); Collection<String> rendererNames = getMyApplication().getRendererRegistry().getRendererNames(); entries = (String[]) rendererNames.toArray(new String[rendererNames.size()]); registerListPreference(osmandSettings.RENDERER, screen, entries, entries); tileSourcePreference = (ListPreference) screen.findPreference(osmandSettings.MAP_TILE_SOURCES.getId()); tileSourcePreference.setOnPreferenceChangeListener(this); overlayPreference = (ListPreference) screen.findPreference(osmandSettings.MAP_OVERLAY.getId()); overlayPreference.setOnPreferenceChangeListener(this); underlayPreference = (ListPreference) screen.findPreference(osmandSettings.MAP_UNDERLAY.getId()); underlayPreference.setOnPreferenceChangeListener(this); Preference localIndexes = (Preference) screen.findPreference(OsmandSettings.LOCAL_INDEXES); localIndexes.setOnPreferenceClickListener(this); saveCurrentTrack = (Preference) screen.findPreference(OsmandSettings.SAVE_CURRENT_TRACK); saveCurrentTrack.setOnPreferenceClickListener(this); routeServiceEnabled = (CheckBoxPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_ENABLED); routeServiceEnabled.setOnPreferenceChangeListener(this); applicationDir = (EditTextPreference) screen.findPreference(OsmandSettings.EXTERNAL_STORAGE_DIR); applicationDir.setOnPreferenceChangeListener(this); broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { routeServiceEnabled.setChecked(false); } }; registerReceiver( broadcastReceiver, new IntentFilter(NavigationService.OSMAND_STOP_SERVICE_ACTION)); Intent intent = getIntent(); if (intent != null && intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0) != 0) { int s = intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0); String pref = null; if (s == SCREEN_GENERAL_SETTINGS) { pref = "general_settings"; } else if (s == SCREEN_NAVIGATION_SETTINGS) { pref = "routing_settings"; } else if (s == SCREEN_MONITORING_SETTINGS) { pref = "monitor_settings"; } if (pref != null) { Preference toOpen = screen.findPreference(pref); if (toOpen instanceof PreferenceScreen) { setPreferenceScreen((PreferenceScreen) toOpen); } } } }