Partial impl

This commit is contained in:
Victor Shcherb 2011-05-14 11:39:20 +02:00
parent 71945ec893
commit cd564b7ddc
39 changed files with 1237 additions and 1309 deletions

View file

@ -16,7 +16,8 @@ public class OsmAndFormatter {
private final static float FOOTS_IN_METER = YARDS_IN_METER * 3f;
public static String getFormattedDistance(int meters, Context ctx) {
MetricsConstants mc = OsmandSettings.getDefaultMetricConstants(ctx);
OsmandSettings settings = OsmandSettings.getOsmandSettings(ctx);
MetricsConstants mc = settings.METRIC_SYSTEM.get();
int mainUnitStr;
float mainUnitInMeters;
if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
@ -48,7 +49,8 @@ public class OsmAndFormatter {
}
public static String getFormattedSpeed(float metersperseconds, Context ctx) {
MetricsConstants mc = OsmandSettings.getDefaultMetricConstants(ctx);
OsmandSettings settings = OsmandSettings.getOsmandSettings(ctx);
MetricsConstants mc = settings.METRIC_SYSTEM.get();
float kmh = metersperseconds * 3.6f;
if(mc == MetricsConstants.KILOMETERS_AND_METERS){
return ((int) kmh) + ctx.getString(R.string.km_h);

View file

@ -14,7 +14,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
@ -44,7 +43,7 @@ public class NavigationService extends Service implements LocationListener {
private SavingTrackHelper savingTrackHelper;
private RoutingHelper routingHelper;
private SharedPreferences settings;
private OsmandSettings settings;
private Handler handler;
@ -86,10 +85,10 @@ public class NavigationService extends Service implements LocationListener {
// initializing variables
setForeground(true);
handler = new Handler();
settings = OsmandSettings.getPrefs(this);
serviceOffInterval = OsmandSettings.getServiceOffInterval(settings);
serviceOffProvider = OsmandSettings.getServiceOffProvider(settings);
serviceError = OsmandSettings.getServiceOffWaitInterval(settings);
settings = OsmandSettings.getOsmandSettings(this);
serviceOffInterval = settings.SERVICE_OFF_INTERVAL.get();
serviceOffProvider = settings.SERVICE_OFF_PROVIDER.get();
serviceError = settings.SERVICE_OFF_WAIT_INTERVAL.get();
savingTrackHelper = new SavingTrackHelper(this);
routingHelper = ((OsmandApplication)getApplication()).getRoutingHelper();
@ -159,7 +158,7 @@ public class NavigationService extends Service implements LocationListener {
@Override
public void onLocationChanged(Location location) {
if(location != null && !OsmandSettings.getMapActivityEnabled(settings)){
if(location != null && !settings.MAP_ACTIVITY_ENABLED.get()){
if(!isContinuous()){
// unregister listener and wait next time
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

File diff suppressed because it is too large Load diff

View file

@ -101,7 +101,7 @@ public class ResourceManager {
}
public void resetStoreDirectory() {
dirWithTiles = OsmandSettings.extendOsmandPath(context, TILES_PATH);
dirWithTiles = OsmandSettings.getOsmandSettings(context).extendOsmandPath(TILES_PATH);
dirWithTiles.mkdirs();
}
@ -352,7 +352,7 @@ public class ResourceManager {
}
private void initRenderers(IProgress progress) {
File file = OsmandSettings.extendOsmandPath(context, APP_DIR + IndexConstants.RENDERERS_DIR);
File file = OsmandSettings.getOsmandSettings(context).extendOsmandPath(APP_DIR + IndexConstants.RENDERERS_DIR);
file.mkdirs();
Map<String, File> externalRenderers = new LinkedHashMap<String, File>();
if (file.exists() && file.canRead()) {
@ -364,7 +364,7 @@ public class ResourceManager {
}
}
RendererRegistry.getRegistry().setExternalRenderers(externalRenderers);
String r = OsmandSettings.getVectorRenderer(OsmandSettings.getPrefs(context));
String r = OsmandSettings.getOsmandSettings(context).RENDERER.get();
if(r != null){
BaseOsmandRender obj = RendererRegistry.getRegistry().getRenderer(r);
if(obj != null){
@ -374,7 +374,7 @@ public class ResourceManager {
}
public List<String> indexingMaps(final IProgress progress) {
File file = OsmandSettings.extendOsmandPath(context, MAPS_PATH);
File file = OsmandSettings.getOsmandSettings(context).extendOsmandPath(MAPS_PATH);
file.mkdirs();
List<String> warnings = new ArrayList<String>();
renderer.clearAllResources();
@ -431,7 +431,7 @@ public class ResourceManager {
// POI INDEX //
public List<String> indexingPoi(final IProgress progress) {
File file = OsmandSettings.extendOsmandPath(context, POI_PATH);
File file = OsmandSettings.getOsmandSettings(context).extendOsmandPath(POI_PATH);
file.mkdirs();
List<String> warnings = new ArrayList<String>();
closeAmenities();

View file

@ -27,92 +27,4 @@ public enum ApplicationMode {
return ctx.getResources().getString(m.key);
}
public static boolean setAppMode(ApplicationMode preset, OsmandApplication app) {
ApplicationMode old = OsmandSettings.getApplicationMode(OsmandSettings.getPrefs(app));
if(preset == old){
return false;
}
Editor edit = OsmandSettings.getWriteableEditor(app);
edit.putString(OsmandSettings.APPLICATION_MODE, preset.toString());
if (preset == ApplicationMode.CAR) {
OsmandSettings.setUseInternetToDownloadTiles(true, edit);
// edit.putBoolean(OsmandSettings.SHOW_POI_OVER_MAP, _);
edit.putBoolean(OsmandSettings.SHOW_TRANSPORT_OVER_MAP, false);
edit.putInt(OsmandSettings.ROTATE_MAP, OsmandSettings.ROTATE_MAP_BEARING);
edit.putBoolean(OsmandSettings.SHOW_VIEW_ANGLE, false);
edit.putBoolean(OsmandSettings.AUTO_ZOOM_MAP, true);
edit.putBoolean(OsmandSettings.SHOW_OSM_BUGS, false);
edit.putBoolean(OsmandSettings.USE_STEP_BY_STEP_RENDERING, true);
// edit.putBoolean(OsmandSettings.USE_ENGLISH_NAMES, _);
edit.putBoolean(OsmandSettings.SAVE_TRACK_TO_GPX, true);
edit.putInt(OsmandSettings.SAVE_TRACK_INTERVAL, 5);
edit.putInt(OsmandSettings.POSITION_ON_MAP, OsmandSettings.BOTTOM_CONSTANT);
// edit.putString(OsmandSettings.MAP_TILE_SOURCES, _);
} else if (preset == ApplicationMode.BICYCLE) {
// edit.putBoolean(OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES, _);
// edit.putBoolean(OsmandSettings.USE_INTERNET_TO_CALCULATE_ROUTE, _);
// edit.putBoolean(OsmandSettings.SHOW_POI_OVER_MAP, true);
edit.putInt(OsmandSettings.ROTATE_MAP, OsmandSettings.ROTATE_MAP_BEARING);
edit.putBoolean(OsmandSettings.SHOW_VIEW_ANGLE, true);
edit.putBoolean(OsmandSettings.AUTO_ZOOM_MAP, false);
// edit.putBoolean(OsmandSettings.SHOW_OSM_BUGS, _);
// edit.putBoolean(OsmandSettings.USE_ENGLISH_NAMES, _);
edit.putBoolean(OsmandSettings.SAVE_TRACK_TO_GPX, true);
edit.putInt(OsmandSettings.SAVE_TRACK_INTERVAL, 30);
edit.putInt(OsmandSettings.POSITION_ON_MAP, OsmandSettings.BOTTOM_CONSTANT);
// edit.putString(OsmandSettings.MAP_TILE_SOURCES, _);
} else if (preset == ApplicationMode.PEDESTRIAN) {
// edit.putBoolean(OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES, _);
// edit.putBoolean(OsmandSettings.SHOW_POI_OVER_MAP, true);
edit.putInt(OsmandSettings.ROTATE_MAP, OsmandSettings.ROTATE_MAP_COMPASS);
edit.putBoolean(OsmandSettings.SHOW_VIEW_ANGLE, true);
edit.putBoolean(OsmandSettings.AUTO_ZOOM_MAP, false);
edit.putBoolean(OsmandSettings.USE_STEP_BY_STEP_RENDERING, false);
// if(useInternetToDownloadTiles.isChecked()){
// edit.putBoolean(OsmandSettings.SHOW_OSM_BUGS, true);
// }
// edit.putBoolean(OsmandSettings.USE_ENGLISH_NAMES, _);
edit.putBoolean(OsmandSettings.SAVE_TRACK_TO_GPX, false);
// edit.putInt(OsmandSettings.SAVE_TRACK_INTERVAL, _);
edit.putInt(OsmandSettings.POSITION_ON_MAP, OsmandSettings.CENTER_CONSTANT);
// edit.putString(OsmandSettings.MAP_TILE_SOURCES, _);
} else if (preset == ApplicationMode.DEFAULT) {
// edit.putBoolean(OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES, _);
// edit.putBoolean(OsmandSettings.SHOW_POI_OVER_MAP, true);
edit.putInt(OsmandSettings.ROTATE_MAP, OsmandSettings.ROTATE_MAP_NONE);
edit.putBoolean(OsmandSettings.SHOW_VIEW_ANGLE, false);
edit.putBoolean(OsmandSettings.AUTO_ZOOM_MAP, false);
edit.putBoolean(OsmandSettings.USE_STEP_BY_STEP_RENDERING, true);
// edit.putBoolean(OsmandSettings.SHOW_OSM_BUGS, _);
// edit.putBoolean(OsmandSettings.USE_ENGLISH_NAMES, _);
edit.putBoolean(OsmandSettings.SAVE_TRACK_TO_GPX, false);
// edit.putInt(OsmandSettings.SAVE_TRACK_INTERVAL, _);
edit.putInt(OsmandSettings.POSITION_ON_MAP, OsmandSettings.CENTER_CONSTANT);
// edit.putString(OsmandSettings.MAP_TILE_SOURCES, _);
}
BaseOsmandRender current = RendererRegistry.getRegistry().getCurrentSelectedRenderer();
BaseOsmandRender defaultRender = RendererRegistry.getRegistry().defaultRender();
BaseOsmandRender newRenderer;
if (preset == ApplicationMode.CAR) {
newRenderer = RendererRegistry.getRegistry().carRender();
} else if (preset == ApplicationMode.BICYCLE) {
newRenderer = RendererRegistry.getRegistry().bicycleRender();
} else if (preset == ApplicationMode.PEDESTRIAN) {
newRenderer = RendererRegistry.getRegistry().pedestrianRender();
} else {
newRenderer = defaultRender;
}
if (newRenderer != current) {
RendererRegistry.getRegistry().setCurrentSelectedRender(newRenderer);
app.getResourceManager().getRenderer().clearCache();
}
return edit.commit();
}
}

View file

@ -65,7 +65,7 @@ public class ContributionVersionActivity extends ListActivity {
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.download_builds);
String installDate = OsmandSettings.getPrefs(this).getString(CONTRIBUTION_INSTALL_APP_DATE, null);
String installDate = OsmandSettings.getOsmandSettings(this).CONTRIBUTION_INSTALL_APP_DATE.get();
if(installDate != null){
try {
currentInstalledDate = dateFormat.parse(installDate);
@ -138,8 +138,7 @@ public class ContributionVersionActivity extends ListActivity {
MessageFormat.format(getString(R.string.build_installed), currentSelectedBuild.tag, dateFormat
.format(currentSelectedBuild.date)), Toast.LENGTH_LONG).show();
}
OsmandSettings.getWriteableEditor(this).putString(CONTRIBUTION_INSTALL_APP_DATE, dateFormat.format(d))
.commit();
OsmandSettings.getOsmandSettings(this).CONTRIBUTION_INSTALL_APP_DATE.set(dateFormat.format(d));
}
protected void executeThreadOperation(int operationId) throws Exception {

View file

@ -7,7 +7,6 @@ import java.util.TimeZone;
import net.osmand.LogUtil;
import net.osmand.SunriseSunset;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.DayNightMode;
import org.apache.commons.logging.Log;
@ -44,8 +43,7 @@ public class DayNightHelper implements SensorEventListener {
public DayNightHelper(OsmandApplication osmandApplication) {
this.osmandApplication = osmandApplication;
setDayNightMode(OsmandSettings.getDayNightMode(OsmandSettings
.getPrefs(osmandApplication)));
setDayNightMode(osmandApplication.getSettings().DAYNIGHT_MODE.get());
}
DayNightMode dayNightMode = DayNightMode.AUTO;

View file

@ -308,7 +308,7 @@ public class DownloadIndexActivity extends ListActivity {
private List<String> listAlreadyDownloadedWithAlternatives() {
List<String> files = new ArrayList<String>();
File externalStorageDirectory = OsmandSettings.getExternalStorageDirectory(getApplicationContext());
File externalStorageDirectory = OsmandSettings.getOsmandSettings(getApplicationContext()).getExternalStorageDirectory();
files.addAll(listWithAlternatives(new File(externalStorageDirectory, ResourceManager.POI_PATH),POI_INDEX_EXT,POI_INDEX_EXT_ZIP,POI_TABLE_VERSION));
files.addAll(listWithAlternatives(new File(externalStorageDirectory, ResourceManager.APP_DIR),BINARY_MAP_INDEX_EXT,BINARY_MAP_INDEX_EXT_ZIP,BINARY_MAP_VERSION));
files.addAll(listWithAlternatives(new File(externalStorageDirectory, ResourceManager.VOICE_PATH),"",VOICE_INDEX_EXT_ZIP, VOICE_VERSION));
@ -343,7 +343,7 @@ public class DownloadIndexActivity extends ListActivity {
String toCheckPostfix = null;
boolean unzipDir = false;
File externalStorageDirectory = OsmandSettings.getExternalStorageDirectory(getApplicationContext());
File externalStorageDirectory = OsmandSettings.getOsmandSettings(getApplicationContext()).getExternalStorageDirectory();
if(fileName.endsWith(IndexConstants.POI_INDEX_EXT)){
parent = new File(externalStorageDirectory, ResourceManager.POI_PATH);
toSavePostfix = POI_INDEX_EXT;

View file

@ -63,7 +63,7 @@ public class EditPOIFilterActivity extends ListActivity {
public void onClick(View v) {
Bundle extras = getIntent().getExtras();
boolean searchNearBy = true;
LatLon lastKnownMapLocation = OsmandSettings.getLastKnownMapLocation(OsmandSettings.getPrefs(EditPOIFilterActivity.this));
LatLon lastKnownMapLocation = OsmandSettings.getOsmandSettings(EditPOIFilterActivity.this).getLastKnownMapLocation();
double latitude = lastKnownMapLocation != null ? lastKnownMapLocation.getLatitude() : 0;
double longitude = lastKnownMapLocation != null ? lastKnownMapLocation.getLongitude() : 0;
final Intent newIntent = new Intent(EditPOIFilterActivity.this, SearchPOIActivity.class);

View file

@ -140,7 +140,7 @@ public class EditingPOIActivity {
Builder builder = new AlertDialog.Builder(ctx);
builder.setTitle(MessageFormat.format(this.view.getResources().getString(R.string.poi_remove_confirm_template),
OsmAndFormatter.getPoiStringWithoutType(a, OsmandSettings.usingEnglishNames(OsmandSettings.getPrefs(ctx)))));
OsmAndFormatter.getPoiStringWithoutType(a, OsmandSettings.getOsmandSettings(ctx).usingEnglishNames())));
final EditText comment = new EditText(ctx);
comment.setText(R.string.poi_remove_title);
builder.setView(comment);
@ -380,8 +380,8 @@ public class EditingPOIActivity {
DefaultHttpClient httpclient = new DefaultHttpClient(params);
if (doAuthenticate) {
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(OsmandSettings.getUserName(OsmandSettings.getPrefs(ctx)) + ":" //$NON-NLS-1$
+ OsmandSettings.getUserPassword(OsmandSettings.getPrefs(ctx)));
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(OsmandSettings.getOsmandSettings(ctx).USER_NAME.get() + ":" //$NON-NLS-1$
+ OsmandSettings.getOsmandSettings(ctx).USER_PASSWORD.get());
httpclient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), credentials);
}
HttpRequestBase method = null;
@ -460,7 +460,7 @@ public class EditingPOIActivity {
connection.setRequestMethod(requestMethod);
StringBuilder responseBody = new StringBuilder();
if (doAuthenticate) {
String token = OsmandSettings.getUserName(OsmandSettings.getPrefs(ctx)) + ":" + OsmandSettings.getUserPassword(OsmandSettings.getPrefs(ctx)); //$NON-NLS-1$
String token = OsmandSettings.getOsmandSettings(ctx).USER_NAME.get() + ":" + OsmandSettings.getOsmandSettings(ctx).USER_PASSWORD.get(); //$NON-NLS-1$
connection.addRequestProperty("Authorization", "Basic " + Base64.encode(token.getBytes("UTF-8"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
connection.setDoInput(true);
@ -645,7 +645,7 @@ public class EditingPOIActivity {
ser.startTag(null, action);
ser.attribute(null, "version", "0.6"); //$NON-NLS-1$ //$NON-NLS-2$
ser.attribute(null, "generator", Version.APP_NAME); //$NON-NLS-1$
writeNode(n, info, ser, changeSetId, OsmandSettings.getUserName(OsmandSettings.getPrefs(ctx)));
writeNode(n, info, ser, changeSetId, OsmandSettings.getOsmandSettings(ctx).USER_NAME.get());
ser.endTag(null, action);
ser.endTag(null, "osmChange"); //$NON-NLS-1$
ser.endDocument();

View file

@ -99,7 +99,7 @@ public class FavouritesActivity extends ListActivity {
list.addAll(helper.getFavoritePointsFromGPXFile());
}
favouritesAdapter = new FavouritesAdapter(list);
final LatLon mapLocation = OsmandSettings.getLastKnownMapLocation(OsmandSettings.getPrefs(this));
final LatLon mapLocation = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
if(mapLocation != null){
favouritesAdapter.sort(new Comparator<FavouritePoint>(){
@ -122,8 +122,8 @@ public class FavouritesActivity extends ListActivity {
public void onListItemClick(ListView parent, View v, int position, long id) {
FavouritePoint point = favouritesAdapter.getItem(position);
OsmandSettings.setShowingFavorites(this, true);
OsmandSettings.setMapLocationToShow(this, point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName()); //$NON-NLS-1$
OsmandSettings.getOsmandSettings(this).SHOW_FAVORITES.set( true);
OsmandSettings.getOsmandSettings(this).setMapLocationToShow(point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName()); //$NON-NLS-1$
Intent newIntent = new Intent(FavouritesActivity.this, MapActivity.class);
startActivity(newIntent);
}
@ -134,7 +134,7 @@ public class FavouritesActivity extends ListActivity {
final FavouritePoint point = (FavouritePoint) favouritesAdapter.getItem(menuInfo.position);
if (aItem.getItemId() == NAVIGATE_TO) {
//OsmandSettings.setMapLocationToShow(this, point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName()); //$NON-NLS-1$
OsmandSettings.setPointToNavigate(this, point.getLatitude(), point.getLongitude());
OsmandSettings.getOsmandSettings(this).setPointToNavigate(point.getLatitude(), point.getLongitude());
Intent newIntent = new Intent(FavouritesActivity.this, MapActivity.class);
startActivity(newIntent);
} else if (aItem.getItemId() == EDIT_ITEM) {
@ -194,7 +194,7 @@ public class FavouritesActivity extends ListActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == EXPORT_ID){
File appDir = OsmandSettings.extendOsmandPath(getApplicationContext(), ResourceManager.APP_DIR);
File appDir = OsmandSettings.getOsmandSettings(this).extendOsmandPath(ResourceManager.APP_DIR);
if(favouritesAdapter.isEmpty()){
Toast.makeText(this, R.string.no_fav_to_save, Toast.LENGTH_LONG).show();
} else if(!appDir.exists()){
@ -219,7 +219,7 @@ public class FavouritesActivity extends ListActivity {
}
}
} else if(item.getItemId() == IMPORT_ID){
File appDir = OsmandSettings.extendOsmandPath(getApplicationContext(), ResourceManager.APP_DIR);
File appDir = OsmandSettings.getOsmandSettings(this).extendOsmandPath(ResourceManager.APP_DIR);
File f = new File(appDir, FILE_TO_SAVE);
if(!f.exists()){
Toast.makeText(this, MessageFormat.format(getString(R.string.fav_file_to_load_not_found), f.getAbsolutePath()), Toast.LENGTH_LONG).show();
@ -279,7 +279,7 @@ public class FavouritesActivity extends ListActivity {
} else {
icon.setImageResource(R.drawable.opened_poi);
}
LatLon lastKnownMapLocation = OsmandSettings.getLastKnownMapLocation(OsmandSettings.getPrefs(FavouritesActivity.this));
LatLon lastKnownMapLocation = OsmandSettings.getOsmandSettings(FavouritesActivity.this).getLastKnownMapLocation();
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(),
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(dist, FavouritesActivity.this));

View file

@ -51,7 +51,7 @@ public class MainMenuActivity extends Activity {
public void checkPreviousRunsForExceptions(boolean firstTime) {
long size = getPreferences(MODE_WORLD_READABLE).getLong(EXCEPTION_FILE_SIZE, 0);
final File file = OsmandSettings.extendOsmandPath(getApplicationContext(), OsmandApplication.EXCEPTION_PATH);
final File file = OsmandSettings.getOsmandSettings(this).extendOsmandPath(OsmandApplication.EXCEPTION_PATH);
if (file.exists() && file.length() > 0) {
if (size != file.length() && !firstTime) {
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
@ -125,7 +125,7 @@ public class MainMenuActivity extends Activity {
String textVersion = Version.APP_VERSION + " " + Version.APP_DESCRIPTION;
final TextView textVersionView = (TextView) findViewById(R.id.TextVersion);
textVersionView.setText(textVersion);
SharedPreferences prefs = OsmandSettings.getPrefs(this);
SharedPreferences prefs = getApplicationContext().getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
// only one commit should be with contribution version flag
// prefs.edit().putBoolean(CONTRIBUTION_VERSION_FLAG, true).commit();

View file

@ -157,10 +157,10 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
private boolean currentShowingAngle;
private Dialog progressDlg = null;
private SharedPreferences settings;
private OsmandSettings settings;
private boolean isMapLinkedToLocation(){
return OsmandSettings.isMapSyncToGpsLocation(settings);
return settings.isMapSyncToGpsLocation();
}
private Notification getNotification(){
@ -178,7 +178,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings = OsmandSettings.getPrefs(this);
settings = OsmandSettings.getOsmandSettings(this);
// for voice navigation
setVolumeControlStream(AudioManager.STREAM_MUSIC);
requestWindowFeature(Window.FEATURE_NO_TITLE);
@ -192,7 +192,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
@Override
public void onDismiss(DialogInterface dialog) {
OsmandApplication app = ((OsmandApplication)getApplication());
if(OsmandSettings.isUsingMapVectorData(settings) && app.getResourceManager().getRenderer().isEmpty()){
if(settings.isUsingMapVectorData() && app.getResourceManager().getRenderer().isEmpty()){
Toast.makeText(MapActivity.this, getString(R.string.no_vector_map_loaded), Toast.LENGTH_LONG).show();
}
}
@ -272,7 +272,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
savingTrackHelper = new SavingTrackHelper(this);
LatLon pointToNavigate = OsmandSettings.getPointToNavigate(settings);
LatLon pointToNavigate = settings.getPointToNavigate();
// This situtation could be when navigation suddenly crashed and after restarting
// it tries to continue the last route
@ -281,9 +281,9 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
routingHelper.setFinalAndCurrentLocation(pointToNavigate, null);
}
if(OsmandSettings.isFollowingByRoute(settings)){
if(settings.FOLLOW_TO_THE_ROUTE.get()){
if(pointToNavigate == null){
OsmandSettings.setFollowingByRoute(this, false);
settings.FOLLOW_TO_THE_ROUTE.set(false);
} else if(!routingHelper.isRouteCalculated()){
Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.continue_follow_previous_route);
@ -297,7 +297,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
builder.setNegativeButton(R.string.default_buttons_no, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
OsmandSettings.setFollowingByRoute(MapActivity.this, false);
settings.FOLLOW_TO_THE_ROUTE.set(false);
routingHelper.setFinalLocation(null);
mapView.refreshMap();
}
@ -308,8 +308,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
navigationLayer.setPointToNavigate(pointToNavigate);
SharedPreferences prefs = OsmandSettings.getPrefs(this);
if(prefs == null || !prefs.contains(OsmandSettings.LAST_KNOWN_MAP_LAT)){
if(!settings.isLastKnownMapLocation()){
LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE);
Location location = null;
try {
@ -344,7 +343,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
mapView.getAnimatedDraggingThread().startZooming(mapView.getZoom(), mapView.getZoom() + 1);
showAndHideMapPosition();
// user can preview map manually switch off auto zoom while user don't press back to location
if(OsmandSettings.isAutoZoomEnabled(settings)){
if(settings.AUTO_ZOOM_MAP.get()){
locationChanged(mapView.getLatitude(), mapView.getLongitude(), null);
}
}
@ -357,7 +356,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
mapView.getAnimatedDraggingThread().startZooming(mapView.getZoom(), mapView.getZoom() - 1);
showAndHideMapPosition();
// user can preview map manually switch off auto zoom while user don't press back to location
if(OsmandSettings.isAutoZoomEnabled(settings)){
if(settings.AUTO_ZOOM_MAP.get()){
locationChanged(mapView.getLatitude(), mapView.getLongitude(), null);
}
}
@ -410,7 +409,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
}
@Override
public boolean onTrackballEvent(MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_MOVE && OsmandSettings.isUsingTrackBall(settings)){
if(event.getAction() == MotionEvent.ACTION_MOVE && settings.USE_TRACKBALL_FOR_MOVEMENTS.get()){
float x = event.getX();
float y = event.getY();
LatLon l = mapView.getLatLonFromScreenPoint(mapView.getCenterPointX() + x * 15, mapView.getCenterPointY() + y * 15);
@ -481,7 +480,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
protected void backToLocationImpl() {
backToLocation.setVisibility(View.INVISIBLE);
if(!isMapLinkedToLocation()){
OsmandSettings.setSyncMapToGpsLocation(MapActivity.this, true);
settings.setSyncMapToGpsLocation(true);
if(locationLayer.getLastKnownLocation() != null){
Location lastKnownLocation = locationLayer.getLastKnownLocation();
AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread();
@ -529,7 +528,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
if(Log.isLoggable(LogUtil.TAG, Log.DEBUG)){
Log.d(LogUtil.TAG, "Location changed " + location.getProvider()); //$NON-NLS-1$
}
if(location != null && OsmandSettings.isSavingTrackToGpx(this)){
if(location != null && settings.SAVE_TRACK_TO_GPX.get()){
savingTrackHelper.insertData(location.getLatitude(), location.getLongitude(),
location.getAltitude(), location.getSpeed(), location.getTime(), settings);
}
@ -542,7 +541,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
}
if (location != null) {
if (isMapLinkedToLocation()) {
if(OsmandSettings.isAutoZoomEnabled(settings) && location.hasSpeed()){
if(settings.AUTO_ZOOM_MAP.get() && location.hasSpeed()){
int z = defineZoomFromSpeed(location.getSpeed(), mapView.getZoom());
if(mapView.getZoom() != z && !mapView.mapIsAnimating()){
long now = System.currentTimeMillis();
@ -587,14 +586,14 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
public void navigateToPoint(LatLon point){
if(point != null){
OsmandSettings.setPointToNavigate(this, point.getLatitude(), point.getLongitude());
settings.setPointToNavigate(point.getLatitude(), point.getLongitude());
} else {
OsmandSettings.clearPointToNavigate(this);
settings.clearPointToNavigate();
}
routingHelper.setFinalAndCurrentLocation(point, null, routingHelper.getCurrentGPXRoute());
if(point == null){
routingHelper.setFollowingMode(false);
OsmandSettings.setFollowingByRoute(MapActivity.this, false);
settings.FOLLOW_TO_THE_ROUTE.set(false);
}
navigationLayer.setPointToNavigate(point);
}
@ -727,75 +726,75 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
((OsmandApplication)getApplication()).getDaynightHelper().onMapPause();
OsmandSettings.setLastKnownMapLocation(this, (float) mapView.getLatitude(), (float) mapView.getLongitude());
settings.setLastKnownMapLocation((float) mapView.getLatitude(), (float) mapView.getLongitude());
AnimateDraggingMapThread animatedThread = mapView.getAnimatedDraggingThread();
if(animatedThread.isAnimating() && animatedThread.getTargetZoom() != 0){
OsmandSettings.setMapLocationToShow(this, animatedThread.getTargetLatitude(), animatedThread.getTargetLongitude(),
settings.setMapLocationToShow(animatedThread.getTargetLatitude(), animatedThread.getTargetLongitude(),
animatedThread.getTargetZoom());
}
OsmandSettings.setLastKnownMapZoom(this, mapView.getZoom());
settings.setLastKnownMapZoom(mapView.getZoom());
if (wakeLock != null) {
wakeLock.release();
wakeLock = null;
}
OsmandSettings.setMapActivityEnabled(this, false);
settings.MAP_ACTIVITY_ENABLED.set(false);
((OsmandApplication)getApplication()).getResourceManager().interruptRendering();
((OsmandApplication)getApplication()).getResourceManager().setBusyIndicator(null);
}
private void updateApplicationModeSettings(){
currentMapRotation = OsmandSettings.getRotateMap(settings);
currentShowingAngle = OsmandSettings.isShowingViewAngle(settings);
currentMapRotation = settings.ROTATE_MAP.get();
currentShowingAngle = settings.SHOW_VIEW_ANGLE.get();
if(currentMapRotation == OsmandSettings.ROTATE_MAP_NONE){
mapView.setRotate(0);
}
if(!currentShowingAngle){
locationLayer.setHeading(null);
}
locationLayer.setAppMode(OsmandSettings.getApplicationMode(settings));
routingHelper.setAppMode(OsmandSettings.getApplicationMode(settings));
mapView.setMapPosition(OsmandSettings.getPositionOnMap(settings));
locationLayer.setAppMode(settings.getApplicationMode());
routingHelper.setAppMode(settings.getApplicationMode());
mapView.setMapPosition(settings.POSITION_ON_MAP.get());
registerUnregisterSensor(getLastKnownLocation());
updateLayers();
}
private void updateLayers(){
if(mapView.getLayers().contains(transportStopsLayer) != OsmandSettings.isShowingTransportOverMap(settings)){
if(OsmandSettings.isShowingTransportOverMap(settings)){
if(mapView.getLayers().contains(transportStopsLayer) != settings.SHOW_TRANSPORT_OVER_MAP.get()){
if(settings.SHOW_TRANSPORT_OVER_MAP.get()){
mapView.addLayer(transportStopsLayer, 5);
} else {
mapView.removeLayer(transportStopsLayer);
}
}
if(mapView.getLayers().contains(osmBugsLayer) != OsmandSettings.isShowingOsmBugs(settings)){
if(OsmandSettings.isShowingOsmBugs(settings)){
if(mapView.getLayers().contains(osmBugsLayer) != settings.SHOW_OSM_BUGS.get()){
if(settings.SHOW_OSM_BUGS.get()){
mapView.addLayer(osmBugsLayer, 2);
} else {
mapView.removeLayer(osmBugsLayer);
}
}
if(mapView.getLayers().contains(poiMapLayer) != OsmandSettings.isShowingPoiOverMap(settings)){
if(OsmandSettings.isShowingPoiOverMap(settings)){
if(mapView.getLayers().contains(poiMapLayer) != settings.SHOW_POI_OVER_MAP.get()){
if(settings.SHOW_POI_OVER_MAP.get()){
mapView.addLayer(poiMapLayer, 3);
} else {
mapView.removeLayer(poiMapLayer);
}
}
if(mapView.getLayers().contains(favoritesLayer) != OsmandSettings.isShowingFavorites(settings)){
if(OsmandSettings.isShowingFavorites(settings)){
if(mapView.getLayers().contains(favoritesLayer) != settings.SHOW_FAVORITES.get()){
if(settings.SHOW_FAVORITES.get()){
mapView.addLayer(favoritesLayer, 4);
} else {
mapView.removeLayer(favoritesLayer);
}
}
trafficLayer.setVisible(OsmandSettings.isShowingYandexTraffic(settings));
trafficLayer.setVisible(settings.SHOW_YANDEX_TRAFFIC.get());
}
private void updateMapSource(){
boolean vectorData = OsmandSettings.isUsingMapVectorData(settings);
boolean vectorData = settings.isUsingMapVectorData();
OsmandApplication app = ((OsmandApplication)getApplication());
ResourceManager rm = app.getResourceManager();
if(vectorData && !app.isApplicationInitializing()){
@ -804,7 +803,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
vectorData = false;
}
}
ITileSource newSource = OsmandSettings.getMapTileSource(settings);
ITileSource newSource = settings.getMapTileSource();
if(mapView.getMap() instanceof SQLiteTileSource){
((SQLiteTileSource)mapView.getMap()).closeDB();
}
@ -820,14 +819,14 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
@Override
protected void onResume() {
super.onResume();
if(OsmandSettings.getMapOrientation(settings) != getRequestedOrientation()){
setRequestedOrientation(OsmandSettings.getMapOrientation(settings));
if(settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()){
setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get());
// can't return from this method we are not sure if activity will be recreated or not
}
currentScreenOrientation = getWindow().getWindowManager().getDefaultDisplay().getOrientation();
boolean showTiles = !OsmandSettings.isUsingMapVectorData(settings);
ITileSource source = showTiles ? OsmandSettings.getMapTileSource(settings) : null;
boolean showTiles = !settings.isUsingMapVectorData();
ITileSource source = showTiles ? settings.getMapTileSource() : null;
if (showTiles != !rendererLayer.isVisible() || !Algoritms.objectEquals(mapView.getMap(), source)) {
updateMapSource();
}
@ -835,7 +834,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
updateApplicationModeSettings();
poiMapLayer.setFilter(OsmandSettings.getPoiFilterForMap(this, (OsmandApplication) getApplication()));
poiMapLayer.setFilter(settings.getPoiFilterForMap((OsmandApplication) getApplication()));
backToLocation.setVisibility(View.INVISIBLE);
routingHelper.setUiActivity(this);
@ -862,10 +861,10 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
providerSupportsBearing = prov == null ? false : prov.supportsBearing() && !isRunningOnEmulator();
providerSupportsSpeed = prov == null ? false : prov.supportsSpeed() && !isRunningOnEmulator();
if(settings != null && settings.contains(OsmandSettings.LAST_KNOWN_MAP_LAT)){
LatLon l = OsmandSettings.getLastKnownMapLocation(settings);
if(settings != null && settings.isLastKnownMapLocation()){
LatLon l = settings.getLastKnownMapLocation();
mapView.setLatLon(l.getLatitude(), l.getLongitude());
mapView.setZoom(OsmandSettings.getLastKnownMapZoom(settings));
mapView.setZoom(settings.getLastKnownMapZoom());
}
@ -875,15 +874,15 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
wakeLock.acquire();
}
OsmandSettings.setMapActivityEnabled(this, true);
settings.MAP_ACTIVITY_ENABLED.set(true);
checkExternalStorage();
showAndHideMapPosition();
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
LatLon latLon = OsmandSettings.getAndClearMapLocationToShow(settings);
LatLon latLon = settings.getAndClearMapLocationToShow();
if (latLon != null && !latLon.equals(cur)) {
mapView.getAnimatedDraggingThread().startMoving(cur.getLatitude(), cur.getLongitude(), latLon.getLatitude(),
latLon.getLongitude(), mapView.getZoom(), OsmandSettings.getMapZoomToShow(settings), mapView.getSourceTileSize(),
latLon.getLongitude(), mapView.getZoom(), settings.getMapZoomToShow(), mapView.getSourceTileSize(),
mapView.getRotate(), true);
}
@ -946,7 +945,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
// when user start dragging
if(locationLayer.getLastKnownLocation() != null){
if(isMapLinkedToLocation()){
OsmandSettings.setSyncMapToGpsLocation(MapActivity.this, false);
settings.setSyncMapToGpsLocation(false);
}
if (backToLocation.getVisibility() != View.VISIBLE) {
runOnUiThread(new Runnable() {
@ -998,7 +997,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
MenuItem navigateToPointMenu = menu.findItem(R.id.map_navigate_to_point);
if (navigateToPointMenu != null) {
navigateToPointMenu.setTitle(routingHelper.isRouteCalculated() ? R.string.stop_routing : R.string.stop_navigation);
if (OsmandSettings.getPointToNavigate(settings) != null) {
if (settings.getPointToNavigate() != null) {
navigateToPointMenu.setVisible(true);
} else {
navigateToPointMenu.setVisible(false);
@ -1070,7 +1069,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
if(navigationLayer.getPointToNavigate() != null){
if(routingHelper.isRouteCalculated()){
routingHelper.setFinalAndCurrentLocation(null, null);
OsmandSettings.setFollowingByRoute(MapActivity.this, false);
settings.FOLLOW_TO_THE_ROUTE.set(false);
routingHelper.setFollowingMode(false);
} else {
navigateToPoint(null);
@ -1095,7 +1094,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
return ApplicationMode.values()[i];
}
}
return OsmandSettings.getApplicationMode(settings);
return settings.getApplicationMode();
}
@ -1111,7 +1110,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton);
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
ApplicationMode appMode = OsmandSettings.getApplicationMode(settings);
ApplicationMode appMode = settings.getApplicationMode();
for(int i=0; i< buttons.length; i++){
if(buttons[i] != null){
final int ind = i;
@ -1157,7 +1156,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
map.setLatitude(lat);
map.setLongitude(lon);
routingHelper.setAppMode(mode);
OsmandSettings.setFollowingByRoute(MapActivity.this, false);
settings.FOLLOW_TO_THE_ROUTE.set(false);
routingHelper.setFollowingMode(false);
routingHelper.setFinalAndCurrentLocation(navigationLayer.getPointToNavigate(), map);
}
@ -1168,7 +1167,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
public void onClick(DialogInterface dialog, int which) {
ApplicationMode mode = getAppMode(buttons);
// change global settings
boolean changed = ApplicationMode.setAppMode(mode, (OsmandApplication) getApplication());
boolean changed = settings.setAppMode(mode, (OsmandApplication) getApplication());
if (changed) {
updateApplicationModeSettings();
mapView.refreshMap();
@ -1181,7 +1180,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
location.setLongitude(lon);
}
routingHelper.setAppMode(mode);
OsmandSettings.setFollowingByRoute(MapActivity.this, true);
settings.FOLLOW_TO_THE_ROUTE.set(true);
routingHelper.setFollowingMode(true);
routingHelper.setFinalAndCurrentLocation(navigationLayer.getPointToNavigate(), location);
@ -1230,14 +1229,11 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
try {
double lt = Double.parseDouble(lat);
double ln = Double.parseDouble(lon);
Editor edit = OsmandSettings.getWriteableEditor(this);
edit.putFloat(OsmandSettings.LAST_KNOWN_MAP_LAT, (float) lt);
edit.putFloat(OsmandSettings.LAST_KNOWN_MAP_LON, (float) ln);
settings.setLastKnownMapLocation((float) lt, (float) ln);
String zoom = data.getQueryParameter("z");
if(zoom != null){
edit.putInt(OsmandSettings.LAST_KNOWN_MAP_ZOOM, Integer.parseInt(zoom));
settings.setLastKnownMapZoom(Integer.parseInt(zoom));
}
edit.commit();
} catch (NumberFormatException e) {
}
}
@ -1267,10 +1263,10 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
final boolean[] selected = new boolean[layersList.size()];
Arrays.fill(selected, true);
selected[1] = OsmandSettings.isShowingPoiOverMap(settings);
selected[2] = OsmandSettings.isShowingTransportOverMap(settings);
selected[3] = OsmandSettings.isShowingOsmBugs(settings);
selected[4] = OsmandSettings.isShowingFavorites(settings);
selected[1] = settings.SHOW_POI_OVER_MAP.get();
selected[2] = settings.SHOW_TRANSPORT_OVER_MAP.get();
selected[3] = settings.SHOW_OSM_BUGS.get();
selected[4] = settings.SHOW_FAVORITES.get();
selected[5] = gpxLayer.isVisible();
selected[trafficInd] = trafficLayer.isVisible();
if(routeInfoInd != -1){
@ -1292,13 +1288,13 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
if(isChecked){
selectPOIFilterLayer();
}
OsmandSettings.setShowPoiOverMap(MapActivity.this, isChecked);
settings.SHOW_POI_OVER_MAP.set(isChecked);
} else if(item == 2){
OsmandSettings.setShowTransortOverMap(MapActivity.this, isChecked);
settings.SHOW_TRANSPORT_OVER_MAP.set(isChecked);
} else if(item == 3){
OsmandSettings.setShowingOsmBugs(MapActivity.this, isChecked);
settings.SHOW_OSM_BUGS.set(isChecked);
} else if(item == 4){
OsmandSettings.setShowingFavorites(MapActivity.this, isChecked);
settings.SHOW_FAVORITES.set(isChecked);
} else if(item == 5){
if(gpxLayer.isVisible()){
gpxLayer.clearCurrentGPX();
@ -1312,7 +1308,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
} else if(item == transportRouteInfoInd){
transportInfoLayer.setVisible(isChecked);
} else if(item == trafficInd){
OsmandSettings.setShowingYandexTraffic(MapActivity.this, isChecked);
settings.SHOW_YANDEX_TRAFFIC.set(isChecked);
}
updateLayers();
mapView.refreshMap();
@ -1323,7 +1319,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
private void useGPXFileLayer(final boolean useRouting, final LatLon endForRouting) {
final List<String> list = new ArrayList<String>();
final File dir = OsmandSettings.extendOsmandPath(getApplicationContext(), ResourceManager.APP_DIR + SavingTrackHelper.TRACKS_PATH);
final File dir = settings.extendOsmandPath(ResourceManager.APP_DIR + SavingTrackHelper.TRACKS_PATH);
if (dir != null && dir.canRead()) {
File[] files = dir.listFiles();
if (files != null) {
@ -1383,7 +1379,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
}
});
} else {
OsmandSettings.setShowingFavorites(MapActivity.this, true);
settings.SHOW_FAVORITES.set(true);
List<FavouritePoint> pts = new ArrayList<FavouritePoint>();
for(WptPt p : res.wayPoints){
FavouritePoint pt = new FavouritePoint();
@ -1436,12 +1432,12 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
LatLon endPoint = endForRouting;
if(/*endForRouting == null && */!l.isEmpty()){
LatLon point = new LatLon(l.get(l.size() - 1).getLatitude(), l.get(l.size() - 1).getLongitude());
OsmandSettings.setPointToNavigate(MapActivity.this, point.getLatitude(), point.getLongitude());
settings.setPointToNavigate(point.getLatitude(), point.getLongitude());
endPoint = point;
navigationLayer.setPointToNavigate(point);
}
if(endForRouting != null){
OsmandSettings.setFollowingByRoute(MapActivity.this, true);
settings.FOLLOW_TO_THE_ROUTE.set(true);
routingHelper.setFollowingMode(true);
routingHelper.setFinalAndCurrentLocation(endPoint, startForRouting, l);
((OsmandApplication)getApplication()).showDialogInitializingCommandPlayer(MapActivity.this);
@ -1486,7 +1482,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
newIntent.putExtra(EditPOIFilterActivity.SEARCH_LON, mapView.getLongitude());
startActivity(newIntent);
} else {
OsmandSettings.setPoiFilterForMap(MapActivity.this, filterId);
settings.setPoiFilterForMap(filterId);
poiMapLayer.setFilter(poiFilters.getFilterById(filterId));
mapView.refreshMap();
}

View file

@ -49,7 +49,7 @@ public class NavigatePointActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LatLon loc = OsmandSettings.getLastKnownMapLocation(OsmandSettings.getPrefs(this));
LatLon loc = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
setContentView(R.layout.navigate_point);
setTitle(R.string.map_specify_point);
initUI(loc.getLatitude(), loc.getLongitude());
@ -129,7 +129,7 @@ public class NavigatePointActivity extends Activity {
double lon = convert(((TextView) findViewById(R.id.LongitudeEdit)).getText().toString());
if(navigate){
OsmandSettings.setPointToNavigate(this, lat, lon);
OsmandSettings.getOsmandSettings(this).setPointToNavigate(lat, lon);
} else {
// in case when it is dialog
if(activity != null) {
@ -137,7 +137,7 @@ public class NavigatePointActivity extends Activity {
activity.getMapView().getAnimatedDraggingThread().startMoving(v.getLatitude(), v.getLongitude(),
lat, lon, v.getZoom(), v.getZoom(), v.getSourceTileSize(), v.getRotate(), true);
} else {
OsmandSettings.setMapLocationToShow(this, lat, lon, MessageFormat.format(getString(R.string.search_history_navigate_to), lat, lon));
OsmandSettings.getOsmandSettings(this).setMapLocationToShow(lat, lon, MessageFormat.format(getString(R.string.search_history_navigate_to), lat, lon));
}
}
close();

View file

@ -26,7 +26,6 @@ import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Handler;
import android.text.format.DateFormat;
@ -41,6 +40,7 @@ public class OsmandApplication extends Application {
RoutingHelper routingHelper = null;
FavouritesDbHelper favorites = null;
CommandPlayer player = null;
OsmandSettings osmandSettings;
// start variables
@ -56,7 +56,8 @@ public class OsmandApplication extends Application {
public void onCreate(){
super.onCreate();
routingHelper = new RoutingHelper(OsmandSettings.getApplicationMode(OsmandSettings.getPrefs(OsmandApplication.this)), OsmandApplication.this, player);
osmandSettings = OsmandSettings.getOsmandSettings(this);
routingHelper = new RoutingHelper(osmandSettings, OsmandApplication.this, player);
manager = new ResourceManager(this);
daynightHelper = new DayNightHelper(this);
uiHandler = new Handler();
@ -64,6 +65,10 @@ public class OsmandApplication extends Application {
startApplication();
}
public OsmandSettings getSettings() {
return osmandSettings;
}
public PoiFiltersHelper getPoiFilters() {
if(poiFilters == null){
poiFilters = new PoiFiltersHelper(this);
@ -103,9 +108,8 @@ public class OsmandApplication extends Application {
}
public void checkPrefferedLocale() {
SharedPreferences settings = OsmandSettings.getPrefs(this);
Configuration config = getBaseContext().getResources().getConfiguration();
String lang = OsmandSettings.getPreferredLocale(settings);
String lang = osmandSettings.PREFERRED_LOCALE.get();
if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) {
prefferedLocale = new Locale(lang);
Locale.setDefault(prefferedLocale);
@ -144,7 +148,7 @@ public class OsmandApplication extends Application {
public void showDialogInitializingCommandPlayer(final Context uiContext){
String voiceProvider = OsmandSettings.getVoiceProvider(OsmandSettings.getPrefs(this));
String voiceProvider = osmandSettings.VOICE_PROVIDER.get();
if(voiceProvider == null){
Builder builder = new AlertDialog.Builder(uiContext);
builder.setCancelable(true);
@ -191,7 +195,7 @@ public class OsmandApplication extends Application {
player = new CommandPlayer(OsmandApplication.this);
routingHelper.getVoiceRouter().setPlayer(player);
}
return player.init(OsmandSettings.getVoiceProvider(OsmandSettings.getPrefs(this)));
return player.init(osmandSettings.VOICE_PROVIDER.get());
}
public NavigationService getNavigationService() {
@ -288,7 +292,7 @@ public class OsmandApplication extends Application {
@Override
public void uncaughtException(final Thread thread, final Throwable ex) {
File file = OsmandSettings.extendOsmandPath(getApplicationContext(), EXCEPTION_PATH);
File file = osmandSettings.extendOsmandPath(EXCEPTION_PATH);
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(out);

View file

@ -60,13 +60,16 @@ public class RoutingHelper {
private int evalWaitInterval = 3000;
private ApplicationMode mode;
private OsmandSettings settings;
private RouteProvider provider = new RouteProvider();
private VoiceRouter voiceRouter;
public RoutingHelper(ApplicationMode mode, Context context, CommandPlayer player){
this.mode = mode;
public RoutingHelper(OsmandSettings settings, Context context, CommandPlayer player){
this.settings = settings;
this.context = context;
voiceRouter = new VoiceRouter(this, player);
}
@ -138,7 +141,7 @@ public class RoutingHelper {
if(currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < 60){
if(lastFixedLocation != null && lastFixedLocation.distanceTo(lastPoint) < 60){
showMessage(context.getString(R.string.arrived_at_destination));
OsmandSettings.setFollowingByRoute(context, false);
settings.FOLLOW_TO_THE_ROUTE.set(false);
voiceRouter.arrivedDestinationPoint();
updateCurrentRoute(routeNodes.size() - 1);
// clear final location to prevent all time showing message
@ -425,8 +428,8 @@ public class RoutingHelper {
}
// temporary check while osmand offline router is not stable
RouteService serviceToUse= OsmandSettings.getRouterService(OsmandSettings.getPrefs(context));
if (serviceToUse == RouteService.OSMAND && !OsmandSettings.isOsmandRoutingServiceUsed(context)) {
RouteService serviceToUse= settings.ROUTER_SERVICE.get();
if (serviceToUse == RouteService.OSMAND && !settings.USE_OSMAND_ROUTING_SERVICE_ALWAYS.get()) {
double distance = MapUtils.getDistance(end, start.getLatitude(), start.getLongitude());
if (distance > DISTANCE_TO_USE_OSMAND_ROUTER) {
showMessage(context.getString(R.string.osmand_routing_experimental));
@ -438,7 +441,7 @@ public class RoutingHelper {
if(currentRunningJob == null){
// do not evaluate very often
if (System.currentTimeMillis() - lastTimeEvaluatedRoute > evalWaitInterval) {
final boolean fastRouteMode = OsmandSettings.isFastRouteMode(context);
final boolean fastRouteMode = settings.FAST_ROUTE_MODE.get();
synchronized (this) {
currentRunningJob = new Thread(new Runnable() {
@Override

View file

@ -19,7 +19,6 @@ import net.osmand.plus.ResourceManager;
import org.apache.commons.logging.Log;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
@ -115,7 +114,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
public List<String> saveDataToGpx(){
SQLiteDatabase db = getReadableDatabase();
List<String> warnings = new ArrayList<String>();
File dir = OsmandSettings.getExternalStorageDirectory(ctx);
File dir = OsmandSettings.getOsmandSettings(ctx).getExternalStorageDirectory();
if(db != null && dir.canWrite()){
dir = new File(dir, ResourceManager.APP_DIR + TRACKS_PATH);
dir.mkdirs();
@ -228,8 +227,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
query.close();
}
public void insertData(double lat, double lon, double alt, double speed, long time, SharedPreferences settings){
if (time - lastTimeUpdated > OsmandSettings.getSavingTrackInterval(settings)*1000) {
public void insertData(double lat, double lon, double alt, double speed, long time, OsmandSettings settings){
if (time - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get()*1000) {
SQLiteDatabase db = getWritableDatabase();
if (db != null) {
db.execSQL(updateScript, new Object[] { lat, lon, alt, speed, time });

View file

@ -9,6 +9,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
@ -21,6 +22,7 @@ import net.osmand.plus.ResourceManager;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.OsmandSettings.DayNightMode;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.activities.RouteProvider.RouteService;
import net.osmand.plus.render.BaseOsmandRender;
import net.osmand.plus.render.RendererRegistry;
@ -53,32 +55,6 @@ import android.widget.Toast;
public class SettingsActivity extends PreferenceActivity implements OnPreferenceChangeListener, OnPreferenceClickListener {
private final static String VECTOR_MAP = "#VECTOR_MAP"; //$NON-NLS-1$
private class BooleanPreference {
private final boolean defValue;
private final String id;
private CheckBoxPreference pref;
public BooleanPreference(String id, boolean defValue){
this.id = id;
this.defValue = defValue;
}
public String getId() {
return id;
}
public boolean getDefValue() {
return defValue;
}
public void setPref(CheckBoxPreference pref) {
this.pref = pref;
}
public CheckBoxPreference getPref() {
return pref;
}
}
private EditTextPreference userPassword;
private EditTextPreference userName;
private EditTextPreference applicationDir;
@ -88,57 +64,81 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
private Preference downloadIndexes;
private ListPreference applicationMode;
private ListPreference daynightMode;
private ListPreference saveTrackInterval;
private ListPreference rotateMap;
private ListPreference tileSourcePreference;
private ListPreference positionOnMap;
private ListPreference routerPreference;
private ListPreference maxLevelToDownload;
private ListPreference mapScreenOrientation;
private ListPreference voicePreference;
private ListPreference metricPreference;
private ListPreference preferredLocale;
private ListPreference rendererPreference;
private ListPreference routeServiceInterval;
private ListPreference routeServiceWaitInterval;
private ListPreference routeServiceProvider;
private CheckBoxPreference routeServiceEnabled;
private CheckBoxPreference useInternetToDownload;
private ProgressDialog progressDlg;
private BooleanPreference[] booleanPreferences = new BooleanPreference[]{
new BooleanPreference(OsmandSettings.SHOW_VIEW_ANGLE, OsmandSettings.SHOW_VIEW_ANGLE_DEF),
new BooleanPreference(OsmandSettings.USE_TRACKBALL_FOR_MOVEMENTS, OsmandSettings.USE_TRACKBALL_FOR_MOVEMENTS_DEF),
new BooleanPreference(OsmandSettings.USE_HIGH_RES_MAPS, OsmandSettings.USE_HIGH_RES_MAPS_DEF),
new BooleanPreference(OsmandSettings.USE_ENGLISH_NAMES, OsmandSettings.USE_ENGLISH_NAMES_DEF),
new BooleanPreference(OsmandSettings.AUTO_ZOOM_MAP, OsmandSettings.AUTO_ZOOM_MAP_DEF),
new BooleanPreference(OsmandSettings.SAVE_TRACK_TO_GPX, OsmandSettings.SAVE_TRACK_TO_GPX_DEF),
new BooleanPreference(OsmandSettings.DEBUG_RENDERING_INFO, OsmandSettings.DEBUG_RENDERING_INFO_DEF),
new BooleanPreference(OsmandSettings.USE_STEP_BY_STEP_RENDERING, OsmandSettings.USE_STEP_BY_STEP_RENDERING_DEF),
new BooleanPreference(OsmandSettings.FAST_ROUTE_MODE, OsmandSettings.FAST_ROUTE_MODE_DEF),
new BooleanPreference(OsmandSettings.USE_OSMAND_ROUTING_SERVICE_ALWAYS, OsmandSettings.USE_OSMAND_ROUTING_SERVICE_ALWAYS_DEF),
};
private BroadcastReceiver broadcastReceiver;
private OsmandSettings osmandSettings;
private Map<String, Preference> screenPreferences = new LinkedHashMap<String, Preference>();
private Map<String, OsmandPreference<Boolean>> booleanPreferences = new LinkedHashMap<String, OsmandPreference<Boolean>>();
private Map<String, OsmandPreference<?>> listPreferences = new LinkedHashMap<String, OsmandPreference<?>>();
private Map<String, Map<String, ?>> listPrefValues = new LinkedHashMap<String, Map<String, ?>>();
private void registerBooleanPreference(OsmandPreference<Boolean> b, PreferenceScreen screen){
CheckBoxPreference p = (CheckBoxPreference) screen.findPreference(b.getId());
p.setOnPreferenceChangeListener(this);
screenPreferences.put(b.getId(), p);
booleanPreferences.put(b.getId(), b);
}
private <T> void registerListPreference(OsmandPreference<T> b, PreferenceScreen screen, String[] names, T[] values){
ListPreference p = (ListPreference) screen.findPreference(b.getId());
p.setOnPreferenceChangeListener(this);
LinkedHashMap<String, Object> vals = new LinkedHashMap<String, Object>();
screenPreferences.put(b.getId(), p);
listPreferences.put(b.getId(), b);
listPrefValues.put(b.getId(), vals);
assert names.length == values.length;
for(int i=0; i<names.length; i++){
vals.put(names[i], values[i]);
}
}
private Set<String> getVoiceFiles(){
// read available voice data
File extStorage = osmandSettings.extendOsmandPath(ResourceManager.VOICE_PATH);
Set<String> setFiles = new LinkedHashSet<String>();
if (extStorage.exists()) {
for (File f : extStorage.listFiles()) {
if (f.isDirectory()) {
setFiles.add(f.getName());
}
}
}
return setFiles;
}
@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);
for(BooleanPreference b : booleanPreferences){
CheckBoxPreference p = (CheckBoxPreference) screen.findPreference(b.getId());
p.setOnPreferenceChangeListener(this);
b.setPref(p);
}
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.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);
useInternetToDownload =(CheckBoxPreference) screen.findPreference(OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES);
useInternetToDownload.setOnPreferenceChangeListener(this);
reloadIndexes =(Preference) screen.findPreference(OsmandSettings.RELOAD_INDEXES);
reloadIndexes.setOnPreferenceClickListener(this);
@ -146,49 +146,102 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
downloadIndexes.setOnPreferenceClickListener(this);
saveCurrentTrack =(Preference) screen.findPreference(OsmandSettings.SAVE_CURRENT_TRACK);
saveCurrentTrack.setOnPreferenceClickListener(this);
routeServiceEnabled =(CheckBoxPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_ENABLED);
routeServiceEnabled.setOnPreferenceChangeListener(this);
userName = (EditTextPreference) screen.findPreference(OsmandSettings.USER_NAME);
userName = (EditTextPreference) screen.findPreference(osmandSettings.USER_NAME.getId());
userName.setOnPreferenceChangeListener(this);
userPassword = (EditTextPreference) screen.findPreference(OsmandSettings.USER_PASSWORD);
userPassword = (EditTextPreference) screen.findPreference(osmandSettings.USER_PASSWORD.getId());
userPassword.setOnPreferenceChangeListener(this);
applicationDir = (EditTextPreference) screen.findPreference(OsmandSettings.EXTERNAL_STORAGE_DIR);
applicationDir.setOnPreferenceChangeListener(this);
// 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});
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();
entries = new String[] { "", "en", "cs", "de", "es", "fr", "hu", "it", "pt", "ru", "sk" };
entrieValues = new String[entries.length];
entrieValues[0] = getString(R.string.system_locale);
for (int i=1; i< entries.length; i++) {
entrieValues[i] = entries[i];
}
registerListPreference(osmandSettings.PREFERRED_LOCALE, screen, entries, entries);
Set<String> voiceFiles = getVoiceFiles();
entries = new String[voiceFiles.size() + 1];
entrieValues = new String[voiceFiles.size() + 1];
int k = 0;
entries[k++] = getString(R.string.voice_not_use);
for (String s : voiceFiles) {
entries[k] = s;
entrieValues[k] = s;
k++;
}
registerListPreference(osmandSettings.VOICE_PROVIDER, screen, entries, entries);
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);
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, entries);
saveTrackInterval =(ListPreference) screen.findPreference(osmandSettings.SAVE_TRACK_INTERVAL.getId());
saveTrackInterval.setOnPreferenceChangeListener(this);
routeServiceInterval =(ListPreference) screen.findPreference(osmandSettings.SERVICE_OFF_INTERVAL.getId());
routeServiceInterval.setOnPreferenceChangeListener(this);
routeServiceWaitInterval =(ListPreference) screen.findPreference(osmandSettings.SERVICE_OFF_WAIT_INTERVAL.getId());
routeServiceWaitInterval.setOnPreferenceChangeListener(this);
applicationMode =(ListPreference) screen.findPreference(OsmandSettings.APPLICATION_MODE);
applicationMode.setOnPreferenceChangeListener(this);
daynightMode =(ListPreference) screen.findPreference(OsmandSettings.DAYNIGHT_MODE);
daynightMode.setOnPreferenceChangeListener(this);
rotateMap =(ListPreference) screen.findPreference(OsmandSettings.ROTATE_MAP);
rotateMap.setOnPreferenceChangeListener(this);
saveTrackInterval =(ListPreference) screen.findPreference(OsmandSettings.SAVE_TRACK_INTERVAL);
saveTrackInterval.setOnPreferenceChangeListener(this);
positionOnMap =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP);
positionOnMap.setOnPreferenceChangeListener(this);
mapScreenOrientation = (ListPreference) screen.findPreference(OsmandSettings.MAP_SCREEN_ORIENTATION);
mapScreenOrientation.setOnPreferenceChangeListener(this);
maxLevelToDownload = (ListPreference) screen.findPreference(OsmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE);
maxLevelToDownload.setOnPreferenceChangeListener(this);
tileSourcePreference = (ListPreference) screen.findPreference(OsmandSettings.MAP_TILE_SOURCES);
tileSourcePreference.setOnPreferenceChangeListener(this);
routerPreference = (ListPreference) screen.findPreference(OsmandSettings.ROUTER_SERVICE);
routerPreference.setOnPreferenceChangeListener(this);
voicePreference = (ListPreference) screen.findPreference(OsmandSettings.VOICE_PROVIDER);
voicePreference.setOnPreferenceChangeListener(this);
metricPreference = (ListPreference) screen.findPreference(OsmandSettings.DEFAULT_METRIC_SYSTEM);
metricPreference.setOnPreferenceChangeListener(this);
preferredLocale = (ListPreference) screen.findPreference(OsmandSettings.PREFERRED_LOCALE);
preferredLocale.setOnPreferenceChangeListener(this);
rendererPreference =(ListPreference) screen.findPreference(OsmandSettings.RENDERER);
rendererPreference.setOnPreferenceChangeListener(this);
routeServiceInterval =(ListPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_INTERVAL);
routeServiceInterval.setOnPreferenceChangeListener(this);
routeServiceWaitInterval =(ListPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_WAIT_INTERVAL);
routeServiceWaitInterval.setOnPreferenceChangeListener(this);
routeServiceProvider =(ListPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_PROVIDER);
routeServiceProvider.setOnPreferenceChangeListener(this);
routeServiceEnabled =(CheckBoxPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_ENABLED);
routeServiceEnabled.setOnPreferenceChangeListener(this);
rendererPreference =(ListPreference) screen.findPreference(osmandSettings.RENDERER.getId());
rendererPreference.setOnPreferenceChangeListener(this);
broadcastReceiver = new BroadcastReceiver(){
@ -202,7 +255,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
}
private void updateApplicationDirSummary() {
String storageDir = OsmandSettings.getExternalStorageDirectory(getApplicationContext()).getAbsolutePath();
String storageDir = osmandSettings.getExternalStorageDirectory().getAbsolutePath();
applicationDir.setText(storageDir);
applicationDir.setSummary(storageDir);
}
@ -239,21 +292,34 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
}
public void updateAllSettings(){
SharedPreferences prefs = OsmandSettings.getPrefs(this);
for(BooleanPreference b : booleanPreferences){
b.getPref().setChecked(prefs.getBoolean(b.getId(), b.getDefValue()));
for(OsmandPreference<Boolean> b : booleanPreferences.values()){
CheckBoxPreference pref = (CheckBoxPreference) screenPreferences.get(b.getId());
pref.setChecked(b.get());
}
for(OsmandPreference<?> p : listPreferences.values()){
ListPreference listPref = (ListPreference) screenPreferences.get(p.getId());
Map<String, ?> prefValues = listPrefValues.get(p.getId());
String[] entryValues = new String[prefValues.size()];
String[] entries = new String[prefValues.size()];
int i = 0;
for(Entry<String, ?> e : prefValues.entrySet()){
entries[i] = e.getKey();
entryValues[i] = e.getValue() + ""; // case of null
i++;
}
listPref.setEntries(entries);
listPref.setEntryValues(entryValues);
listPref.setValue(p.get() + "");
}
userName.setText(OsmandSettings.getUserName(prefs));
userPassword.setText(OsmandSettings.getUserPassword(prefs));
applicationDir.setText(OsmandSettings.getExternalStorageDirectory(prefs).getAbsolutePath());
useInternetToDownload.setChecked(OsmandSettings.isUsingInternetToDownloadTiles(prefs));
Resources resources = this.getResources();
String[] e = new String[] {resources.getString(R.string.position_on_map_center),
resources.getString(R.string.position_on_map_bottom)};
positionOnMap.setEntryValues(e);
positionOnMap.setEntries(e);
positionOnMap.setValueIndex(OsmandSettings.getPositionOnMap(prefs));
fillTime(saveTrackInterval, new int[]{1, 2, 3, 5, 15, 20, 30}, new int[]{1, 2, 3, 5}, OsmandSettings.getSavingTrackInterval(prefs)); //$NON-NLS-1$
@ -261,27 +327,11 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
fillTime(routeServiceWaitInterval, new int[]{15, 30, 45, 60, 90}, new int[]{2, 3, 5, 10}, OsmandSettings.getServiceOffWaitInterval(prefs)/1000);
fill(rotateMap, //
new String[]{getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)}, //
new String[]{OsmandSettings.ROTATE_MAP_NONE+"", OsmandSettings.ROTATE_MAP_BEARING+"", OsmandSettings.ROTATE_MAP_COMPASS+""}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
OsmandSettings.getRotateMap(prefs)+""); //$NON-NLS-1$
fill(routeServiceProvider,//
new String[]{getString(R.string.gps_provider), getString(R.string.network_provider)}, //
new String[]{LocationManager.GPS_PROVIDER, LocationManager.NETWORK_PROVIDER}, //
OsmandSettings.getServiceOffProvider(prefs));
routeServiceEnabled.setChecked(getMyApplication().getNavigationService() != null);
fill(mapScreenOrientation, //
new String[] {
resources.getString(R.string.map_orientation_portrait),
resources.getString(R.string.map_orientation_landscape),
resources.getString(R.string.map_orientation_default), }, //
new String[] {
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + "", //$NON-NLS-1$
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE + "", ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED + "" }, //$NON-NLS-1$ //$NON-NLS-2$
OsmandSettings.getMapOrientation(prefs) + ""); //$NON-NLS-1$
ApplicationMode[] presets = ApplicationMode.values();
String[] names = new String[presets.length];
@ -292,65 +342,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
}
fill(applicationMode, names, values, OsmandSettings.getApplicationMode(prefs).name());
DayNightMode[] dnpresets = DayNightMode.possibleValues(this);
names = new String[dnpresets.length];
values = new String[dnpresets.length];
for(int i=0; i< dnpresets.length; i++){
names[i] = dnpresets[i].toHumanString(this);
values[i] = dnpresets[i].name();
}
fill(daynightMode, names, values, OsmandSettings.getDayNightMode(prefs).name());
String[] entries = new String[RouteService.values().length];
String entry = OsmandSettings.getRouterService(prefs).getName();
for (int i = 0; i < RouteService.values().length; i++) {
entries[i] = RouteService.values()[i].getName();
}
fill(routerPreference, entries, entries, entry);
names = new String[MetricsConstants.values().length];
values = new String[MetricsConstants.values().length];
entry = OsmandSettings.getDefaultMetricConstants(this).name();
for (int i = 0; i < MetricsConstants.values().length; i++) {
values[i] = MetricsConstants.values()[i].name();
names[i] = MetricsConstants.values()[i].toHumanString(this);
}
fill(metricPreference, names, values, entry);
String[] locales = //getResources().getAssets().getLocales();
new String [] { "en", "cs", "de", "es", "fr", "hu", "it", "pt", "ru", "sk"};
values = new String[locales.length + 1];
names = new String[locales.length + 1] ;
values[0] = OsmandSettings.PREFERRED_LOCALE_DEF;
names[0] = getString(R.string.system_locale);
System.arraycopy(locales, 0, names, 1, locales.length);
System.arraycopy(locales, 0, values, 1, locales.length);
fill(preferredLocale, names, values, OsmandSettings.getPreferredLocale(prefs));
// read available voice data
File extStorage = OsmandSettings.extendOsmandPath(getApplicationContext(), ResourceManager.VOICE_PATH);
Set<String> setFiles = new LinkedHashSet<String>();
if (extStorage.exists()) {
for (File f : extStorage.listFiles()) {
if (f.isDirectory()) {
setFiles.add(f.getName());
}
}
}
String provider = OsmandSettings.getVoiceProvider(prefs);
entries = new String[setFiles.size() + 1];
int k = 0;
entries[k++] = getString(R.string.voice_not_use);
for(String s : setFiles){
entries[k++] = s;
}
voicePreference.setEntries(entries);
voicePreference.setEntryValues(entries);
if(setFiles.contains(provider)){
voicePreference.setValue(provider);
} else {
voicePreference.setValueIndex(0);
}
String vectorRenderer = OsmandSettings.getVectorRenderer(prefs);
Collection<String> rendererNames = RendererRegistry.getRegistry().getRendererNames();
@ -363,13 +356,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
rendererPreference.setValueIndex(0);
}
int startZoom = 12;
int endZoom = 19;
entries = new String[endZoom - startZoom + 1];
for (int i = startZoom; i <= endZoom; i++) {
entries[i - startZoom] = i + ""; //$NON-NLS-1$
}
fill(maxLevelToDownload, entries, entries, OsmandSettings.getMaximumLevelToDownloadTile(prefs)+""); //$NON-NLS-1$
Map<String, String> entriesMap = getTileSourceEntries(this);
entries = new String[entriesMap.size() + 1];
@ -449,51 +436,49 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
OsmandSettings.getWriteableEditor(this).putInt(id, value).commit();
}
@SuppressWarnings("unchecked")
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// handle boolean prefences
BooleanPreference p = null;
for(BooleanPreference b : booleanPreferences){
if(b.getPref() == preference){
p = b;
break;
OsmandPreference<Boolean> boolPref = booleanPreferences.get(preference.getKey());
OsmandPreference<Object> listPref = (OsmandPreference<Object>) listPreferences.get(preference.getKey());
if(boolPref != null){
boolPref.set((Boolean)newValue);
} else if (listPref != null) {
CharSequence entry = ((ListPreference) preference).getEntry();
Map<String, ?> map = listPrefValues.get(preference.getKey());
Object obj = map.get(entry);
listPref.set(obj);
if(listPref.getId().equals(osmandSettings.DAYNIGHT_MODE.getId())){
getMyApplication().getDaynightHelper().setDayNightMode(osmandSettings.DAYNIGHT_MODE.get());
} else if(listPref.getId().equals(osmandSettings.VOICE_PROVIDER.getId())){
getMyApplication().initCommandPlayer();
} else if(listPref.getId().equals(osmandSettings.PREFERRED_LOCALE.getId())){
// restart activity
getMyApplication().checkPrefferedLocale();
Intent intent = getIntent();
finish();
startActivity(intent);
}
}
if(p != null){
editBoolean(p.getId(), (Boolean)newValue);
} else if(preference == applicationMode){
boolean changed = ApplicationMode.setAppMode(ApplicationMode.valueOf(newValue.toString()), getMyApplication());
if(changed){
updateAllSettings();
}
} else if(preference == daynightMode){
editString(OsmandSettings.DAYNIGHT_MODE, (String) newValue);
getMyApplication().getDaynightHelper().setDayNightMode(DayNightMode.valueOf(newValue.toString()));
} else if(preference == mapScreenOrientation){
editInt(OsmandSettings.MAP_SCREEN_ORIENTATION, Integer.parseInt(newValue.toString()));
} else if(preference == saveTrackInterval){
editInt(OsmandSettings.SAVE_TRACK_INTERVAL, Integer.parseInt(newValue.toString()));
} else if (preference == routeServiceInterval) {
editInt(OsmandSettings.SERVICE_OFF_INTERVAL, Integer.parseInt((String) newValue) * 1000);
} else if (preference == routeServiceWaitInterval) {
editInt(OsmandSettings.SERVICE_OFF_WAIT_INTERVAL, Integer.parseInt((String) newValue) * 1000);
} else if(preference == userPassword){
editString(OsmandSettings.USER_PASSWORD, (String) newValue);
} else if(preference == useInternetToDownload){
OsmandSettings.setUseInternetToDownloadTiles((Boolean) newValue, OsmandSettings.getWriteableEditor(this));
} else if(preference == userName){
editString(OsmandSettings.USER_NAME, (String) newValue);
} else if(preference == applicationDir){
warnAboutChangingStorage((String) newValue);
return false;
} else if(preference == positionOnMap){
editInt(OsmandSettings.POSITION_ON_MAP, positionOnMap.findIndexOfValue((String) newValue));
} else if (preference == maxLevelToDownload) {
editInt(OsmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE, Integer.parseInt((String) newValue));
} else if (preference == routeServiceInterval) {
editInt(OsmandSettings.SERVICE_OFF_INTERVAL, Integer.parseInt((String) newValue) * 1000);
} else if (preference == routeServiceWaitInterval) {
editInt(OsmandSettings.SERVICE_OFF_WAIT_INTERVAL, Integer.parseInt((String) newValue) * 1000);
} else if (preference == rotateMap) {
editInt(OsmandSettings.ROTATE_MAP, Integer.parseInt((String) newValue));
} else if (preference == routeServiceProvider) {
editString(OsmandSettings.SERVICE_OFF_PROVIDER, (String) newValue);
} else if (preference == routeServiceEnabled) {
Intent serviceIntent = new Intent(this, NavigationService.class);
if ((Boolean) newValue) {
@ -506,17 +491,6 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
routeServiceEnabled.setChecked(getMyApplication().getNavigationService() != null);
}
}
} else if (preference == routerPreference) {
RouteService s = null;
for(RouteService r : RouteService.values()){
if(r.getName().equals(newValue)){
s = r;
break;
}
}
if(s != null){
editInt(OsmandSettings.ROUTER_SERVICE, s.ordinal());
}
} else if (preference == rendererPreference) {
BaseOsmandRender loaded = RendererRegistry.getRegistry().getRenderer((String) newValue);
if(loaded == null){
@ -527,24 +501,6 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
Toast.makeText(this, R.string.renderer_load_sucess, Toast.LENGTH_SHORT).show();
getMyApplication().getResourceManager().getRenderer().clearCache();
}
} else if (preference == voicePreference) {
int i = voicePreference.findIndexOfValue((String) newValue);
if (i == 0) {
editString(OsmandSettings.VOICE_PROVIDER, null);
} else {
editString(OsmandSettings.VOICE_PROVIDER, (String) newValue);
}
getMyApplication().initCommandPlayer();
} else if (preference == metricPreference) {
MetricsConstants mc = MetricsConstants.valueOf((String) newValue);
OsmandSettings.setDefaultMetricConstants(mc, this);
} else if (preference == preferredLocale) {
editString(OsmandSettings.PREFERRED_LOCALE, (String) newValue);
// restart activity
getMyApplication().checkPrefferedLocale();
Intent intent = getIntent();
finish();
startActivity(intent);
} else if (preference == tileSourcePreference) {
if(VECTOR_MAP.equals((String) newValue)){
editBoolean(OsmandSettings.MAP_VECTOR_DATA, true);

View file

@ -81,7 +81,7 @@ public class ShowRouteInfoActivity extends ListActivity {
RouteDirectionInfo item = ((RouteInfoAdapter)getListAdapter()).getItem(position - 1);
Location loc = helper.getLocationFromRouteDirection(item);
if(loc != null){
OsmandSettings.setMapLocationToShow(this, loc.getLatitude(),loc.getLongitude());
OsmandSettings.getOsmandSettings(this).setMapLocationToShow(loc.getLatitude(),loc.getLongitude());
startActivity(new Intent(this, MapActivity.class));
}
}

View file

@ -49,8 +49,7 @@ public class GeoIntentActivity extends ListActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.search_address_offline);
getMyApplication().checkApplicationIsBeingInitialized(this);
location = OsmandSettings.getLastKnownMapLocation(OsmandSettings
.getPrefs(this));
location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
final Intent intent = getIntent();
if (intent != null) {
progressDlg = ProgressDialog.show(this,
@ -145,7 +144,7 @@ public class GeoIntentActivity extends ListActivity {
super.onListItemClick(l, v, position, id);
MapObject item = ((MapObjectAdapter) getListAdapter())
.getItem(position);
OsmandSettings.setMapLocationToShow(this, item.getLocation()
OsmandSettings.getOsmandSettings(this).setMapLocationToShow(item.getLocation()
.getLatitude(), item.getLocation().getLongitude(),
getString(R.string.address) + " : " + item.toString()); //$NON-NLS-1$
startActivity(new Intent(this, MapActivity.class));

View file

@ -45,6 +45,7 @@ public class SearchAddressActivity extends Activity {
private Button searchOnline;
private ProgressDialog progressDlg;
private OsmandSettings osmandSettings;
@Override
@ -60,6 +61,7 @@ public class SearchAddressActivity extends Activity {
countryButton = (Button) findViewById(R.id.CountryButton);
buildingButton = (Button) findViewById(R.id.BuildingButton);
searchOnline = (Button) findViewById(R.id.SearchOnline);
osmandSettings = OsmandSettings.getOsmandSettings(SearchAddressActivity.this);
attachListeners();
}
@ -96,10 +98,10 @@ public class SearchAddressActivity extends Activity {
@Override
public void onClick(View v) {
if(radioBuilding){
OsmandSettings.removeLastSearchedIntersectedStreet(SearchAddressActivity.this);
osmandSettings.removeLastSearchedIntersectedStreet();
startActivity(new Intent(SearchAddressActivity.this, SearchBuildingByNameActivity.class));
} else {
OsmandSettings.setLastSearchedIntersectedStreet(SearchAddressActivity.this, ""); //$NON-NLS-1$
osmandSettings.setLastSearchedIntersectedStreet(""); //$NON-NLS-1$
startActivity(new Intent(SearchAddressActivity.this, SearchStreet2ByNameActivity.class));
}
}
@ -175,7 +177,7 @@ public class SearchAddressActivity extends Activity {
LatLon l = null;
String historyName = null;
int zoom = 12;
boolean en = OsmandSettings.usingEnglishNames(OsmandSettings.getPrefs(this));
boolean en = osmandSettings.USE_ENGLISH_NAMES.get();
if (street2 != null && street != null) {
l = region.findStreetIntersection(street, street2);
if(l != null) {
@ -201,9 +203,9 @@ public class SearchAddressActivity extends Activity {
}
if (l != null) {
if(navigateTo){
OsmandSettings.setPointToNavigate(SearchAddressActivity.this, l.getLatitude(), l.getLongitude());
osmandSettings.setPointToNavigate(l.getLatitude(), l.getLongitude());
} else {
OsmandSettings.setMapLocationToShow(SearchAddressActivity.this, l.getLatitude(), l.getLongitude(), zoom, historyName);
osmandSettings.setMapLocationToShow(l.getLatitude(), l.getLongitude(), zoom, historyName);
}
startActivity(new Intent(SearchAddressActivity.this, MapActivity.class));
@ -280,28 +282,27 @@ public class SearchAddressActivity extends Activity {
}
public void loadData(){
SharedPreferences prefs = OsmandSettings.getPrefs(this);
if (region != null) {
if(region.useEnglishNames() != OsmandSettings.usingEnglishNames(prefs)){
region.setUseEnglishNames(OsmandSettings.usingEnglishNames(prefs));
if(region.useEnglishNames() != osmandSettings.USE_ENGLISH_NAMES.get()){
region.setUseEnglishNames(osmandSettings.USE_ENGLISH_NAMES.get());
}
String postcodeStr = OsmandSettings.getLastSearchedPostcode(prefs);
String postcodeStr = osmandSettings.getLastSearchedPostcode();
if(postcodeStr != null){
postcode = region.getPostcode(postcodeStr);
} else {
city = region.getCityById(OsmandSettings.getLastSearchedCity(prefs));
city = region.getCityById(osmandSettings.getLastSearchedCity());
}
if (postcode != null || city != null) {
MapObject o = postcode == null ? city : postcode;
street = region.getStreetByName(o, OsmandSettings.getLastSearchedStreet(prefs));
street = region.getStreetByName(o, osmandSettings.getLastSearchedStreet());
if (street != null) {
String str = OsmandSettings.getLastSearchedIntersectedStreet(prefs);
String str = osmandSettings.getLastSearchedIntersectedStreet();
radioBuilding = str == null;
if(str != null){
street2 = region.getStreetByName(o, str);
} else {
building = region.getBuildingByName(street, OsmandSettings.getLastSearchedBuilding(prefs));
building = region.getBuildingByName(street, osmandSettings.getLastSearchedBuilding());
}
}
}
@ -334,16 +335,15 @@ public class SearchAddressActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
SharedPreferences prefs = OsmandSettings.getPrefs(this);
region = null;
String lastSearchedRegion = OsmandSettings.getLastSearchedRegion(prefs);
String lastSearchedRegion = osmandSettings.getLastSearchedRegion();
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(lastSearchedRegion);
String progressMsg = null;
// try to determine whether progress dialog & new thread needed
if (region != null) {
Long cityId = OsmandSettings.getLastSearchedCity(prefs);
String postcode = OsmandSettings.getLastSearchedPostcode(prefs);
Long cityId = osmandSettings.getLastSearchedCity();
String postcode = osmandSettings.getLastSearchedPostcode();
if (!region.areCitiesPreloaded()) {
progressMsg = getString(R.string.loading_cities);
} else if (postcode != null && !region.arePostcodesPreloaded()) {
@ -352,7 +352,7 @@ public class SearchAddressActivity extends Activity {
progressMsg = getString(R.string.loading_streets_buildings);
} else if (postcode != null && region.getPostcode(postcode) != null && region.getPostcode(postcode).isEmptyWithStreets()) {
progressMsg = getString(R.string.loading_streets_buildings);
} else if (OsmandSettings.usingEnglishNames(prefs) != region.useEnglishNames()) {
} else if (osmandSettings.USE_ENGLISH_NAMES.get() != region.useEnglishNames()) {
progressMsg = getString(R.string.converting_names);
}
}

View file

@ -65,7 +65,7 @@ public class SearchAddressOnlineActivity extends ListActivity {
searchPlaces(((EditText) findViewById(R.id.SearchText)).getText().toString());
}
});
location = OsmandSettings.getLastKnownMapLocation(OsmandSettings.getPrefs(this));
location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
}
protected void searchPlaces(final String search) {
@ -158,7 +158,7 @@ public class SearchAddressOnlineActivity extends ListActivity {
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Place item = ((PlacesAdapter) getListAdapter()).getItem(position);
OsmandSettings.setMapLocationToShow(this, item.lat, item.lon, getString(R.string.address)+ " : " + item.displayName); //$NON-NLS-1$
OsmandSettings.getOsmandSettings(this).setMapLocationToShow(item.lat, item.lon, getString(R.string.address)+ " : " + item.displayName); //$NON-NLS-1$
startActivity(new Intent(this, MapActivity.class));
}

View file

@ -20,18 +20,19 @@ public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity<B
private City city;
private Street street;
private PostCode postcode;
private OsmandSettings settings;
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences prefs = OsmandSettings.getPrefs(this);
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(prefs));
settings = OsmandSettings.getOsmandSettings(this);
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
if(region != null){
postcode = region.getPostcode(OsmandSettings.getLastSearchedPostcode(prefs));
city = region.getCityById(OsmandSettings.getLastSearchedCity(prefs));
postcode = region.getPostcode(settings.getLastSearchedPostcode());
city = region.getCityById(settings.getLastSearchedCity());
if(postcode != null){
street = region.getStreetByName(postcode, OsmandSettings.getLastSearchedStreet(prefs));
street = region.getStreetByName(postcode, settings.getLastSearchedStreet());
} else if(city != null){
street = region.getStreetByName(city, OsmandSettings.getLastSearchedStreet(prefs));
street = region.getStreetByName(city, settings.getLastSearchedStreet());
}
}
super.onCreate(savedInstanceState);
@ -54,7 +55,7 @@ public class SearchBuildingByNameActivity extends SearchByNameAbstractActivity<B
@Override
public void itemSelected(Building obj) {
OsmandSettings.setLastSearchedBuilding(this, obj.getName(region.useEnglishNames()));
settings.setLastSearchedBuilding(obj.getName(region.useEnglishNames()));
finish();
}

View file

@ -19,11 +19,13 @@ import android.widget.TextView;
public class SearchCityByNameActivity extends SearchByNameAbstractActivity<MapObject> {
private RegionAddressRepository region;
private LatLon location;
private OsmandSettings settings;
@Override
protected void onCreate(Bundle savedInstanceState) {
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(OsmandSettings.getPrefs(this)));
location = OsmandSettings.getLastKnownMapLocation(OsmandSettings.getPrefs(this));
settings = ((OsmandApplication)getApplication()).getSettings();
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
location = settings.getLastKnownMapLocation();
super.onCreate(savedInstanceState);
((TextView)findViewById(R.id.Label)).setText(R.string.incremental_search_city);
}
@ -51,12 +53,12 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<MapOb
@Override
public void itemSelected(MapObject obj) {
if (obj instanceof City) {
OsmandSettings.setLastSearchedCity(this, obj.getId());
settings.setLastSearchedCity(obj.getId());
if (region.getCityById(obj.getId()) == null) {
region.addCityToPreloadedList((City) obj);
}
} else if(obj instanceof PostCode){
OsmandSettings.setLastSearchedPostcode(this, obj.getName());
settings.setLastSearchedPostcode(obj.getName());
}
finish();

View file

@ -36,7 +36,7 @@ public class SearchHistoryActivity extends ListActivity {
lv.setId(android.R.id.list);
setContentView(lv);
location = OsmandSettings.getLastKnownMapLocation(OsmandSettings.getPrefs(this));
location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
helper = SearchHistoryHelper.getInstance();
@ -79,9 +79,9 @@ public class SearchHistoryActivity extends ListActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
OsmandSettings.setMapLocationToShow(SearchHistoryActivity.this, entry.getLat(), entry.getLon());
OsmandSettings.getOsmandSettings(SearchHistoryActivity.this).setMapLocationToShow(entry.getLat(), entry.getLon());
} else if (which == 1) {
OsmandSettings.setPointToNavigate(SearchHistoryActivity.this, entry.getLat(), entry.getLon());
OsmandSettings.getOsmandSettings(SearchHistoryActivity.this).setPointToNavigate(entry.getLat(), entry.getLon());
}
Intent newIntent = new Intent(SearchHistoryActivity.this, MapActivity.class);
@ -103,7 +103,7 @@ public class SearchHistoryActivity extends ListActivity {
private void selectModel(HistoryEntry model) {
helper.selectEntry(model, this);
OsmandSettings.setMapLocationToShow(this, model.getLat(), model.getLon());
OsmandSettings.getOsmandSettings(SearchHistoryActivity.this).setMapLocationToShow(model.getLat(), model.getLon());
startActivity(new Intent(this, MapActivity.class));
}

View file

@ -96,7 +96,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
private String currentLocationProvider = null;
private boolean sensorRegistered = false;
private Handler uiHandler;
private SharedPreferences settings;
private OsmandSettings settings;
@ -116,7 +116,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
searchFilterLayout = findViewById(R.id.SearchFilterLayout);
showOnMap = (Button) findViewById(R.id.ShowOnMap);
settings = OsmandSettings.getPrefs(this);
settings = OsmandSettings.getOsmandSettings(this);
searchPOILevel.setOnClickListener(new OnClickListener() {
@Override
@ -185,10 +185,10 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
showOnMap.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
OsmandSettings.setPoiFilterForMap(SearchPOIActivity.this, filter.getFilterId());
OsmandSettings.setShowPoiOverMap(SearchPOIActivity.this, true);
settings.setPoiFilterForMap(filter.getFilterId());
settings.SHOW_POI_OVER_MAP.set(true);
if(/*searchNearBy && */location != null){
OsmandSettings.setMapLocationToShow(SearchPOIActivity.this, location.getLatitude(), location.getLongitude(), 15);
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), 15);
}
Intent newIntent = new Intent(SearchPOIActivity.this, MapActivity.class);
startActivity(newIntent);
@ -216,7 +216,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
@Override
public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
final Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(pos);
String format = OsmAndFormatter.getPoiSimpleFormat(amenity, SearchPOIActivity.this, OsmandSettings.usingEnglishNames(settings));
String format = OsmAndFormatter.getPoiSimpleFormat(amenity, SearchPOIActivity.this, settings.USE_ENGLISH_NAMES.get());
if (amenity.getOpeningHours() != null) {
format += " "+getString(R.string.opening_hours) + " : " + amenity.getOpeningHours(); //$NON-NLS-1$ //$NON-NLS-2$
}
@ -228,18 +228,18 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
@Override
public void onClick(DialogInterface dialog, int which) {
if(which == 0){
int z = OsmandSettings.getLastKnownMapZoom(settings);
String poiSimpleFormat = OsmAndFormatter.getPoiSimpleFormat(amenity, SearchPOIActivity.this, OsmandSettings.usingEnglishNames(settings));
OsmandSettings.setMapLocationToShow(SearchPOIActivity.this,
int z = settings.getLastKnownMapZoom();
String poiSimpleFormat = OsmAndFormatter.getPoiSimpleFormat(amenity, SearchPOIActivity.this, settings.usingEnglishNames());
settings.setMapLocationToShow(
amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(),
Math.max(16, z), getString(R.string.poi)+" : " + poiSimpleFormat); //$NON-NLS-1$
} else if(which == 1){
LatLon l = amenity.getLocation();
OsmandSettings.setPointToNavigate(SearchPOIActivity.this, l.getLatitude(), l.getLongitude());
settings.setPointToNavigate(l.getLatitude(), l.getLongitude());
}
if(filter != null){
OsmandSettings.setPoiFilterForMap(SearchPOIActivity.this, filter.getFilterId());
OsmandSettings.setShowPoiOverMap(SearchPOIActivity.this, true);
settings.setPoiFilterForMap(filter.getFilterId());
settings.SHOW_POI_OVER_MAP.set(true);
}
Intent newIntent = new Intent(SearchPOIActivity.this, MapActivity.class);
@ -480,13 +480,13 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
public void onListItemClick(ListView parent, View v, int position, long id) {
if(filter != null){
OsmandSettings.setPoiFilterForMap(SearchPOIActivity.this, filter.getFilterId());
OsmandSettings.setShowPoiOverMap(SearchPOIActivity.this, true);
settings.setPoiFilterForMap(filter.getFilterId());
settings.SHOW_POI_OVER_MAP.set(true);
}
int z = OsmandSettings.getLastKnownMapZoom(settings);
int z = settings.getLastKnownMapZoom();
Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(position);
String poiSimpleFormat = OsmAndFormatter.getPoiSimpleFormat(amenity, this, OsmandSettings.usingEnglishNames(settings));
OsmandSettings.setMapLocationToShow(this, amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(),
String poiSimpleFormat = OsmAndFormatter.getPoiSimpleFormat(amenity, this, settings.usingEnglishNames());
settings.setMapLocationToShow( amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(),
Math.max(16, z), getString(R.string.poi)+" : " + poiSimpleFormat); //$NON-NLS-1$
Intent newIntent = new Intent(SearchPOIActivity.this, MapActivity.class);
startActivity(newIntent);
@ -598,7 +598,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
LatLon l = amenity.getLocation();
Location.distanceBetween(l.getLatitude(), l.getLongitude(), location.getLatitude(), location.getLongitude(), mes);
}
String str = OsmAndFormatter.getPoiStringWithoutType(amenity, OsmandSettings.usingEnglishNames(settings));
String str = OsmAndFormatter.getPoiStringWithoutType(amenity, settings.usingEnglishNames());
label.setText(str);
int opened = -1;
if (amenity.getOpeningHours() != null) {
@ -664,7 +664,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
.toLowerCase();
List<Amenity> filter = new ArrayList<Amenity>();
for (Amenity item : originalAmenityList) {
String lower = OsmAndFormatter.getPoiStringWithoutType(item, OsmandSettings.usingEnglishNames(settings)).toLowerCase();
String lower = OsmAndFormatter.getPoiStringWithoutType(item, settings.usingEnglishNames()).toLowerCase();
if(lower.indexOf(lowerCase) != -1){
filter.add(item);
}

View file

@ -55,7 +55,7 @@ public class SearchPoiFilterActivity extends ListActivity {
latitude = extras.getDouble(SEARCH_LAT);
longitude = extras.getDouble(SEARCH_LON);
} else {
LatLon loc = OsmandSettings.getLastKnownMapLocation(OsmandSettings.getPrefs(this));
LatLon loc = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
latitude = loc.getLatitude();
longitude = loc.getLongitude();
}

View file

@ -35,7 +35,7 @@ public class SearchRegionByNameActivity extends SearchByNameAbstractActivity<Reg
@Override
public void itemSelected(RegionAddressRepository obj) {
OsmandSettings.setLastSearchedRegion(this, obj.getName());
OsmandSettings.getOsmandSettings(this).setLastSearchedRegion(obj.getName());
finish();
}

View file

@ -11,7 +11,6 @@ import net.osmand.plus.R;
import net.osmand.plus.RegionAddressRepository;
import net.osmand.plus.activities.OsmandApplication;
import android.app.ProgressDialog;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;
@ -22,21 +21,22 @@ public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<St
private Street street1;
private List<Street> initialList = new ArrayList<Street>();
private ProgressDialog progressDlg;
private OsmandSettings settings;
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences prefs = OsmandSettings.getPrefs(this);
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(prefs));
settings = OsmandSettings.getOsmandSettings(this);
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
if(region != null){
postcode = region.getPostcode(OsmandSettings.getLastSearchedPostcode(prefs));
city = region.getCityById(OsmandSettings.getLastSearchedCity(prefs));
postcode = region.getPostcode(settings.getLastSearchedPostcode());
city = region.getCityById(settings.getLastSearchedCity());
if(postcode != null){
street1 = region.getStreetByName(postcode, (OsmandSettings.getLastSearchedStreet(prefs)));
street1 = region.getStreetByName(postcode, (settings.getLastSearchedStreet()));
if(street1 != null){
city = street1.getCity();
}
} else if(city != null){
street1 = region.getStreetByName(city, (OsmandSettings.getLastSearchedStreet(prefs)));
street1 = region.getStreetByName(city, (settings.getLastSearchedStreet()));
}
if(city != null){
startLoadDataInThread(getString(R.string.loading_streets));
@ -109,7 +109,7 @@ public class SearchStreet2ByNameActivity extends SearchByNameAbstractActivity<St
@Override
public void itemSelected(Street obj) {
OsmandSettings.setLastSearchedIntersectedStreet(this, obj.getName(region.useEnglishNames()));
settings.setLastSearchedIntersectedStreet(obj.getName(region.useEnglishNames()));
finish();
}

View file

@ -18,14 +18,16 @@ public class SearchStreetByNameActivity extends SearchByNameAbstractActivity<Str
private RegionAddressRepository region;
private City city;
private PostCode postcode;
private OsmandSettings settings;
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences prefs = OsmandSettings.getPrefs(this);
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(OsmandSettings.getLastSearchedRegion(prefs));
settings = OsmandSettings.getOsmandSettings(this);
region = ((OsmandApplication)getApplication()).getResourceManager().getRegionRepository(settings.getLastSearchedRegion());
if(region != null){
postcode = region.getPostcode(OsmandSettings.getLastSearchedPostcode(prefs));
postcode = region.getPostcode(settings.getLastSearchedPostcode());
if (postcode == null) {
city = region.getCityById(OsmandSettings.getLastSearchedCity(prefs));
city = region.getCityById(settings.getLastSearchedCity());
}
}
super.onCreate(savedInstanceState);
@ -48,7 +50,7 @@ public class SearchStreetByNameActivity extends SearchByNameAbstractActivity<Str
@Override
public void itemSelected(Street obj) {
OsmandSettings.setLastSearchedStreet(this, obj.getName(region.useEnglishNames()));
settings.setLastSearchedStreet(obj.getName(region.useEnglishNames()));
finish();
}

View file

@ -66,7 +66,7 @@ public class SearchTransportActivity extends ListActivity {
private TransportStopAdapter stopsAdapter;
private TransportRouteAdapter intermediateListAdapater;
private SharedPreferences settings;
private OsmandSettings settings;
@ -74,12 +74,12 @@ public class SearchTransportActivity extends ListActivity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
settings = OsmandSettings.getPrefs(this);
settings = OsmandSettings.getOsmandSettings(this);
Bundle extras = getIntent().getExtras();
if(extras != null && extras.containsKey(LAT_KEY) && extras.containsKey(LON_KEY)){
lastKnownMapLocation = new LatLon(extras.getDouble(LAT_KEY), extras.getDouble(LON_KEY));
} else {
lastKnownMapLocation = OsmandSettings.getLastKnownMapLocation(settings);
lastKnownMapLocation = settings.getLastKnownMapLocation();
}
setContentView(R.layout.search_transport);
searchTransportLevel = (Button) findViewById(R.id.SearchTransportLevelButton);
@ -132,7 +132,7 @@ public class SearchTransportActivity extends ListActivity {
@Override
protected void onResume() {
super.onResume();
LatLon pointToNavigate = OsmandSettings.getPointToNavigate(OsmandSettings.getPrefs(this));
LatLon pointToNavigate = settings.getPointToNavigate();
if(!Algoritms.objectEquals(pointToNavigate, this.destinationLocation)){
destinationLocation = pointToNavigate;
selectedDestinationLocation = destinationLocation;
@ -265,7 +265,7 @@ public class SearchTransportActivity extends ListActivity {
} else {
n.append(". "); //$NON-NLS-1$
}
String name = st.getName(OsmandSettings.usingEnglishNames(settings));
String name = st.getName(settings.usingEnglishNames());
if(locationToGo != null){
n.append(name).append(" - ["); //$NON-NLS-1$
n.append(OsmAndFormatter.getFormattedDistance((int) MapUtils.getDistance(locationToGo, st.getLocation()), SearchTransportActivity.this)).append("]"); //$NON-NLS-1$
@ -323,7 +323,7 @@ public class SearchTransportActivity extends ListActivity {
public void showContextMenuOnRoute(final RouteInfoLocation route, final int routeInd) {
Builder b = new AlertDialog.Builder(this);
List<TransportStop> stops = route.getDirection() ? route.getRoute().getForwardStops() : route.getRoute().getBackwardStops();
boolean en = OsmandSettings.usingEnglishNames(settings);
boolean en = settings.usingEnglishNames();
String info = getInformation(route, stops, routeInd, false);
StringBuilder txt = new StringBuilder(300);
@ -459,7 +459,7 @@ public class SearchTransportActivity extends ListActivity {
} else {
labelW.append(getString(R.string.transport_search_none));
}
labelW.append("]\n").append(route.getName(OsmandSettings.usingEnglishNames(settings))); //$NON-NLS-1$
labelW.append("]\n").append(route.getName(settings.usingEnglishNames())); //$NON-NLS-1$
label.setText(labelW.toString());
// TODO icons
if (locationToGo != null && stop.getDistToLocation() < 400) {
@ -531,7 +531,7 @@ public class SearchTransportActivity extends ListActivity {
icon.setVisibility(View.VISIBLE);
StringBuilder labelW = new StringBuilder(150);
labelW.append(route.getType()).append(" ").append(route.getRef()); //$NON-NLS-1$
boolean en = OsmandSettings.usingEnglishNames(settings);
boolean en = settings.usingEnglishNames();
labelW.append(" : ").append(info.getStart().getName(en)).append(" - ").append(info.getStop().getName(en)); //$NON-NLS-1$ //$NON-NLS-2$
// additional information if route is calculated
if (currentRouteLocation == -1) {

View file

@ -73,12 +73,12 @@ public class MapRenderRepositories {
private boolean interrupted = false;
private RenderingContext currentRenderingContext;
private SearchRequest<BinaryMapDataObject> searchRequest;
private SharedPreferences prefs;
private OsmandSettings prefs;
public MapRenderRepositories(Context context){
this.context = context;
this.renderer = new OsmandRenderer(context);
handler = new Handler(Looper.getMainLooper());
prefs = OsmandSettings.getPrefs(context);
prefs = OsmandSettings.getOsmandSettings(context);
}
public Context getContext() {
@ -355,7 +355,7 @@ public class MapRenderRepositories {
Bitmap bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, Config.RGB_565);
boolean stepByStep = OsmandSettings.isUsingStepByStepRendering(prefs);
boolean stepByStep = prefs.USE_STEP_BY_STEP_RENDERING.get();
// 1. generate image step by step
if (stepByStep) {
this.bmp = bmp;
@ -365,7 +365,7 @@ public class MapRenderRepositories {
renderer.generateNewBitmap(currentRenderingContext, cObjects, bmp,
OsmandSettings.usingEnglishNames(prefs), renderingType, stepByStep ? notifyList : null);
prefs.USE_ENGLISH_NAMES.get(), renderingType, stepByStep ? notifyList : null);
if (checkWhetherInterrupted()) {
currentRenderingContext = null;
return;
@ -378,7 +378,7 @@ public class MapRenderRepositories {
this.bmp = bmp;
this.bmpLocation = tileRect;
}
if(OsmandSettings.isDebugRendering(context)){
if(prefs.DEBUG_RENDERING_INFO.get()){
final String msg = "Search done in "+ searchTime+" ms\nRendering done in "+ renderingTime+ " ms"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
handler.post(new Runnable(){
@Override

View file

@ -4,7 +4,6 @@ import net.osmand.Algoritms;
import net.osmand.OsmAndFormatter;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.RoutingHelper.RouteDirectionInfo;
@ -172,7 +171,7 @@ public class MapInfoLayer implements OsmandMapLayer {
pathTransform.postTranslate(boundsForMiniRoute.left, boundsForMiniRoute.top);
showArrivalTime = OsmandSettings.isShowingArrivalTime(view.getSettings());
showArrivalTime = view.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME.get();
}
private void scaleRect(RectF r){
@ -567,14 +566,14 @@ public class MapInfoLayer implements OsmandMapLayer {
}
if (boundsForLeftTime.contains(point.x, point.y) && routeLayer.getHelper().isFollowingMode()) {
showArrivalTime = !showArrivalTime;
OsmandSettings.setShowingArrivalTime(view.getContext(), showArrivalTime);
view.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME.set(showArrivalTime);
view.refreshMap();
return true;
}
}
if(cachedDistString != null && boundsForDist.contains(point.x, point.y)){
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
LatLon pointToNavigate = OsmandSettings.getPointToNavigate(view.getSettings());
LatLon pointToNavigate = view.getSettings().getPointToNavigate();
if(pointToNavigate != null){
int fZoom = view.getZoom() < 15 ? 15 : view.getZoom();
thread.startMoving(view.getLatitude(), view.getLongitude(), pointToNavigate.getLatitude(), pointToNavigate.getLongitude(),

View file

@ -328,7 +328,7 @@ public class OsmBugsLayer implements OsmandMapLayer, ContextMenuLayer.IContextMe
String text = ((EditText)openBug.findViewById(R.id.BugMessage)).getText().toString();
String author = ((EditText)openBug.findViewById(R.id.AuthorName)).getText().toString();
// do not set name as author it is ridiculous in that case
OsmandSettings.setUserNameForOsmBug(ctx, author);
view.getSettings().USER_OSM_BUG_NAME.set(author);
boolean bug = createNewBug(latitude, longitude, text, author);
if (bug) {
Toast.makeText(ctx, ctx.getResources().getString(R.string.osb_add_dialog_success), Toast.LENGTH_LONG).show();
@ -347,7 +347,7 @@ public class OsmBugsLayer implements OsmandMapLayer, ContextMenuLayer.IContextMe
public void openBug(final Context ctx, LayoutInflater layoutInflater, final OsmandMapTileView mapView, final double latitude, final double longitude){
openBugAlertDialog(ctx, layoutInflater, mapView, latitude, longitude, "", OsmandSettings.getUserNameForOsmBug(OsmandSettings.getPrefs(ctx)));
openBugAlertDialog(ctx, layoutInflater, mapView, latitude, longitude, "", mapView.getSettings().USER_OSM_BUG_NAME.get());
}
public void commentBug(final Context ctx, LayoutInflater layoutInflater, final OpenStreetBug bug){
@ -355,14 +355,14 @@ public class OsmBugsLayer implements OsmandMapLayer, ContextMenuLayer.IContextMe
builder.setTitle(R.string.osb_comment_dialog_title);
final View view = layoutInflater.inflate(R.layout.open_bug, null);
builder.setView(view);
((EditText)view.findViewById(R.id.AuthorName)).setText(OsmandSettings.getUserNameForOsmBug(OsmandSettings.getPrefs(ctx)));
((EditText)view.findViewById(R.id.AuthorName)).setText(OsmandSettings.getOsmandSettings(ctx).USER_OSM_BUG_NAME.get());
builder.setNegativeButton(R.string.default_buttons_cancel, null);
builder.setPositiveButton(R.string.osb_comment_dialog_add_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = ((EditText)view.findViewById(R.id.BugMessage)).getText().toString();
String author = ((EditText)view.findViewById(R.id.AuthorName)).getText().toString();
OsmandSettings.setUserNameForOsmBug(ctx, author);
OsmandSettings.getOsmandSettings(ctx).USER_OSM_BUG_NAME.set(author);
boolean added = addingComment(bug.getId(), text, author);
if (added) {
Toast.makeText(ctx, ctx.getResources().getString(R.string.osb_comment_dialog_success), Toast.LENGTH_LONG).show();

View file

@ -234,7 +234,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
// that trigger allows to scale tiles for certain devices
// for example for device with density > 1 draw tiles the same size as with density = 1
// It makes text bigger but blurry, the settings could be introduced for that
if (dm != null && dm.density > 1f && !OsmandSettings.isUsingHighResMaps(getSettings()) ) {
if (dm != null && dm.density > 1f && !getSettings().USE_HIGH_RES_MAPS.get() ) {
res *= dm.density;
}
return res;
@ -457,11 +457,11 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
protected Rect boundsRect = new Rect();
protected RectF bitmapToDraw = new RectF();
protected Rect bitmapToZoom = new Rect();
protected SharedPreferences settings = null;
protected OsmandSettings settings = null;
public SharedPreferences getSettings(){
public OsmandSettings getSettings(){
if(settings == null){
settings = OsmandSettings.getPrefs(getContext());
settings = OsmandSettings.getOsmandSettings(getContext());
}
return settings;
}
@ -471,7 +471,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
return;
}
boolean useInternet = OsmandSettings.isUsingInternetToDownloadTiles(getSettings());
boolean useInternet = getSettings().USE_INTERNET_TO_DOWNLOAD_TILES.get();
if (useInternet) {
MapTileDownloader.getInstance().refuseAllPreviousRequests();
}
@ -510,9 +510,10 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
latlonRect.right = (float) MapUtils.getLongitudeFromTile(nzoom, tilesRect.right);
if (map != null) {
ResourceManager mgr = getApplication().getResourceManager();
useInternet = useInternet && OsmandSettings.isInternetConnectionAvailable(getContext())
useInternet = useInternet && settings.isInternetConnectionAvailable()
&& map.couldBeDownloadedFromInternet();
int maxLevel = Math.min(OsmandSettings.getMaximumLevelToDownloadTile(getSettings()), map.getMaximumZoomSupported());
int maxLevel = Math.min(getSettings().MAX_LEVEL_TO_DOWNLOAD_TILE.get(), map.getMaximumZoomSupported());
for (int i = 0; i < width; i++) {

View file

@ -7,7 +7,6 @@ import net.osmand.LogUtil;
import net.osmand.OsmAndFormatter;
import net.osmand.data.Amenity;
import net.osmand.osm.LatLon;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.PoiFilter;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -83,7 +82,8 @@ public class POIMapLayer implements OsmandMapLayer, ContextMenuLayer.IContextMen
public boolean onTouchEvent(PointF point) {
Amenity n = getAmenityFromPoint(point);
if(n != null){
String format = OsmAndFormatter.getPoiSimpleFormat(n, view.getContext(), OsmandSettings.usingEnglishNames(view.getSettings()));
String format = OsmAndFormatter.getPoiSimpleFormat(n, view.getContext(),
view.getSettings().USE_ENGLISH_NAMES.get());
if(n.getOpeningHours() != null){
format += "\n" + view.getContext().getString(R.string.opening_hours) +" : "+ n.getOpeningHours(); //$NON-NLS-1$ //$NON-NLS-2$
}
@ -213,7 +213,7 @@ public class POIMapLayer implements OsmandMapLayer, ContextMenuLayer.IContextMen
@Override
public String getObjectDescription(Object o) {
if(o instanceof Amenity){
return OsmAndFormatter.getPoiSimpleFormat((Amenity) o, view.getContext(), OsmandSettings.usingEnglishNames(view.getSettings()));
return OsmAndFormatter.getPoiSimpleFormat((Amenity) o, view.getContext(), view.getSettings().USE_ENGLISH_NAMES.get());
}
return null;
}

View file

@ -144,7 +144,7 @@ public class TransportInfoLayer implements OsmandMapLayer {
int x = view.getRotatedMapXForPoint(location.getLatitude(), location.getLongitude());
int y = view.getRotatedMapYForPoint(location.getLatitude(), location.getLongitude());
if (Math.abs(x - ex) < getRadius() * 3 /2 && Math.abs(y - ey) < getRadius() * 3 /2) {
Toast.makeText(view.getContext(), st.getName(OsmandSettings.usingEnglishNames(view.getSettings())) + " : " + //$NON-NLS-1$
Toast.makeText(view.getContext(), st.getName(view.getSettings().USE_ENGLISH_NAMES.get()) + " : " + //$NON-NLS-1$
route.getType() + " " + route.getRef() //$NON-NLS-1$
, Toast.LENGTH_LONG).show();
return true;

View file

@ -81,7 +81,7 @@ public class TransportStopsLayer implements OsmandMapLayer, ContextMenuLayer.ICo
private String getStopDescription(TransportStop n, boolean useName) {
StringBuilder text = new StringBuilder(250);
text.append(view.getContext().getString(R.string.transport_Stop))
.append(" : ").append(n.getName(OsmandSettings.usingEnglishNames(view.getSettings()))); //$NON-NLS-1$
.append(" : ").append(n.getName(view.getSettings().USE_ENGLISH_NAMES.get())); //$NON-NLS-1$
text.append("\n").append(view.getContext().getString(R.string.transport_Routes)).append(" : "); //$NON-NLS-1$ //$NON-NLS-2$
List<TransportIndexRepository> reps = view.getApplication().getResourceManager().searchTransportRepositories(
n.getLocation().getLatitude(), n.getLocation().getLongitude());
@ -91,7 +91,7 @@ public class TransportStopsLayer implements OsmandMapLayer, ContextMenuLayer.ICo
List<String> l;
if (!useName) {
l = reps.get(0).getRouteDescriptionsForStop(n, "{1} {0}"); //$NON-NLS-1$
} else if (OsmandSettings.usingEnglishNames(view.getSettings())) {
} else if (view.getSettings().USE_ENGLISH_NAMES.get()) {
l = reps.get(0).getRouteDescriptionsForStop(n, "{1} {0} - {3}"); //$NON-NLS-1$
} else {
l = reps.get(0).getRouteDescriptionsForStop(n, "{1} {0} - {2}"); //$NON-NLS-1$

View file

@ -83,7 +83,7 @@ public class CommandPlayer {
prologSystem.clearTheory();
voiceDir = null;
if(voiceProvider != null){
File parent = OsmandSettings.extendOsmandPath(ctx, ResourceManager.VOICE_PATH);
File parent = OsmandSettings.getOsmandSettings(ctx).extendOsmandPath(ResourceManager.VOICE_PATH);
voiceDir = new File(parent, voiceProvider);
if(!voiceDir.exists()){
voiceDir = null;