fix small issues
git-svn-id: https://osmand.googlecode.com/svn/trunk@289 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
f186f7bc9d
commit
01662401f0
4 changed files with 101 additions and 91 deletions
|
@ -40,8 +40,8 @@ public class ToDoConstants {
|
||||||
// FIXME BUGS Android
|
// FIXME BUGS Android
|
||||||
// double tap to zoom [done]
|
// double tap to zoom [done]
|
||||||
// forbid rotate map to landscape [ done]
|
// forbid rotate map to landscape [ done]
|
||||||
|
// REFACTOR Settings activity ( for check box properties!) [partially done]
|
||||||
|
|
||||||
// REFACTOR Settings activity ( for check box properties!)
|
|
||||||
// show POI choose near by or last map selection.
|
// show POI choose near by or last map selection.
|
||||||
// Show poi direction (using sensor)
|
// Show poi direction (using sensor)
|
||||||
// hide center point (enable only when trackball using)
|
// hide center point (enable only when trackball using)
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 1.7 KiB |
|
@ -45,19 +45,21 @@ public class OsmandSettings {
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String USE_INTERNET_TO_DOWNLOAD_TILES = "use_internet_to_download_tiles"; //$NON-NLS-1$
|
public static final String USE_INTERNET_TO_DOWNLOAD_TILES = "use_internet_to_download_tiles"; //$NON-NLS-1$
|
||||||
|
public static final boolean USE_INTERNET_TO_DOWNLOAD_TILES_DEF = true;
|
||||||
|
|
||||||
public static boolean isUsingInternetToDownloadTiles(Context ctx) {
|
public static boolean isUsingInternetToDownloadTiles(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getBoolean(USE_INTERNET_TO_DOWNLOAD_TILES, true);
|
return prefs.getBoolean(USE_INTERNET_TO_DOWNLOAD_TILES, USE_INTERNET_TO_DOWNLOAD_TILES_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String SHOW_POI_OVER_MAP = "show_poi_over_map"; //$NON-NLS-1$
|
public static final String SHOW_POI_OVER_MAP = "show_poi_over_map"; //$NON-NLS-1$
|
||||||
|
public static final Boolean SHOW_POI_OVER_MAP_DEF = false;
|
||||||
|
|
||||||
public static boolean isShowingPoiOverMap(Context ctx) {
|
public static boolean isShowingPoiOverMap(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getBoolean(SHOW_POI_OVER_MAP, false);
|
return prefs.getBoolean(SHOW_POI_OVER_MAP, SHOW_POI_OVER_MAP_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean setShowPoiOverMap(Context ctx, boolean val) {
|
public static boolean setShowPoiOverMap(Context ctx, boolean val) {
|
||||||
|
@ -67,10 +69,11 @@ public class OsmandSettings {
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String SHOW_TRANSPORT_OVER_MAP = "show_transport_over_map"; //$NON-NLS-1$
|
public static final String SHOW_TRANSPORT_OVER_MAP = "show_transport_over_map"; //$NON-NLS-1$
|
||||||
|
public static final boolean SHOW_TRANSPORT_OVER_MAP_DEF = false;
|
||||||
|
|
||||||
public static boolean isShowingTransportOverMap(Context ctx) {
|
public static boolean isShowingTransportOverMap(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getBoolean(SHOW_TRANSPORT_OVER_MAP, false);
|
return prefs.getBoolean(SHOW_TRANSPORT_OVER_MAP, SHOW_TRANSPORT_OVER_MAP_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean setShowTransortOverMap(Context ctx, boolean val) {
|
public static boolean setShowTransortOverMap(Context ctx, boolean val) {
|
||||||
|
@ -145,10 +148,11 @@ public class OsmandSettings {
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String SAVE_TRACK_TO_GPX = "save_track_to_gpx"; //$NON-NLS-1$
|
public static final String SAVE_TRACK_TO_GPX = "save_track_to_gpx"; //$NON-NLS-1$
|
||||||
|
public static final boolean SAVE_TRACK_TO_GPX_DEF = false;
|
||||||
|
|
||||||
public static boolean isSavingTrackToGpx(Context ctx) {
|
public static boolean isSavingTrackToGpx(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getBoolean(SAVE_TRACK_TO_GPX, false);
|
return prefs.getBoolean(SAVE_TRACK_TO_GPX, SAVE_TRACK_TO_GPX_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
|
@ -161,10 +165,11 @@ public class OsmandSettings {
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String SHOW_OSM_BUGS = "show_osm_bugs"; //$NON-NLS-1$
|
public static final String SHOW_OSM_BUGS = "show_osm_bugs"; //$NON-NLS-1$
|
||||||
|
public static final boolean SHOW_OSM_BUGS_DEF = false;
|
||||||
|
|
||||||
public static boolean isShowingOsmBugs(Context ctx) {
|
public static boolean isShowingOsmBugs(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getBoolean(SHOW_OSM_BUGS, false);
|
return prefs.getBoolean(SHOW_OSM_BUGS, SHOW_OSM_BUGS_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
|
@ -177,26 +182,29 @@ public class OsmandSettings {
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String SHOW_VIEW_ANGLE = "show_view_angle"; //$NON-NLS-1$
|
public static final String SHOW_VIEW_ANGLE = "show_view_angle"; //$NON-NLS-1$
|
||||||
|
public static final boolean SHOW_VIEW_ANGLE_DEF = false;
|
||||||
|
|
||||||
public static boolean isShowingViewAngle(Context ctx) {
|
public static boolean isShowingViewAngle(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getBoolean(SHOW_VIEW_ANGLE, false);
|
return prefs.getBoolean(SHOW_VIEW_ANGLE, SHOW_VIEW_ANGLE_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String AUTO_ZOOM_MAP = "auto_zoom_map"; //$NON-NLS-1$
|
public static final String AUTO_ZOOM_MAP = "auto_zoom_map"; //$NON-NLS-1$
|
||||||
|
public static final boolean AUTO_ZOOM_MAP_DEF = false;
|
||||||
|
|
||||||
public static boolean isAutoZoomEnabled(Context ctx) {
|
public static boolean isAutoZoomEnabled(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getBoolean(AUTO_ZOOM_MAP, false);
|
return prefs.getBoolean(AUTO_ZOOM_MAP, AUTO_ZOOM_MAP_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String ROTATE_MAP_TO_BEARING = "rotate_map_to_bearing"; //$NON-NLS-1$
|
public static final String ROTATE_MAP_TO_BEARING = "rotate_map_to_bearing"; //$NON-NLS-1$
|
||||||
|
public static final boolean ROTATE_MAP_TO_BEARING_DEF = false;
|
||||||
|
|
||||||
public static boolean isRotateMapToBearing(Context ctx) {
|
public static boolean isRotateMapToBearing(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getBoolean(ROTATE_MAP_TO_BEARING, false);
|
return prefs.getBoolean(ROTATE_MAP_TO_BEARING, ROTATE_MAP_TO_BEARING_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
|
@ -217,18 +225,20 @@ public class OsmandSettings {
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String MAP_VIEW_3D = "map_view_3d"; //$NON-NLS-1$
|
public static final String MAP_VIEW_3D = "map_view_3d"; //$NON-NLS-1$
|
||||||
|
public static final boolean MAP_VIEW_3D_DEF = false;
|
||||||
|
|
||||||
public static boolean isMapView3D(Context ctx) {
|
public static boolean isMapView3D(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getBoolean(MAP_VIEW_3D, false);
|
return prefs.getBoolean(MAP_VIEW_3D, MAP_VIEW_3D_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public static final String USE_ENGLISH_NAMES = "use_english_names"; //$NON-NLS-1$
|
public static final String USE_ENGLISH_NAMES = "use_english_names"; //$NON-NLS-1$
|
||||||
|
public static final boolean USE_ENGLISH_NAMES_DEF = false;
|
||||||
|
|
||||||
public static boolean usingEnglishNames(Context ctx) {
|
public static boolean usingEnglishNames(Context ctx) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
return prefs.getBoolean(USE_ENGLISH_NAMES, false);
|
return prefs.getBoolean(USE_ENGLISH_NAMES, USE_ENGLISH_NAMES_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean setUseEnglishNames(Context ctx, boolean useEnglishNames) {
|
public static boolean setUseEnglishNames(Context ctx, boolean useEnglishNames) {
|
||||||
|
|
|
@ -32,28 +32,61 @@ import com.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||||
|
|
||||||
public class SettingsActivity extends PreferenceActivity implements OnPreferenceChangeListener, OnPreferenceClickListener {
|
public class SettingsActivity extends PreferenceActivity implements OnPreferenceChangeListener, OnPreferenceClickListener {
|
||||||
|
|
||||||
private CheckBoxPreference showPoiOnMap;
|
private class BooleanPreference {
|
||||||
private CheckBoxPreference useInternetToDownloadTiles;
|
private final boolean defValue;
|
||||||
private ListPreference tileSourcePreference;
|
private final String id;
|
||||||
private CheckBoxPreference rotateMapToBearing;
|
private CheckBoxPreference pref;
|
||||||
private CheckBoxPreference showViewAngle;
|
|
||||||
private ListPreference positionOnMap;
|
public BooleanPreference(String id, boolean defValue){
|
||||||
private CheckBoxPreference useEnglishNames;
|
this.id = id;
|
||||||
private CheckBoxPreference showOsmBugs;
|
this.defValue = defValue;
|
||||||
private EditTextPreference userName;
|
}
|
||||||
private CheckBoxPreference saveTrackToGpx;
|
|
||||||
private ListPreference saveTrackInterval;
|
public String getId() {
|
||||||
private Preference saveCurrentTrack;
|
return id;
|
||||||
private ListPreference applicationMode;
|
}
|
||||||
private CheckBoxPreference autoZoom;
|
|
||||||
|
public boolean getDefValue() {
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPref(CheckBoxPreference pref) {
|
||||||
|
this.pref = pref;
|
||||||
|
}
|
||||||
|
public CheckBoxPreference getPref() {
|
||||||
|
return pref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private EditTextPreference userPassword;
|
private EditTextPreference userPassword;
|
||||||
|
private EditTextPreference userName;
|
||||||
|
|
||||||
|
private Preference saveCurrentTrack;
|
||||||
private Preference reloadIndexes;
|
private Preference reloadIndexes;
|
||||||
private Preference downloadIndexes;
|
private Preference downloadIndexes;
|
||||||
|
|
||||||
|
private ListPreference applicationMode;
|
||||||
|
private ListPreference saveTrackInterval;
|
||||||
|
private ListPreference tileSourcePreference;
|
||||||
|
private ListPreference positionOnMap;
|
||||||
private ListPreference routerPreference;
|
private ListPreference routerPreference;
|
||||||
private ListPreference maxLevelToDownload;
|
private ListPreference maxLevelToDownload;
|
||||||
private CheckBoxPreference showTransport;
|
|
||||||
private ListPreference mapScreenOrientation;
|
private ListPreference mapScreenOrientation;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private BooleanPreference[] booleanPreferences = new BooleanPreference[]{
|
||||||
|
new BooleanPreference(OsmandSettings.SHOW_POI_OVER_MAP, OsmandSettings.SHOW_POI_OVER_MAP_DEF ),
|
||||||
|
new BooleanPreference(OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES, OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES_DEF),
|
||||||
|
new BooleanPreference(OsmandSettings.ROTATE_MAP_TO_BEARING, OsmandSettings.ROTATE_MAP_TO_BEARING_DEF),
|
||||||
|
new BooleanPreference(OsmandSettings.SHOW_VIEW_ANGLE, OsmandSettings.SHOW_VIEW_ANGLE_DEF),
|
||||||
|
new BooleanPreference(OsmandSettings.USE_ENGLISH_NAMES, OsmandSettings.USE_ENGLISH_NAMES_DEF),
|
||||||
|
new BooleanPreference(OsmandSettings.SHOW_OSM_BUGS, OsmandSettings.SHOW_OSM_BUGS_DEF),
|
||||||
|
new BooleanPreference(OsmandSettings.AUTO_ZOOM_MAP, OsmandSettings.AUTO_ZOOM_MAP_DEF),
|
||||||
|
new BooleanPreference(OsmandSettings.SHOW_TRANSPORT_OVER_MAP, OsmandSettings.SHOW_TRANSPORT_OVER_MAP_DEF),
|
||||||
|
new BooleanPreference(OsmandSettings.SAVE_TRACK_TO_GPX, OsmandSettings.SAVE_TRACK_TO_GPX_DEF),
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -63,41 +96,27 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
applicationMode =(ListPreference) screen.findPreference(OsmandSettings.APPLICATION_MODE);
|
applicationMode =(ListPreference) screen.findPreference(OsmandSettings.APPLICATION_MODE);
|
||||||
applicationMode.setOnPreferenceChangeListener(this);
|
applicationMode.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
useInternetToDownloadTiles = (CheckBoxPreference) screen.findPreference(OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES);
|
for(BooleanPreference b : booleanPreferences){
|
||||||
useInternetToDownloadTiles.setOnPreferenceChangeListener(this);
|
CheckBoxPreference p = (CheckBoxPreference) screen.findPreference(b.getId());
|
||||||
showPoiOnMap =(CheckBoxPreference) screen.findPreference(OsmandSettings.SHOW_POI_OVER_MAP);
|
p.setOnPreferenceChangeListener(this);
|
||||||
showPoiOnMap.setOnPreferenceChangeListener(this);
|
b.setPref(p);
|
||||||
rotateMapToBearing =(CheckBoxPreference) screen.findPreference(OsmandSettings.ROTATE_MAP_TO_BEARING);
|
}
|
||||||
rotateMapToBearing.setOnPreferenceChangeListener(this);
|
|
||||||
showViewAngle =(CheckBoxPreference) screen.findPreference(OsmandSettings.SHOW_VIEW_ANGLE);
|
|
||||||
showViewAngle.setOnPreferenceChangeListener(this);
|
|
||||||
autoZoom =(CheckBoxPreference) screen.findPreference(OsmandSettings.AUTO_ZOOM_MAP);
|
|
||||||
autoZoom.setOnPreferenceChangeListener(this);
|
|
||||||
showOsmBugs =(CheckBoxPreference) screen.findPreference(OsmandSettings.SHOW_OSM_BUGS);
|
|
||||||
showOsmBugs.setOnPreferenceChangeListener(this);
|
|
||||||
showTransport =(CheckBoxPreference) screen.findPreference(OsmandSettings.SHOW_TRANSPORT_OVER_MAP);
|
|
||||||
showTransport.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
useEnglishNames =(CheckBoxPreference) screen.findPreference(OsmandSettings.USE_ENGLISH_NAMES);
|
|
||||||
useEnglishNames.setOnPreferenceChangeListener(this);
|
|
||||||
reloadIndexes =(Preference) screen.findPreference(OsmandSettings.RELOAD_INDEXES);
|
reloadIndexes =(Preference) screen.findPreference(OsmandSettings.RELOAD_INDEXES);
|
||||||
reloadIndexes.setOnPreferenceClickListener(this);
|
reloadIndexes.setOnPreferenceClickListener(this);
|
||||||
downloadIndexes =(Preference) screen.findPreference(OsmandSettings.DOWNLOAD_INDEXES);
|
downloadIndexes =(Preference) screen.findPreference(OsmandSettings.DOWNLOAD_INDEXES);
|
||||||
downloadIndexes.setOnPreferenceClickListener(this);
|
downloadIndexes.setOnPreferenceClickListener(this);
|
||||||
|
saveCurrentTrack =(Preference) screen.findPreference(OsmandSettings.SAVE_CURRENT_TRACK);
|
||||||
|
saveCurrentTrack.setOnPreferenceClickListener(this);
|
||||||
|
|
||||||
userName = (EditTextPreference) screen.findPreference(OsmandSettings.USER_NAME);
|
userName = (EditTextPreference) screen.findPreference(OsmandSettings.USER_NAME);
|
||||||
userName.setOnPreferenceChangeListener(this);
|
userName.setOnPreferenceChangeListener(this);
|
||||||
userPassword = (EditTextPreference) screen.findPreference(OsmandSettings.USER_PASSWORD);
|
userPassword = (EditTextPreference) screen.findPreference(OsmandSettings.USER_PASSWORD);
|
||||||
userPassword.setOnPreferenceChangeListener(this);
|
userPassword.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
saveTrackToGpx =(CheckBoxPreference) screen.findPreference(OsmandSettings.SAVE_TRACK_TO_GPX);
|
|
||||||
saveTrackToGpx.setOnPreferenceChangeListener(this);
|
|
||||||
saveTrackInterval =(ListPreference) screen.findPreference(OsmandSettings.SAVE_TRACK_INTERVAL);
|
saveTrackInterval =(ListPreference) screen.findPreference(OsmandSettings.SAVE_TRACK_INTERVAL);
|
||||||
saveTrackInterval.setOnPreferenceChangeListener(this);
|
saveTrackInterval.setOnPreferenceChangeListener(this);
|
||||||
saveCurrentTrack =(Preference) screen.findPreference(OsmandSettings.SAVE_CURRENT_TRACK);
|
|
||||||
saveCurrentTrack.setOnPreferenceClickListener(this);
|
|
||||||
|
|
||||||
|
|
||||||
positionOnMap =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP);
|
positionOnMap =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP);
|
||||||
positionOnMap.setOnPreferenceChangeListener(this);
|
positionOnMap.setOnPreferenceChangeListener(this);
|
||||||
mapScreenOrientation =(ListPreference) screen.findPreference(OsmandSettings.MAP_SCREEN_ORIENTATION);
|
mapScreenOrientation =(ListPreference) screen.findPreference(OsmandSettings.MAP_SCREEN_ORIENTATION);
|
||||||
|
@ -118,15 +137,10 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAllSettings(){
|
public void updateAllSettings(){
|
||||||
useInternetToDownloadTiles.setChecked(OsmandSettings.isUsingInternetToDownloadTiles(this));
|
SharedPreferences prefs = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
showPoiOnMap.setChecked(OsmandSettings.isShowingPoiOverMap(this));
|
for(BooleanPreference b : booleanPreferences){
|
||||||
rotateMapToBearing.setChecked(OsmandSettings.isRotateMapToBearing(this));
|
b.getPref().setChecked(prefs.getBoolean(b.getId(), b.getDefValue()));
|
||||||
showViewAngle.setChecked(OsmandSettings.isShowingViewAngle(this));
|
}
|
||||||
showOsmBugs.setChecked(OsmandSettings.isShowingOsmBugs(this));
|
|
||||||
showTransport.setChecked(OsmandSettings.isShowingTransportOverMap(this));
|
|
||||||
saveTrackToGpx.setChecked(OsmandSettings.isSavingTrackToGpx(this));
|
|
||||||
useEnglishNames.setChecked(OsmandSettings.usingEnglishNames(this));
|
|
||||||
autoZoom.setChecked(OsmandSettings.isAutoZoomEnabled(this));
|
|
||||||
userName.setText(OsmandSettings.getUserName(this));
|
userName.setText(OsmandSettings.getUserName(this));
|
||||||
userPassword.setText(OsmandSettings.getUserPassword(this));
|
userPassword.setText(OsmandSettings.getUserPassword(this));
|
||||||
|
|
||||||
|
@ -214,35 +228,27 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
SharedPreferences prefs = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
SharedPreferences prefs = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
|
||||||
Editor edit = prefs.edit();
|
Editor edit = prefs.edit();
|
||||||
if(preference == applicationMode){
|
// handle boolean prefences
|
||||||
|
BooleanPreference p = null;
|
||||||
|
for(BooleanPreference b : booleanPreferences){
|
||||||
|
if(b.getPref() == preference){
|
||||||
|
p = b;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(p != null){
|
||||||
|
edit.putBoolean(p.getId(), (Boolean)newValue);
|
||||||
|
if(p.getId() == OsmandSettings.SHOW_POI_OVER_MAP && ((Boolean) newValue)){
|
||||||
|
edit.putString(OsmandSettings.SELECTED_POI_FILTER_FOR_MAP, PoiFiltersHelper.getOsmDefinedFilterId(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
edit.commit();
|
||||||
|
|
||||||
|
} else if(preference == applicationMode){
|
||||||
edit.putString(OsmandSettings.APPLICATION_MODE, (String) newValue);
|
edit.putString(OsmandSettings.APPLICATION_MODE, (String) newValue);
|
||||||
setAppMode(ApplicationMode.valueOf(newValue.toString()), edit);
|
setAppMode(ApplicationMode.valueOf(newValue.toString()), edit);
|
||||||
edit.commit();
|
edit.commit();
|
||||||
updateAllSettings();
|
updateAllSettings();
|
||||||
} else if(preference == autoZoom){
|
|
||||||
edit.putBoolean(OsmandSettings.AUTO_ZOOM_MAP, (Boolean) newValue);
|
|
||||||
edit.commit();
|
|
||||||
} else if(preference == showTransport){
|
|
||||||
edit.putBoolean(OsmandSettings.SHOW_TRANSPORT_OVER_MAP, (Boolean) newValue);
|
|
||||||
edit.commit();
|
|
||||||
} else if(preference == showPoiOnMap){
|
|
||||||
edit.putBoolean(OsmandSettings.SHOW_POI_OVER_MAP, (Boolean) newValue);
|
|
||||||
if((Boolean)newValue){
|
|
||||||
edit.putString(OsmandSettings.SELECTED_POI_FILTER_FOR_MAP, PoiFiltersHelper.getOsmDefinedFilterId(null));
|
|
||||||
}
|
|
||||||
edit.commit();
|
|
||||||
} else if(preference == useInternetToDownloadTiles){
|
|
||||||
edit.putBoolean(OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES, (Boolean) newValue);
|
|
||||||
edit.commit();
|
|
||||||
} else if(preference == rotateMapToBearing){
|
|
||||||
edit.putBoolean(OsmandSettings.ROTATE_MAP_TO_BEARING, (Boolean) newValue);
|
|
||||||
edit.commit();
|
|
||||||
} else if(preference == useEnglishNames){
|
|
||||||
edit.putBoolean(OsmandSettings.USE_ENGLISH_NAMES, (Boolean) newValue);
|
|
||||||
edit.commit();
|
|
||||||
} else if(preference == saveTrackToGpx){
|
|
||||||
edit.putBoolean(OsmandSettings.SAVE_TRACK_TO_GPX, (Boolean) newValue);
|
|
||||||
edit.commit();
|
|
||||||
} else if(preference == mapScreenOrientation){
|
} else if(preference == mapScreenOrientation){
|
||||||
edit.putInt(OsmandSettings.MAP_SCREEN_ORIENTATION, Integer.parseInt(newValue.toString()));
|
edit.putInt(OsmandSettings.MAP_SCREEN_ORIENTATION, Integer.parseInt(newValue.toString()));
|
||||||
edit.commit();
|
edit.commit();
|
||||||
|
@ -255,12 +261,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
} else if(preference == userName){
|
} else if(preference == userName){
|
||||||
edit.putString(OsmandSettings.USER_NAME, (String) newValue);
|
edit.putString(OsmandSettings.USER_NAME, (String) newValue);
|
||||||
edit.commit();
|
edit.commit();
|
||||||
} else if(preference == showViewAngle){
|
|
||||||
edit.putBoolean(OsmandSettings.SHOW_VIEW_ANGLE, (Boolean) newValue);
|
|
||||||
edit.commit();
|
|
||||||
} else if(preference == showOsmBugs){
|
|
||||||
edit.putBoolean(OsmandSettings.SHOW_OSM_BUGS, (Boolean) newValue);
|
|
||||||
edit.commit();
|
|
||||||
} else if(preference == positionOnMap){
|
} else if(preference == positionOnMap){
|
||||||
edit.putInt(OsmandSettings.POSITION_ON_MAP, positionOnMap.findIndexOfValue((String) newValue));
|
edit.putInt(OsmandSettings.POSITION_ON_MAP, positionOnMap.findIndexOfValue((String) newValue));
|
||||||
edit.commit();
|
edit.commit();
|
||||||
|
@ -406,5 +407,4 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue