Merge pull request #192 from alexey-pelykh/uiCodeReferencesRefactor

Ui code references refactor
This commit is contained in:
Pavol Zibrita 2012-03-09 01:38:28 -08:00
commit c2649a6158
55 changed files with 281 additions and 229 deletions

View file

@ -10,7 +10,7 @@
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="4"/>
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/OsmandTheme"
android:debuggable="true" android:name="net.osmand.plus.activities.OsmandApplication" android:description="@string/app_description"
android:debuggable="true" android:name="net.osmand.plus.OsmandApplication"
android:backupAgent="net.osmand.plus.OsmandBackupAgent" android:restoreAnyVersion="true">
<activity android:name="net.osmand.plus.activities.MainMenuActivity"
android:label="@string/app_name">

View file

@ -24,6 +24,7 @@ import net.osmand.osm.EntityInfo;
import net.osmand.osm.MapUtils;
import net.osmand.osm.Node;
import net.osmand.osm.io.OsmBaseStorage;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
@ -95,8 +96,8 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
HttpConnectionParams.setConnectionTimeout(params, 15000);
DefaultHttpClient httpclient = new DefaultHttpClient(params);
if (doAuthenticate) {
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(OsmandSettings.getOsmandSettings(ctx).USER_NAME.get() + ":" //$NON-NLS-1$
+ OsmandSettings.getOsmandSettings(ctx).USER_PASSWORD.get());
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(OsmandApplication.getSettings().USER_NAME.get() + ":" //$NON-NLS-1$
+ OsmandApplication.getSettings().USER_PASSWORD.get());
httpclient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), credentials);
}
HttpRequestBase method = null;
@ -175,7 +176,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
connection.setRequestMethod(requestMethod);
StringBuilder responseBody = new StringBuilder();
if (doAuthenticate) {
String token = OsmandSettings.getOsmandSettings(ctx).USER_NAME.get() + ":" + OsmandSettings.getOsmandSettings(ctx).USER_PASSWORD.get(); //$NON-NLS-1$
String token = OsmandApplication.getSettings().USER_NAME.get() + ":" + OsmandApplication.getSettings().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);
@ -333,7 +334,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
ser.startTag(null, stringAction.get(action));
ser.attribute(null, "version", "0.6"); //$NON-NLS-1$ //$NON-NLS-2$
ser.attribute(null, "generator", Version.getAppName(ctx)); //$NON-NLS-1$
writeNode(n, info, ser, changeSetId, OsmandSettings.getOsmandSettings(ctx).USER_NAME.get());
writeNode(n, info, ser, changeSetId, OsmandApplication.getSettings().USER_NAME.get());
ser.endTag(null, stringAction.get(action));
ser.endTag(null, "osmChange"); //$NON-NLS-1$
ser.endDocument();

View file

@ -5,6 +5,7 @@ import java.text.MessageFormat;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.data.City.CityType;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.OsmandSettings.MetricsConstants;
@ -17,7 +18,7 @@ public class OsmAndFormatter {
private final static float FOOTS_IN_ONE_METER = YARDS_IN_ONE_METER * 3f;
public static double calculateRoundedDist(double distInMeters, Context ctx) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(ctx);
OsmandSettings settings = OsmandApplication.getSettings();
MetricsConstants mc = settings.METRIC_SYSTEM.get();
double mainUnitInMeter = 1;
double metersInSecondUnit = METERS_IN_KILOMETER;
@ -50,7 +51,7 @@ public class OsmAndFormatter {
}
public static String getFormattedDistance(float meters, Context ctx) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(ctx);
OsmandSettings settings = OsmandApplication.getSettings();
MetricsConstants mc = settings.METRIC_SYSTEM.get();
int mainUnitStr;
float mainUnitInMeters;
@ -83,7 +84,7 @@ public class OsmAndFormatter {
}
public static String getFormattedAlt(double alt, Context ctx) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(ctx);
OsmandSettings settings = OsmandApplication.getSettings();
MetricsConstants mc = settings.METRIC_SYSTEM.get();
if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
return ((int) alt) + " " + ctx.getString(R.string.m);
@ -93,7 +94,7 @@ public class OsmAndFormatter {
}
public static String getFormattedSpeed(float metersperseconds, Context ctx) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(ctx);
OsmandSettings settings = OsmandApplication.getSettings();
MetricsConstants mc = settings.METRIC_SYSTEM.get();
float kmh = metersperseconds * 3.6f;
if(mc == MetricsConstants.KILOMETERS_AND_METERS){

View file

@ -74,8 +74,7 @@ public class FavouritesDbHelper extends SQLiteOpenHelper {
}
public String exportFavorites(String fileName) {
File f = new File(OsmandSettings.getOsmandSettings(context).extendOsmandPath(ResourceManager.APP_DIR),
fileName);
File f = new File(OsmandApplication.getSettings().extendOsmandPath(ResourceManager.APP_DIR), fileName);
GPXFile gpx = new GPXFile();
for (FavouritePoint p : getFavouritePoints()) {
if (p.isStored()) {

View file

@ -12,7 +12,6 @@ import net.osmand.ResultMatcher;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.osm.MapUtils;
import net.osmand.plus.activities.OsmandApplication;
import net.sf.junidecode.Junidecode;
import org.apache.commons.logging.Log;

View file

@ -3,7 +3,6 @@ package net.osmand.plus;
import net.osmand.Version;
import net.osmand.plus.activities.LiveMonitoringHelper;
import net.osmand.plus.activities.OsmandApplication;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.routing.RoutingHelper;
import android.app.AlarmManager;
@ -91,7 +90,7 @@ public class NavigationService extends Service implements LocationListener {
// initializing variables
setForeground(true);
handler = new Handler();
settings = OsmandSettings.getOsmandSettings(this);
settings = OsmandApplication.getSettings();
serviceOffInterval = settings.SERVICE_OFF_INTERVAL.get();
serviceOffProvider = settings.SERVICE_OFF_PROVIDER.get();
serviceError = settings.SERVICE_OFF_WAIT_INTERVAL.get();

View file

@ -1,6 +1,5 @@
package net.osmand.plus;
import net.osmand.plus.activities.OsmandApplication;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

View file

@ -1,4 +1,4 @@
package net.osmand.plus.activities;
package net.osmand.plus;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
@ -16,13 +16,10 @@ import net.osmand.GPXUtilities;
import net.osmand.LogUtil;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.PoiFiltersHelper;
import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
import net.osmand.plus.activities.DayNightHelper;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RoutingHelper;
@ -30,6 +27,7 @@ import net.osmand.plus.voice.CommandPlayer;
import net.osmand.plus.voice.CommandPlayerException;
import net.osmand.plus.voice.CommandPlayerFactory;
import net.osmand.render.RenderingRulesStorage;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@ -41,79 +39,97 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.os.Handler;
import android.text.format.DateFormat;
import android.util.Log;
import android.widget.Toast;
public class OsmandApplication extends Application {
public static final String EXCEPTION_PATH = ResourceManager.APP_DIR + "exception.log"; //$NON-NLS-1$
private static final org.apache.commons.logging.Log LOG = LogUtil.getLog(OsmandApplication.class);
ResourceManager manager = null;
ResourceManager manager = null;
PoiFiltersHelper poiFilters = null;
RoutingHelper routingHelper = null;
FavouritesDbHelper favorites = null;
CommandPlayer player = null;
OsmandSettings osmandSettings;
/**
* Static reference to instance of settings class.
* Transferred from OsmandSettings class to allow redefine actual instance behind it
*/
static OsmandSettings osmandSettings = null;
DayNightHelper daynightHelper;
NavigationService navigationService;
RendererRegistry rendererRegistry;
// start variables
private ProgressDialogImplementation startDialog;
private List<String> startingWarnings;
private Handler uiHandler;
private GPXFile gpxFileToDisplay;
private boolean applicationInitializing = false;
private Locale prefferedLocale = null;
@Override
public void onCreate(){
super.onCreate();
long timeToStart = System.currentTimeMillis();
osmandSettings = OsmandSettings.getOsmandSettings(this);
routingHelper = new RoutingHelper(osmandSettings, OsmandApplication.this, player);
manager = new ResourceManager(this);
daynightHelper = new DayNightHelper(this);
uiHandler = new Handler();
rendererRegistry = new RendererRegistry();
checkPrefferedLocale();
startApplication();
if(LOG.isDebugEnabled()){
LOG.debug("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms");
}
@Override
public void onCreate() {
super.onCreate();
long timeToStart = System.currentTimeMillis();
osmandSettings = createOsmandSettingsInstance();
routingHelper = new RoutingHelper(osmandSettings, this, player);
manager = new ResourceManager(this);
daynightHelper = new DayNightHelper(this);
uiHandler = new Handler();
rendererRegistry = new RendererRegistry();
checkPrefferedLocale();
startApplication();
if (LOG.isDebugEnabled()) {
LOG.debug("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms");
}
}
@Override
public void onTerminate() {
super.onTerminate();
if (routingHelper != null) {
routingHelper.getVoiceRouter().onApplicationTerminate(getApplicationContext());
}
}
public RendererRegistry getRendererRegistry() {
@Override
public void onTerminate() {
super.onTerminate();
if (routingHelper != null) {
routingHelper.getVoiceRouter().onApplicationTerminate(getApplicationContext());
}
}
public RendererRegistry getRendererRegistry() {
return rendererRegistry;
}
public OsmandSettings getSettings() {
/**
* Creates instance of OsmandSettings
* @return Reference to instance of OsmandSettings
*/
protected OsmandSettings createOsmandSettingsInstance() {
return new OsmandSettings(this);
}
/**
* Application settings
* @return Reference to instance of OsmandSettings
*/
public static OsmandSettings getSettings() {
if(osmandSettings == null) {
LOG.error("Trying to access settings before they were created");
}
return osmandSettings;
}
public PoiFiltersHelper getPoiFilters() {
if(poiFilters == null){
poiFilters = new PoiFiltersHelper(this);
}
if (poiFilters == null) {
poiFilters = new PoiFiltersHelper(this);
}
return poiFilters;
}
public void setGpxFileToDisplay(GPXFile gpxFileToDisplay, boolean showCurrentGpxFile) {
this.gpxFileToDisplay = gpxFileToDisplay;
osmandSettings.SHOW_CURRENT_GPX_TRACK.set(showCurrentGpxFile);
if(gpxFileToDisplay == null){
if (gpxFileToDisplay == null) {
getFavorites().setFavoritePointsFromGPXFile(null);
} else {
List<FavouritePoint> pts = new ArrayList<FavouritePoint>();
@ -121,7 +137,7 @@ public class OsmandApplication extends Application {
FavouritePoint pt = new FavouritePoint();
pt.setLatitude(p.lat);
pt.setLongitude(p.lon);
if(p.name == null){
if (p.name == null) {
p.name = "";
}
pt.setName(p.name);
@ -130,32 +146,32 @@ public class OsmandApplication extends Application {
getFavorites().setFavoritePointsFromGPXFile(pts);
}
}
public GPXFile getGpxFileToDisplay() {
return gpxFileToDisplay;
}
public FavouritesDbHelper getFavorites() {
if(favorites == null) {
favorites = new FavouritesDbHelper(this);
}
public FavouritesDbHelper getFavorites() {
if (favorites == null) {
favorites = new FavouritesDbHelper(this);
}
return favorites;
}
public ResourceManager getResourceManager() {
public ResourceManager getResourceManager() {
return manager;
}
public DayNightHelper getDaynightHelper() {
public DayNightHelper getDaynightHelper() {
return daynightHelper;
}
@Override
public void onLowMemory() {
super.onLowMemory();
manager.onLowMemory();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
@ -165,32 +181,34 @@ public class OsmandApplication extends Application {
getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
}
}
public void checkPrefferedLocale() {
Configuration config = getBaseContext().getResources().getConfiguration();
String lang = osmandSettings.PREFERRED_LOCALE.get();
Configuration config = getBaseContext().getResources().getConfiguration();
String lang = osmandSettings.PREFERRED_LOCALE.get();
if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) {
prefferedLocale = new Locale(lang);
Locale.setDefault(prefferedLocale);
config.locale = prefferedLocale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
}
}
public static final int PROGRESS_DIALOG = 5;
public static final int PROGRESS_DIALOG = 5;
/**
* @param activity that supports onCreateDialog({@link #PROGRESS_DIALOG}) and returns @param progressdialog
* @param progressDialog - it should be exactly the same as onCreateDialog
* @param activity
* that supports onCreateDialog({@link #PROGRESS_DIALOG}) and
* returns @param progressdialog
* @param progressDialog
* - it should be exactly the same as onCreateDialog
* @return
*/
public void checkApplicationIsBeingInitialized(Activity activity, ProgressDialog progressDialog){
public void checkApplicationIsBeingInitialized(Activity activity, ProgressDialog progressDialog) {
// start application if it was previously closed
startApplication();
synchronized (OsmandApplication.this) {
if(startDialog != null){
if (startDialog != null) {
progressDialog.setTitle(getString(R.string.loading_data));
progressDialog.setMessage(getString(R.string.reading_indexes));
activity.showDialog(PROGRESS_DIALOG);
@ -200,55 +218,59 @@ public class OsmandApplication extends Application {
}
}
}
public boolean isApplicationInitializing(){
public boolean isApplicationInitializing() {
return startDialog != null;
}
public RoutingHelper getRoutingHelper() {
return routingHelper;
}
public CommandPlayer getPlayer() {
return player;
}
public void showDialogInitializingCommandPlayer(final Activity uiContext){
public void showDialogInitializingCommandPlayer(final Activity uiContext) {
showDialogInitializingCommandPlayer(uiContext, true);
}
public void showDialogInitializingCommandPlayer(final Activity uiContext, boolean warningNoneProvider){
public void showDialogInitializingCommandPlayer(final Activity uiContext, boolean warningNoneProvider) {
showDialogInitializingCommandPlayer(uiContext, warningNoneProvider, null);
}
public void showDialogInitializingCommandPlayer(final Activity uiContext, boolean warningNoneProvider, Runnable run){
public void showDialogInitializingCommandPlayer(final Activity uiContext, boolean warningNoneProvider, Runnable run) {
String voiceProvider = osmandSettings.VOICE_PROVIDER.get();
if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
if (warningNoneProvider && voiceProvider == null) {
Builder builder = new AlertDialog.Builder(uiContext);
builder.setCancelable(true);
builder.setNegativeButton(R.string.default_buttons_cancel, null);
builder.setPositiveButton(R.string.default_buttons_ok, new DialogInterface.OnClickListener() {
builder.setPositiveButton(R.string.default_buttons_ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(uiContext, SettingsActivity.class);
intent.putExtra(SettingsActivity.INTENT_KEY_SETTINGS_SCREEN, SettingsActivity.SCREEN_NAVIGATION_SETTINGS);
uiContext.startActivity(intent);
}
});
@Override
public void onClick(DialogInterface dialog,
int which) {
Intent intent = new Intent(uiContext,
SettingsActivity.class);
intent.putExtra(
SettingsActivity.INTENT_KEY_SETTINGS_SCREEN,
SettingsActivity.SCREEN_NAVIGATION_SETTINGS);
uiContext.startActivity(intent);
}
});
builder.setTitle(R.string.voice_is_not_available_title);
builder.setMessage(R.string.voice_is_not_available_msg);
builder.show();
}
} else {
if(player == null
|| !Algoritms.objectEquals(voiceProvider, player.getCurrentVoice())){
if (player == null || !Algoritms.objectEquals(voiceProvider, player.getCurrentVoice())) {
initVoiceDataInDifferentThread(uiContext, voiceProvider, run);
}
}
}
private void initVoiceDataInDifferentThread(final Activity uiContext, final String voiceProvider, final Runnable run) {
@ -265,7 +287,7 @@ public class OsmandApplication extends Application {
player = CommandPlayerFactory.createCommandPlayer(voiceProvider, OsmandApplication.this, uiContext);
routingHelper.getVoiceRouter().setPlayer(player);
dlg.dismiss();
if(run != null && uiContext != null){
if (run != null && uiContext != null) {
uiContext.runOnUiThread(run);
}
} catch (CommandPlayerException e) {
@ -275,22 +297,21 @@ public class OsmandApplication extends Application {
}
}).start();
}
public NavigationService getNavigationService() {
return navigationService;
}
public void setNavigationService(NavigationService navigationService) {
this.navigationService = navigationService;
}
public synchronized void closeApplication(){
if(applicationInitializing){
public synchronized void closeApplication() {
if (applicationInitializing) {
manager.close();
}
applicationInitializing = false;
applicationInitializing = false;
}
public synchronized void startApplication() {
if (applicationInitializing) {
@ -310,7 +331,7 @@ public class OsmandApplication extends Application {
Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
}
public String exportFavorites(File f) {
GPXFile gpx = new GPXFile();
for (FavouritePoint p : getFavorites().getFavouritePoints()) {
@ -324,7 +345,7 @@ public class OsmandApplication extends Application {
}
return GPXUtilities.writeGpxFile(f, gpx, this);
}
private void startApplicationBackground() {
List<String> warnings = null;
try {
@ -345,9 +366,9 @@ public class OsmandApplication extends Application {
warnings.addAll(helper.saveDataToGpx());
}
helper.close();
// restore backuped favorites to normal file
final File appDir = OsmandSettings.getOsmandSettings(this).extendOsmandPath(ResourceManager.APP_DIR);
final File appDir = OsmandApplication.getSettings().extendOsmandPath(ResourceManager.APP_DIR);
File save = new File(appDir, FavouritesDbHelper.FILE_TO_SAVE);
File bak = new File(appDir, FavouritesDbHelper.FILE_TO_BACKUP);
if (bak.exists() && (!save.exists() || bak.lastModified() > save.lastModified())) {
@ -382,13 +403,13 @@ public class OsmandApplication extends Application {
}
}
}
protected void showWarnings(List<String> warnings, final Context uiContext) {
if (warnings != null && !warnings.isEmpty()) {
final StringBuilder b = new StringBuilder();
boolean f = true;
for (String w : warnings) {
if(f){
if (f) {
f = false;
} else {
b.append('\n');
@ -407,7 +428,6 @@ public class OsmandApplication extends Application {
}
});
}
private class DefaultExceptionHandler implements UncaughtExceptionHandler {
@ -425,7 +445,8 @@ public class OsmandApplication extends Application {
PrintStream printStream = new PrintStream(out);
ex.printStackTrace(printStream);
StringBuilder msg = new StringBuilder();
msg.append("Exception occured in thread " + thread.toString() + " : "). //$NON-NLS-1$ //$NON-NLS-2$
msg.append(
"Exception occured in thread " + thread.toString() + " : "). //$NON-NLS-1$ //$NON-NLS-2$
append(DateFormat.format("MMMM dd, yyyy h:mm:ss", System.currentTimeMillis())).append("\n"). //$NON-NLS-1$//$NON-NLS-2$
append(new String(out.toByteArray()));
@ -437,11 +458,10 @@ public class OsmandApplication extends Application {
defaultHandler.uncaughtException(thread, ex);
} catch (Exception e) {
// swallow all exceptions
Log.e(LogUtil.TAG, "Exception while handle other exception", e); //$NON-NLS-1$
android.util.Log.e(LogUtil.TAG, "Exception while handle other exception", e); //$NON-NLS-1$
}
}
}
}

View file

@ -14,11 +14,11 @@ import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.osm.LatLon;
import net.osmand.plus.activities.ApplicationMode;
import net.osmand.plus.activities.OsmandApplication;
import net.osmand.plus.activities.search.SearchHistoryHelper;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.render.RenderingRulesStorage;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
@ -33,22 +33,22 @@ import android.os.Environment;
import android.widget.Toast;
public class OsmandSettings {
// GLOBAL instance - make instance global for application
// if some problems appear it can be unique for Application (ApplicationContext)
private static OsmandSettings INSTANCE;
public static OsmandSettings getOsmandSettings(Context ctx) {
if (INSTANCE == null) {
synchronized (ctx.getApplicationContext()) {
if (INSTANCE == null) {
INSTANCE = new OsmandSettings((OsmandApplication) ctx.getApplicationContext());
}
}
}
return INSTANCE;
/**
* Exposes method to override default value of the preference
* @author Alexey Pelykh
*
* @param <T> Type of preference value
*/
protected interface OsmandPreferenceWithOverridableDefault<T> {
/**
* Overrides default value with given
* @param newDefaultValue New default value
*/
void overrideDefaultValue(T newDefaultValue);
}
public interface OsmandPreference<T> {
public interface OsmandPreference<T> extends OsmandPreferenceWithOverridableDefault<T> {
T get();
boolean set(T obj);
@ -72,8 +72,10 @@ public class OsmandSettings {
private List<TileSourceTemplate> internetAvailableSourceTemplates = null;
// TODO make all layers profile preferenced????
private OsmandSettings(OsmandApplication ctx){
this.ctx = ctx;
protected OsmandSettings(OsmandApplication application) {
ctx = application;
//TODO: Is it really intended to keep settings WORLD_READABLE?
globalPreferences = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
// start from default settings
currentMode = ApplicationMode.DEFAULT;
@ -109,6 +111,11 @@ public class OsmandSettings {
public ApplicationMode get() {
return currentMode;
}
@Override
public void overrideDefaultValue(ApplicationMode newDefaultValue) {
throw new UnsupportedOperationException();
}
@Override
public boolean set(ApplicationMode val) {
@ -234,6 +241,11 @@ public class OsmandSettings {
}
}
@Override
public void overrideDefaultValue(T newDefaultValue) {
this.defaultValue = newDefaultValue;
}
protected abstract T getValue(SharedPreferences prefs, T defaultValue);
protected abstract boolean setValue(SharedPreferences prefs, T val);
@ -285,7 +297,6 @@ public class OsmandSettings {
protected boolean setValue(SharedPreferences prefs, Boolean val) {
return prefs.edit().putBoolean(getId(), val).commit();
}
}
private class IntPreference extends CommonPreference<Integer> {

View file

@ -16,7 +16,6 @@ import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.data.IndexConstants;
import net.osmand.osm.MapUtils;
import net.osmand.plus.activities.OsmandApplication;
public class PoiFilter {
@ -148,7 +147,7 @@ public class PoiFilter {
public ResultMatcher<Amenity> getResultMatcher(final ResultMatcher<Amenity> matcher){
if(nameFilter != null) {
final boolean en = OsmandSettings.getOsmandSettings(application).USE_ENGLISH_NAMES.get();
final boolean en = OsmandApplication.getSettings().USE_ENGLISH_NAMES.get();
return new ResultMatcher<Amenity>() {
@Override
public boolean publish(Amenity object) {

View file

@ -9,7 +9,6 @@ import java.util.List;
import java.util.Map;
import net.osmand.data.AmenityType;
import net.osmand.plus.activities.OsmandApplication;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

View file

@ -36,7 +36,6 @@ import net.osmand.plus.AsyncLoadingThread.AmenityLoadRequest;
import net.osmand.plus.AsyncLoadingThread.MapLoadRequest;
import net.osmand.plus.AsyncLoadingThread.TileLoadDownloadRequest;
import net.osmand.plus.AsyncLoadingThread.TransportLoadRequest;
import net.osmand.plus.activities.OsmandApplication;
import net.osmand.plus.render.MapRenderRepositories;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.render.RenderingRulesStorage;

View file

@ -9,7 +9,6 @@ import net.osmand.ResultMatcher;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.osm.MapUtils;
import net.osmand.plus.activities.OsmandApplication;
public class SearchByNameFilter extends PoiFilter {

View file

@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -63,7 +64,7 @@ public class ContributionVersionActivity extends OsmandListActivity {
setContentView(R.layout.download_builds);
titleBar.afterSetContentView();
String installDate = OsmandSettings.getOsmandSettings(this).CONTRIBUTION_INSTALL_APP_DATE.get();
String installDate = OsmandApplication.getSettings().CONTRIBUTION_INSTALL_APP_DATE.get();
if(installDate != null){
try {
currentInstalledDate = dateFormat.parse(installDate);
@ -136,7 +137,7 @@ public class ContributionVersionActivity extends OsmandListActivity {
MessageFormat.format(getString(R.string.build_installed), currentSelectedBuild.tag, dateFormat
.format(currentSelectedBuild.date)), Toast.LENGTH_LONG).show();
}
OsmandSettings.getOsmandSettings(this).CONTRIBUTION_INSTALL_APP_DATE.set(dateFormat.format(d));
OsmandApplication.getSettings().CONTRIBUTION_INSTALL_APP_DATE.set(dateFormat.format(d));
}
protected void executeThreadOperation(int operationId) throws Exception {

View file

@ -7,6 +7,7 @@ import java.util.TimeZone;
import net.osmand.LogUtil;
import net.osmand.SunriseSunset;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings.DayNightMode;
import org.apache.commons.logging.Log;

View file

@ -33,6 +33,7 @@ import net.osmand.plus.DownloadOsmandIndexesHelper.IndexItem;
import net.osmand.plus.IndexFileList;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -184,7 +185,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
} else {
downloadIndexList();
}
if(getPackageName().equals(FREE_VERSION_NAME) && OsmandSettings.getOsmandSettings(this).checkFreeDownloadsNumberZero()){
if(getPackageName().equals(FREE_VERSION_NAME) && OsmandApplication.getSettings().checkFreeDownloadsNumberZero()){
Builder msg = new AlertDialog.Builder(this);
msg.setTitle(R.string.free_version_title);
msg.setMessage(getString(R.string.free_version_message, MAXIMUM_AVAILABLE_FREE_DOWNLOADS+"", ""));
@ -459,7 +460,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
private Collection<String> listAlreadyDownloadedWithAlternatives() {
Set<String> files = new TreeSet<String>();
File externalStorageDirectory = OsmandSettings.getOsmandSettings(getApplicationContext()).getExternalStorageDirectory();
File externalStorageDirectory = OsmandApplication.getSettings().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.BACKUP_PATH),BINARY_MAP_INDEX_EXT,BINARY_MAP_INDEX_EXT_ZIP,BINARY_MAP_VERSION));
@ -498,7 +499,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
String toCheckPostfix = null;
boolean unzipDir = false;
File externalStorageDirectory = OsmandSettings.getOsmandSettings(getApplicationContext()).getExternalStorageDirectory();
File externalStorageDirectory = OsmandApplication.getSettings().getExternalStorageDirectory();
if(fileName.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)){
parent = new File(externalStorageDirectory, ResourceManager.APP_DIR);
toSavePostfix = BINARY_MAP_INDEX_EXT;
@ -553,7 +554,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
protected void downloadFilesCheckFreeVersion() {
if (getPackageName().equals(FREE_VERSION_NAME)) {
int total = OsmandSettings.getOsmandSettings(this).NUMBER_OF_FREE_DOWNLOADS.get() + entriesToDownload.size();
int total = OsmandApplication.getSettings().NUMBER_OF_FREE_DOWNLOADS.get() + entriesToDownload.size();
boolean wiki = false;
for (DownloadEntry es : entriesToDownload.values()) {
if (es.baseName.contains("_wiki")) {
@ -581,7 +582,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
sz += es.sizeMB;
}
// get availabile space
File dir = OsmandSettings.getOsmandSettings(this).extendOsmandPath("");
File dir = OsmandApplication.getSettings().extendOsmandPath("");
double asz = -1;
if(dir.canRead()){
StatFs fs = new StatFs(dir.getAbsolutePath());
@ -643,7 +644,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
public DownloadIndexesAsyncTask(ProgressDialogImplementation progressDialogImplementation) {
this.progress = progressDialogImplementation;
downloads = OsmandSettings.getOsmandSettings(DownloadIndexActivity.this).NUMBER_OF_FREE_DOWNLOADS;
downloads = OsmandApplication.getSettings().NUMBER_OF_FREE_DOWNLOADS;
}
@Override
@ -718,10 +719,10 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
if (vectorMapsToReindex) {
ResourceManager manager = ((OsmandApplication) getApplication()).getResourceManager();
List<String> warnings = manager.indexingMaps(progress);
if (warnings.isEmpty() && !OsmandSettings.getOsmandSettings(getApplicationContext()).MAP_VECTOR_DATA.get()) {
if (warnings.isEmpty() && !OsmandApplication.getSettings().MAP_VECTOR_DATA.get()) {
warnings.add(getString(R.string.binary_map_download_success));
// Is it proper way to switch every tome to vector data?
OsmandSettings.getOsmandSettings(getApplicationContext()).MAP_VECTOR_DATA.set(true);
OsmandApplication.getSettings().MAP_VECTOR_DATA.set(true);
}
if (!warnings.isEmpty()) {
return warnings.get(0);

View file

@ -10,6 +10,7 @@ import net.osmand.data.MapTileDownloader.DownloadRequest;
import net.osmand.data.MapTileDownloader.IMapDownloaderCallback;
import net.osmand.map.ITileSource;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
import net.osmand.plus.views.BaseMapLayer;

View file

@ -11,6 +11,7 @@ import net.osmand.OsmAndFormatter;
import net.osmand.data.AmenityType;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.PoiFilter;
import net.osmand.plus.PoiFiltersHelper;
@ -62,7 +63,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
public void onClick(View v) {
Bundle extras = getIntent().getExtras();
boolean searchNearBy = true;
LatLon lastKnownMapLocation = OsmandSettings.getOsmandSettings(EditPOIFilterActivity.this).getLastKnownMapLocation();
LatLon lastKnownMapLocation = OsmandApplication.getSettings().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

@ -21,6 +21,7 @@ import net.osmand.osm.OpeningHoursParser;
import net.osmand.osm.OpeningHoursParser.BasicDayOpeningHourRule;
import net.osmand.osm.OpeningHoursParser.OpeningHoursRule;
import net.osmand.plus.AmenityIndexRepositoryOdb;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import android.app.AlertDialog;
@ -72,7 +73,7 @@ public class EditingPOIActivity implements DialogProvider {
public EditingPOIActivity(MapActivity uiContext){
this.ctx = uiContext;
OsmandSettings settings = OsmandSettings.getOsmandSettings(ctx);
OsmandSettings settings = OsmandApplication.getSettings();
if(settings.OFFLINE_POI_EDITION.get() || !settings.isInternetConnectionAvailable(true)){
this.openstreetmapUtil = new OpenstreetmapLocalUtil(ctx);
} else {
@ -116,7 +117,7 @@ public class EditingPOIActivity implements DialogProvider {
private void prepareDeleteDialog(Dialog dlg, Bundle args) {
Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
dlg.setTitle(MessageFormat.format(this.ctx.getMapView().getResources().getString(R.string.poi_remove_confirm_template),
OsmAndFormatter.getPoiStringWithoutType(a, OsmandSettings.getOsmandSettings(ctx).usingEnglishNames())));
OsmAndFormatter.getPoiStringWithoutType(a, OsmandApplication.getSettings().usingEnglishNames())));
}
private Dialog createDeleteDialog(final Bundle args) {

View file

@ -22,6 +22,7 @@ import net.osmand.OsmAndFormatter;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -200,7 +201,7 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
@Override
protected void onResume() {
super.onResume();
final LatLon mapLocation = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
final LatLon mapLocation = OsmandApplication.getSettings().getLastKnownMapLocation();
favouritesAdapter.synchronizeGroups();
// Sort Favs by distance on Search tab, but sort alphabetically here
@ -227,7 +228,7 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
}
} else {
FavouritePoint point = (FavouritePoint) favouritesAdapter.getChild(groupPosition, childPosition);
OsmandSettings settings = OsmandSettings.getOsmandSettings(this);
OsmandSettings settings = OsmandApplication.getSettings();
settings.SHOW_FAVORITES.set(true);
settings.setMapLocationToShow(point.getLatitude(), point.getLongitude(),
Math.max(12, settings.getLastKnownMapZoom()), null, getString(R.string.favorite)+" : " + point.getName(), point);
@ -243,13 +244,13 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
int group = ExpandableListView.getPackedPositionGroup(((ExpandableListContextMenuInfo)menuInfo).packedPosition);
final FavouritePoint point = (FavouritePoint) favouritesAdapter.getChild(group, child);
if (aItem.getItemId() == SHOW_ON_MAP) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(this);
OsmandSettings settings = OsmandApplication.getSettings();
settings.SHOW_FAVORITES.set(true);
settings.setMapLocationToShow(point.getLatitude(), point.getLongitude(),
Math.max(12, settings.getLastKnownMapZoom()), null, getString(R.string.favorite)+" : " + point.getName(), point);
MapActivity.launchMapActivityMoveToTop(this);
} else if (aItem.getItemId() == NAVIGATE_TO) {
OsmandSettings.getOsmandSettings(this).setPointToNavigate(point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName());
OsmandApplication.getSettings().setPointToNavigate(point.getLatitude(), point.getLongitude(), getString(R.string.favorite)+" : " + point.getName());
MapActivity.launchMapActivityMoveToTop(this);
} else if (aItem.getItemId() == EDIT_ITEM) {
Builder builder = new AlertDialog.Builder(this);
@ -338,7 +339,7 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
final File appDir = OsmandSettings.getOsmandSettings(this).extendOsmandPath(ResourceManager.APP_DIR);
final File appDir = OsmandApplication.getSettings().extendOsmandPath(ResourceManager.APP_DIR);
final File tosave = new File(appDir, FavouritesDbHelper.FILE_TO_SAVE);
if(item.getItemId() == EXPORT_ID){
if(favouritesAdapter.isEmpty()){
@ -614,7 +615,7 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
} else {
icon.setImageResource(R.drawable.opened_poi);
}
LatLon lastKnownMapLocation = OsmandSettings.getOsmandSettings(FavouritesActivity.this).getLastKnownMapLocation();
LatLon lastKnownMapLocation = OsmandApplication.getSettings().getLastKnownMapLocation();
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(),
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(dist, FavouritesActivity.this));

View file

@ -12,6 +12,7 @@ import net.osmand.FavouritePoint;
import net.osmand.OsmAndFormatter;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.search.SearchActivity;
@ -78,7 +79,7 @@ public class FavouritesListActivity extends TrackedListActivity implements Searc
location = ((SearchActivity) getParent()).getSearchPoint();
}
if (location == null) {
location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
location = OsmandApplication.getSettings().getLastKnownMapLocation();
}
}
locationUpdate(location);
@ -128,11 +129,11 @@ public class FavouritesListActivity extends TrackedListActivity implements Searc
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(FavouritesListActivity.this);
OsmandSettings settings = OsmandApplication.getSettings();
settings.setMapLocationToShow(entry.getLatitude(), entry.getLongitude(), settings.getLastKnownMapZoom(),
null, getString(R.string.favorite)+" : " + entry.getName(), entry); //$NON-NLS-1$
} else if (which == 1) {
OsmandSettings.getOsmandSettings(FavouritesListActivity.this).setPointToNavigate(entry.getLatitude(),
OsmandApplication.getSettings().setPointToNavigate(entry.getLatitude(),
entry.getLongitude(), getString(R.string.favorite) + " : " + entry.getName());
}
MapActivity.launchMapActivityMoveToTop(FavouritesListActivity.this);
@ -147,7 +148,7 @@ public class FavouritesListActivity extends TrackedListActivity implements Searc
protected void onListItemClick(ListView l, View v, int position, long id) {
if (!isSelectFavoriteMode()) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(this);
OsmandSettings settings = OsmandApplication.getSettings();
FavouritePoint point = favouritesAdapter.getItem(position);
settings.SHOW_FAVORITES.set(true);
settings.setMapLocationToShow(point.getLatitude(), point.getLongitude(), settings.getLastKnownMapZoom(), null,

View file

@ -6,6 +6,7 @@ import java.io.InputStreamReader;
import java.text.MessageFormat;
import net.osmand.LogUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
@ -30,7 +31,7 @@ public class LiveMonitoringHelper {
public LiveMonitoringHelper(Context ctx){
this.ctx = ctx;
settings = OsmandSettings.getOsmandSettings(ctx);
settings = OsmandApplication.getSettings();
}
public boolean isLiveMonitoringEnabled(){

View file

@ -30,6 +30,7 @@ import net.osmand.data.IndexConstants;
import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -201,7 +202,7 @@ public class LocalIndexHelper {
}
public List<LocalIndexInfo> getLocalIndexData(LocalIndexType type, LoadLocalIndexTask loadTask){
OsmandSettings settings = OsmandSettings.getOsmandSettings(app.getApplicationContext());
OsmandSettings settings = OsmandApplication.getSettings();
Map<String, String> loadedMaps = app.getResourceManager().getIndexFileNames();
List<LocalIndexInfo> result = new ArrayList<LocalIndexInfo>();

View file

@ -15,6 +15,7 @@ import java.util.Set;
import net.osmand.Algoritms;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.IProgress;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -77,7 +78,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
CustomTitleBar titleBar = new CustomTitleBar(this, R.string.local_index_descr_title, R.drawable.tab_settings_screen_icon);
setContentView(R.layout.local_index);
titleBar.afterSetContentView();
settings = OsmandSettings.getOsmandSettings(this);
settings = OsmandApplication.getSettings();
descriptionLoader = new LoadLocalIndexDescriptionTask();
listAdapter = new LocalIndexesAdapter();
@ -159,7 +160,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
if (info != null && info.getGpxFile() != null) {
WptPt loc = info.getGpxFile().findPointToShow();
if (loc != null) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(LocalIndexesActivity.this);
OsmandSettings settings = OsmandApplication.getSettings();
settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
}
((OsmandApplication) getApplication()).setGpxFileToDisplay(info.getGpxFile(), false);
@ -631,7 +632,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
}
private void updateDescriptionTextWithSize(){
File dir = OsmandSettings.getOsmandSettings(this).extendOsmandPath("");
File dir = OsmandApplication.getSettings().extendOsmandPath("");
String size = formatGb.format(new Object[]{0});
if(dir.canRead()){
StatFs fs = new StatFs(dir.getAbsolutePath());

View file

@ -13,6 +13,7 @@ import net.osmand.OpenstreetmapUtil;
import net.osmand.osm.EntityInfo;
import net.osmand.plus.AmenityIndexRepositoryOdb;
import net.osmand.plus.OpenstreetmapsDbHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.plus.R;
@ -219,7 +220,7 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
int resId = menu.get(which);
if (info != null) {
if (resId == R.string.local_openstreetmap_show_poi) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(LocalOpenstreetmapActivity.this);
OsmandSettings settings = OsmandApplication.getSettings();
settings.setMapLocationToShow(info.getLatitude(), info.getLongitude(), settings.getLastKnownMapZoom());
MapActivity.launchMapActivityMoveToTop(LocalOpenstreetmapActivity.this);
} else if (resId == R.string.local_openstreetmap_delete) {

View file

@ -7,6 +7,7 @@ import java.util.Random;
import com.google.android.apps.analytics.easytracking.TrackedActivity;
import net.osmand.Version;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -56,7 +57,7 @@ public class MainMenuActivity extends TrackedActivity {
public void checkPreviousRunsForExceptions(boolean firstTime) {
long size = getPreferences(MODE_WORLD_READABLE).getLong(EXCEPTION_FILE_SIZE, 0);
final File file = OsmandSettings.getOsmandSettings(this).extendOsmandPath(OsmandApplication.EXCEPTION_PATH);
final File file = OsmandApplication.getSettings().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);

View file

@ -18,6 +18,7 @@ import net.osmand.map.IMapLocationListener;
import net.osmand.osm.LatLon;
import net.osmand.plus.BusyIndicator;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;

View file

@ -19,6 +19,7 @@ import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.AmenityIndexRepositoryOdb;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -212,8 +213,8 @@ public class MapActivityActions implements DialogProvider {
double longitude = args.getDouble(KEY_LONGITUDE);
String name = editText.getText().toString();
mapActivity.getSavingTrackHelper().insertPointData(latitude, longitude, System.currentTimeMillis(), name);
if(OsmandSettings.getOsmandSettings(mapActivity).SHOW_CURRENT_GPX_TRACK.get()) {
getMyApplication().favorites.addFavoritePointToGPXFile(new FavouritePoint(latitude, longitude, name, ""));
if(OsmandApplication.getSettings().SHOW_CURRENT_GPX_TRACK.get()) {
getMyApplication().getFavorites().addFavoritePointToGPXFile(new FavouritePoint(latitude, longitude, name, ""));
}
Toast.makeText(mapActivity, MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name), Toast.LENGTH_SHORT)
.show();
@ -431,7 +432,7 @@ public class MapActivityActions implements DialogProvider {
protected void getDirections(final double lat, final double lon, boolean followEnabled){
final OsmandSettings settings = OsmandSettings.getOsmandSettings(mapActivity);
final OsmandSettings settings = OsmandApplication.getSettings();
final RoutingHelper routingHelper = mapActivity.getRoutingHelper();
Builder builder = new AlertDialog.Builder(mapActivity);
@ -563,7 +564,7 @@ public class MapActivityActions implements DialogProvider {
public void navigateUsingGPX(final ApplicationMode appMode) {
final LatLon endForRouting = mapActivity.getPointToNavigate();
final MapActivityLayers mapLayers = mapActivity.getMapLayers();
final OsmandSettings settings = OsmandSettings.getOsmandSettings(mapActivity);
final OsmandSettings settings = OsmandApplication.getSettings();
final RoutingHelper routingHelper = mapActivity.getRoutingHelper();
mapLayers.selectGPXFileLayer(new CallbackWithObject<GPXFile>() {

View file

@ -23,6 +23,7 @@ import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.PoiFilter;
import net.osmand.plus.PoiFiltersHelper;
import net.osmand.plus.R;

View file

@ -10,6 +10,7 @@ import com.google.android.apps.analytics.easytracking.TrackedActivity;
import net.osmand.LogUtil;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.search.SearchActivity;
@ -78,7 +79,7 @@ public class NavigatePointActivity extends TrackedActivity implements SearchActi
loc = ((SearchActivity) getParent()).getSearchPoint();
}
if (loc == null) {
loc = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
loc = OsmandApplication.getSettings().getLastKnownMapLocation();
}
initUI(loc.getLatitude(), loc.getLongitude());
}
@ -238,14 +239,14 @@ public class NavigatePointActivity extends TrackedActivity implements SearchActi
double lon = convert(((TextView) findViewById(R.id.LongitudeEdit)).getText().toString());
if(navigate){
OsmandSettings.getOsmandSettings(this).setPointToNavigate(lat, lon, getString(R.string.point_on_map, lat, lon));
OsmandApplication.getSettings().setPointToNavigate(lat, lon, getString(R.string.point_on_map, lat, lon));
} else {
// in case when it is dialog
if(activity != null) {
OsmandMapTileView v = activity.getMapView();
v.getAnimatedDraggingThread().startMoving(lat, lon, v.getZoom(), true);
} else {
OsmandSettings settings = OsmandSettings.getOsmandSettings(this);
OsmandSettings settings = OsmandApplication.getSettings();
settings.setMapLocationToShow(lat, lon, Math.max(12, settings.getLastKnownMapZoom()),
getString(R.string.point_on_map, lat, lon));
}

View file

@ -14,6 +14,7 @@ import net.osmand.GPXUtilities.Track;
import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.LogUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.ResourceManager;
@ -124,7 +125,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
*/
public List<String> saveDataToGpx() {
List<String> warnings = new ArrayList<String>();
File dir = OsmandSettings.getOsmandSettings(ctx).getExternalStorageDirectory();
File dir = OsmandApplication.getSettings().getExternalStorageDirectory();
if (dir.canWrite()) {
dir = new File(dir, ResourceManager.GPX_PATH);
dir.mkdirs();

View file

@ -20,6 +20,7 @@ import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandSettings.DayNightMode;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -168,7 +169,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
String[] entries;
String[] entrieValues;
PreferenceScreen screen = getPreferenceScreen();
osmandSettings = OsmandSettings.getOsmandSettings(this);
osmandSettings = OsmandApplication.getSettings();
registerBooleanPreference(osmandSettings.SHOW_VIEW_ANGLE,screen);
registerBooleanPreference(osmandSettings.USE_TRACKBALL_FOR_MOVEMENTS,screen);

View file

@ -6,6 +6,7 @@ package net.osmand.plus.activities;
import java.util.List;
import net.osmand.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.routing.RoutingHelper;
@ -67,7 +68,7 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
RouteDirectionInfo item = ((RouteInfoAdapter)getListAdapter()).getItem(position - 1);
Location loc = helper.getLocationFromRouteDirection(item);
if(loc != null){
OsmandSettings settings = OsmandSettings.getOsmandSettings(this);
OsmandSettings settings = OsmandApplication.getSettings();
settings.setMapLocationToShow(loc.getLatitude(),loc.getLongitude(),
Math.max(13, settings.getLastKnownMapZoom()));
MapActivity.launchMapActivityMoveToTop(this);

View file

@ -3,6 +3,7 @@
*/
package net.osmand.plus.activities;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.voice.AbstractPrologCommandPlayer;
import net.osmand.plus.voice.CommandBuilder;
import net.osmand.plus.voice.CommandPlayer;

View file

@ -18,12 +18,12 @@ import net.osmand.data.Street;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.osm.Node;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.RegionAddressRepository;
import net.osmand.plus.ResourceManager;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandApplication;
import net.osmand.plus.activities.OsmandListActivity;
import android.app.Dialog;
import android.app.ProgressDialog;

View file

@ -9,6 +9,7 @@ import java.util.Locale;
import net.osmand.Algoritms;
import net.osmand.FavouritePoint;
import net.osmand.osm.LatLon;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.FavouritesListActivity;
@ -154,7 +155,7 @@ public class SearchActivity extends TabActivity {
searchAroundCurrentLocation = false;
endSearchCurrentLocation();
if (position == POSITION_LAST_MAP_VIEW) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(SearchActivity.this);
OsmandSettings settings = OsmandApplication.getSettings();
updateSearchPoint(settings.getLastKnownMapLocation(), getString(R.string.search_position_fixed), true);
} else if (position == POSITION_FAVORITES) {
Intent intent = new Intent(SearchActivity.this, FavouritesListActivity.class);
@ -265,7 +266,7 @@ public class SearchActivity extends TabActivity {
}
if(searchPoint == null){
LatLon last = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
LatLon last = OsmandApplication.getSettings().getLastKnownMapLocation();
if(!Algoritms.objectEquals(reqSearchPoint, last)){
reqSearchPoint = last;
updateSearchPoint(last, getString(R.string.search_position_fixed), true);

View file

@ -5,11 +5,11 @@ import java.text.MessageFormat;
import net.osmand.Algoritms;
import net.osmand.osm.LatLon;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.RegionAddressRepository;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandApplication;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
@ -62,7 +62,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);
osmandSettings = OsmandApplication.getSettings();
attachListeners();
}

View file

@ -14,6 +14,7 @@ import net.osmand.OsmAndFormatter;
import net.osmand.Version;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -84,7 +85,7 @@ public class SearchAddressOnlineActivity extends OsmandListActivity implements S
searchPlaces(searchText.getText().toString());
}
});
location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
location = OsmandApplication.getSettings().getLastKnownMapLocation();
if (lastResult != null) {
setListAdapter(lastResult);
@ -106,7 +107,7 @@ public class SearchAddressOnlineActivity extends OsmandListActivity implements S
location = ((SearchActivity) getParent()).getSearchPoint();
}
if (location == null) {
location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
location = OsmandApplication.getSettings().getLastKnownMapLocation();
}
}
@ -209,7 +210,7 @@ public class SearchAddressOnlineActivity extends OsmandListActivity implements S
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Place item = ((PlacesAdapter) getListAdapter()).getItem(position);
OsmandSettings settings = OsmandSettings.getOsmandSettings(this);
OsmandSettings settings = OsmandApplication.getSettings();
settings.setMapLocationToShow(item.lat, item.lon,
Math.max(15, settings.getLastKnownMapZoom()), getString(R.string.address)+ " : " + item.displayName); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(this);

View file

@ -7,9 +7,9 @@ import net.osmand.data.Building;
import net.osmand.data.City;
import net.osmand.data.PostCode;
import net.osmand.data.Street;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.RegionAddressRepository;
import net.osmand.plus.activities.OsmandApplication;
import android.os.AsyncTask;
import android.view.View;
import android.widget.TextView;

View file

@ -8,6 +8,7 @@ import net.osmand.CollatorStringMatcher;
import net.osmand.CollatorStringMatcher.StringMatcherMode;
import net.osmand.LogUtil;
import net.osmand.osm.LatLon;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandListActivity;
@ -57,7 +58,7 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings = OsmandSettings.getOsmandSettings(this);
settings = OsmandApplication.getSettings();
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.search_by_name);

View file

@ -9,9 +9,9 @@ import net.osmand.data.MapObject;
import net.osmand.data.PostCode;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.RegionAddressRepository;
import net.osmand.plus.activities.OsmandApplication;
import android.os.AsyncTask;
import android.os.Message;
import android.view.View;

View file

@ -8,6 +8,7 @@ import com.google.android.apps.analytics.easytracking.TrackedListActivity;
import net.osmand.OsmAndFormatter;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -80,7 +81,7 @@ public class SearchHistoryActivity extends TrackedListActivity implements Searc
location = ((SearchActivity) getParent()).getSearchPoint();
}
if (location == null) {
location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
location = OsmandApplication.getSettings().getLastKnownMapLocation();
}
List<HistoryEntry> historyEntries = helper.getHistoryEntries(this);
@ -108,12 +109,11 @@ public class SearchHistoryActivity extends TrackedListActivity implements Searc
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
OsmandSettings settings = OsmandSettings.getOsmandSettings(SearchHistoryActivity.this);
OsmandSettings settings = OsmandApplication.getSettings();
settings.setMapLocationToShow(entry.getLat(), entry.getLon(), settings.getLastKnownMapZoom(), null, entry
.getName(), null);
} else if (which == 1) {
OsmandSettings.getOsmandSettings(SearchHistoryActivity.this).setPointToNavigate(entry.getLat(), entry.getLon(),
null);
OsmandApplication.getSettings().setPointToNavigate(entry.getLat(), entry.getLon(), null);
}
MapActivity.launchMapActivityMoveToTop(SearchHistoryActivity.this);
}
@ -131,7 +131,7 @@ public class SearchHistoryActivity extends TrackedListActivity implements Searc
private void selectModel(HistoryEntry model) {
helper.selectEntry(model, this);
OsmandSettings settings = OsmandSettings.getOsmandSettings(SearchHistoryActivity.this);
OsmandSettings settings = OsmandApplication.getSettings();
settings.setMapLocationToShow(model.getLat(), model.getLon(), settings.getLastKnownMapZoom(), null, model.getName(), null);
MapActivity.launchMapActivityMoveToTop(this);
}

View file

@ -25,6 +25,7 @@ import net.osmand.osm.LatLon;
import net.osmand.osm.OpeningHoursParser;
import net.osmand.osm.OpeningHoursParser.OpeningHoursRule;
import net.osmand.plus.NameFinderPoiFilter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.PoiFilter;
import net.osmand.plus.R;
@ -32,7 +33,6 @@ import net.osmand.plus.SearchByNameFilter;
import net.osmand.plus.activities.CustomTitleBar;
import net.osmand.plus.activities.EditPOIFilterActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandApplication;
import net.osmand.plus.activities.OsmandListActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
@ -126,7 +126,7 @@ public class SearchPOIActivity extends OsmandListActivity implements SensorEvent
showOnMap = (ImageButton) findViewById(R.id.ShowOnMap);
showFilter = (ImageButton) findViewById(R.id.ShowFilter);
settings = OsmandSettings.getOsmandSettings(this);
settings = OsmandApplication.getSettings();
searchPOILevel.setOnClickListener(new OnClickListener() {
@Override

View file

@ -8,6 +8,7 @@ import java.util.List;
import net.osmand.osm.LatLon;
import net.osmand.plus.NameFinderPoiFilter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.PoiFilter;
import net.osmand.plus.PoiFiltersHelper;
@ -15,7 +16,6 @@ import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
import net.osmand.plus.SearchByNameFilter;
import net.osmand.plus.activities.EditPOIFilterActivity;
import net.osmand.plus.activities.OsmandApplication;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -89,7 +89,7 @@ public class SearchPoiFilterActivity extends TrackedListActivity {
searchAround = ((SearchActivity) getParent()).isSearchAroundCurrentLocation();
}
if (loc == null && !searchAround) {
loc = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
loc = OsmandApplication.getSettings().getLastKnownMapLocation();
}
if(loc != null && !searchAround) {
intentToLaunch.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());

View file

@ -2,10 +2,10 @@ package net.osmand.plus.activities.search;
import java.util.ArrayList;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.RegionAddressRepository;
import net.osmand.plus.activities.OsmandApplication;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
@ -33,7 +33,7 @@ public class SearchRegionByNameActivity extends SearchByNameAbstractActivity<Reg
@Override
public void itemSelected(RegionAddressRepository obj) {
OsmandSettings.getOsmandSettings(this).setLastSearchedRegion(obj.getName(), obj.getEstimatedRegionCenter());
OsmandApplication.getSettings().setLastSearchedRegion(obj.getName(), obj.getEstimatedRegionCenter());
finish();
}

View file

@ -5,9 +5,9 @@ import java.util.List;
import net.osmand.data.City;
import net.osmand.data.PostCode;
import net.osmand.data.Street;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.RegionAddressRepository;
import net.osmand.plus.activities.OsmandApplication;
import android.os.AsyncTask;
import android.view.View;
import android.widget.TextView;

View file

@ -10,9 +10,9 @@ import net.osmand.CollatorStringMatcher.StringMatcherMode;
import net.osmand.data.City;
import net.osmand.data.PostCode;
import net.osmand.data.Street;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.RegionAddressRepository;
import net.osmand.plus.activities.OsmandApplication;
import android.os.AsyncTask;
import android.os.Message;
import android.view.View;

View file

@ -15,11 +15,11 @@ import net.osmand.data.TransportRoute;
import net.osmand.data.TransportStop;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TransportIndexRepository;
import net.osmand.plus.TransportIndexRepository.RouteInfoLocation;
import net.osmand.plus.activities.OsmandApplication;
import net.osmand.plus.activities.TransportRouteHelper;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import android.app.AlertDialog;
@ -74,7 +74,7 @@ public class SearchTransportActivity extends TrackedListActivity implements Sear
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
settings = OsmandSettings.getOsmandSettings(this);
settings = OsmandApplication.getSettings();
setContentView(R.layout.search_transport);
searchTransportLevel = (Button) findViewById(R.id.SearchTransportLevelButton);
@ -140,7 +140,7 @@ public class SearchTransportActivity extends TrackedListActivity implements Sear
startPoint = ((SearchActivity) getParent()).getSearchPoint();
}
if (startPoint == null) {
startPoint = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
startPoint = OsmandApplication.getSettings().getLastKnownMapLocation();
}
LatLon pointToNavigate = settings.getPointToNavigate();

View file

@ -34,9 +34,9 @@ import net.osmand.osm.MapUtils;
import net.osmand.osm.MultyPolygon;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.RotatedTileBox;
import net.osmand.plus.activities.OsmandApplication;
import net.osmand.plus.render.NativeOsmandLibrary.NativeSearchResult;
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@ -95,7 +95,7 @@ public class MapRenderRepositories {
this.context = context;
this.renderer = new OsmandRenderer(context);
handler = new Handler(Looper.getMainLooper());
prefs = OsmandSettings.getOsmandSettings(context);
prefs = OsmandApplication.getSettings();
}
public Context getContext() {

View file

@ -28,9 +28,9 @@ import net.osmand.OsmAndFormatter;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.ApplicationMode;
import net.osmand.plus.activities.OsmandApplication;
import net.osmand.plus.routing.RoutingHelper.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper.TurnType;
import net.osmand.router.BicycleRouter;

View file

@ -6,6 +6,7 @@ import java.util.List;
import net.osmand.GPXUtilities.Track;
import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import android.graphics.Canvas;
@ -48,7 +49,7 @@ public class GPXLayer extends OsmandMapLayer {
@Override
public void initLayer(OsmandMapTileView view) {
this.view = view;
settings = OsmandSettings.getOsmandSettings(view.getContext());
settings = OsmandApplication.getSettings();
initUI();
}

View file

@ -14,6 +14,7 @@ import java.util.regex.Pattern;
import net.osmand.LogUtil;
import net.osmand.osm.LatLon;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.DialogProvider;
@ -358,7 +359,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements ContextMenuLayer.ICo
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.getOsmandSettings(activity).USER_OSM_BUG_NAME.set(author);
OsmandApplication.getSettings().USER_OSM_BUG_NAME.set(author);
boolean bug = createNewBug(latitude, longitude, text, author);
if (bug) {
Toast.makeText(activity, activity.getResources().getString(R.string.osb_add_dialog_success), Toast.LENGTH_LONG).show();
@ -375,7 +376,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements ContextMenuLayer.ICo
public void openBug(final double latitude, final double longitude){
OsmandSettings settings = OsmandSettings.getOsmandSettings(activity);
OsmandSettings settings = OsmandApplication.getSettings();
openBugAlertDialog(latitude, longitude, "", settings.USER_OSM_BUG_NAME.get());
}
@ -389,7 +390,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements ContextMenuLayer.ICo
builder.setTitle(R.string.osb_comment_dialog_title);
final View view = activity.getLayoutInflater().inflate(R.layout.open_bug, null);
builder.setView(view);
((EditText)view.findViewById(R.id.AuthorName)).setText(OsmandSettings.getOsmandSettings(activity).USER_OSM_BUG_NAME.get());
((EditText)view.findViewById(R.id.AuthorName)).setText(OsmandApplication.getSettings().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
@ -397,7 +398,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements ContextMenuLayer.ICo
OpenStreetBug bug = (OpenStreetBug) args.getSerializable(KEY_BUG);
String text = ((EditText)view.findViewById(R.id.BugMessage)).getText().toString();
String author = ((EditText)view.findViewById(R.id.AuthorName)).getText().toString();
OsmandSettings.getOsmandSettings(activity).USER_OSM_BUG_NAME.set(author);
OsmandApplication.getSettings().USER_OSM_BUG_NAME.set(author);
boolean added = addingComment(bug.getId(), text, author);
if (added) {
Toast.makeText(activity, activity.getResources().getString(R.string.osb_comment_dialog_success), Toast.LENGTH_LONG).show();

View file

@ -12,8 +12,8 @@ import net.osmand.data.MapTileDownloader.IMapDownloaderCallback;
import net.osmand.map.IMapLocationListener;
import net.osmand.osm.LatLon;
import net.osmand.osm.MapUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.activities.OsmandApplication;
import net.osmand.plus.views.MultiTouchSupport.MultiTouchZoomListener;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@ -414,7 +414,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
public OsmandSettings getSettings(){
if(settings == null){
settings = OsmandSettings.getOsmandSettings(getContext());
settings = OsmandApplication.getSettings();
}
return settings;
}

View file

@ -10,6 +10,7 @@ import java.util.Iterator;
import java.util.List;
import net.osmand.LogUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
@ -75,7 +76,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer {
prologSystem.clearTheory();
voiceDir = null;
if (voiceProvider != null) {
File parent = OsmandSettings.getOsmandSettings(ctx).extendOsmandPath(ResourceManager.VOICE_PATH);
File parent = OsmandApplication.getSettings().extendOsmandPath(ResourceManager.VOICE_PATH);
voiceDir = new File(parent, voiceProvider);
if (!voiceDir.exists()) {
voiceDir = null;

View file

@ -2,10 +2,10 @@ package net.osmand.plus.voice;
import java.io.File;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ResourceManager;
import net.osmand.plus.activities.OsmandApplication;
import android.app.Activity;
import android.os.Build;
@ -15,7 +15,7 @@ public class CommandPlayerFactory
throws CommandPlayerException
{
if (voiceProvider != null){
File parent = OsmandSettings.getOsmandSettings(ctx).extendOsmandPath(ResourceManager.VOICE_PATH);
File parent = OsmandApplication.getSettings().extendOsmandPath(ResourceManager.VOICE_PATH);
File voiceDir = new File(parent, voiceProvider);
if(!voiceDir.exists()){
throw new CommandPlayerException(ctx.getString(R.string.voice_data_unavailable));