Allow settings to be created on the upper level. Add interface for letter conditional overriding of default values for preferences
This commit is contained in:
parent
09daa404e2
commit
904659f90b
38 changed files with 142 additions and 99 deletions
|
@ -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();
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -90,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();
|
||||
|
|
|
@ -50,7 +50,13 @@ public class OsmandApplication extends Application {
|
|||
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;
|
||||
|
@ -69,7 +75,7 @@ public class OsmandApplication extends Application {
|
|||
super.onCreate();
|
||||
|
||||
long timeToStart = System.currentTimeMillis();
|
||||
osmandSettings = OsmandSettings.getOsmandSettings(this);
|
||||
osmandSettings = createOsmandSettingsInstance();
|
||||
routingHelper = new RoutingHelper(osmandSettings, this, player);
|
||||
manager = new ResourceManager(this);
|
||||
daynightHelper = new DayNightHelper(this);
|
||||
|
@ -93,8 +99,23 @@ public class OsmandApplication extends Application {
|
|||
public RendererRegistry getRendererRegistry() {
|
||||
return rendererRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates instance of OsmandSettings
|
||||
* @return Reference to instance of OsmandSettings
|
||||
*/
|
||||
protected OsmandSettings createOsmandSettingsInstance() {
|
||||
return new OsmandSettings(this);
|
||||
}
|
||||
|
||||
public OsmandSettings getSettings() {
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
@ -347,8 +368,7 @@ public class OsmandApplication extends Application {
|
|||
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())) {
|
||||
|
|
|
@ -18,6 +18,7 @@ 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;
|
||||
|
@ -32,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);
|
||||
|
@ -71,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;
|
||||
|
@ -108,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) {
|
||||
|
@ -233,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);
|
||||
|
@ -284,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> {
|
||||
|
||||
|
|
|
@ -147,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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -185,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+"", ""));
|
||||
|
@ -460,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));
|
||||
|
@ -499,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;
|
||||
|
@ -554,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")) {
|
||||
|
@ -582,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());
|
||||
|
@ -644,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
|
||||
|
@ -719,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);
|
||||
|
|
|
@ -63,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);
|
||||
|
|
|
@ -73,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 {
|
||||
|
@ -117,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) {
|
||||
|
|
|
@ -201,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
|
||||
|
@ -228,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);
|
||||
|
@ -244,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);
|
||||
|
@ -339,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()){
|
||||
|
@ -615,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));
|
||||
|
|
|
@ -79,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);
|
||||
|
@ -129,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);
|
||||
|
@ -148,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,
|
||||
|
|
|
@ -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(){
|
||||
|
|
|
@ -202,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>();
|
||||
|
||||
|
|
|
@ -78,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();
|
||||
|
||||
|
@ -160,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);
|
||||
|
@ -632,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());
|
||||
|
|
|
@ -220,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) {
|
||||
|
|
|
@ -57,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);
|
||||
|
|
|
@ -213,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();
|
||||
|
@ -432,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);
|
||||
|
@ -564,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>() {
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -169,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);
|
||||
|
|
|
@ -68,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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue