From 09daa404e22c6d698646d274e75e9030c4368adf Mon Sep 17 00:00:00 2001 From: Alexey Pelykh Date: Wed, 7 Mar 2012 21:17:34 +0200 Subject: [PATCH 1/2] OsmandApplication class is not anyhow related to activities, let's keep code organized --- OsmAnd/AndroidManifest.xml | 2 +- .../net/osmand/plus/NameFinderPoiFilter.java | 1 - .../net/osmand/plus/NavigationService.java | 1 - .../OnNavigationServiceAlarmReceiver.java | 1 - .../{activities => }/OsmandApplication.java | 222 +++++++++--------- .../src/net/osmand/plus/OsmandSettings.java | 1 - OsmAnd/src/net/osmand/plus/PoiFilter.java | 1 - .../src/net/osmand/plus/PoiFiltersHelper.java | 1 - .../src/net/osmand/plus/ResourceManager.java | 1 - .../net/osmand/plus/SearchByNameFilter.java | 1 - .../plus/activities/DayNightHelper.java | 1 + .../activities/DownloadIndexActivity.java | 1 + .../plus/activities/DownloadTilesDialog.java | 1 + .../activities/EditPOIFilterActivity.java | 1 + .../plus/activities/EditingPOIActivity.java | 1 + .../plus/activities/FavouritesActivity.java | 1 + .../activities/FavouritesListActivity.java | 1 + .../plus/activities/LocalIndexHelper.java | 1 + .../plus/activities/LocalIndexesActivity.java | 1 + .../LocalOpenstreetmapActivity.java | 1 + .../plus/activities/MainMenuActivity.java | 1 + .../osmand/plus/activities/MapActivity.java | 1 + .../plus/activities/MapActivityActions.java | 1 + .../plus/activities/MapActivityLayers.java | 1 + .../plus/activities/SettingsActivity.java | 1 + .../activities/ShowRouteInfoActivity.java | 1 + .../plus/activities/TestVoiceActivity.java | 1 + .../activities/search/GeoIntentActivity.java | 2 +- .../search/SearchAddressActivity.java | 2 +- .../search/SearchBuildingByNameActivity.java | 2 +- .../search/SearchCityByNameActivity.java | 2 +- .../activities/search/SearchPOIActivity.java | 2 +- .../search/SearchPoiFilterActivity.java | 2 +- .../search/SearchRegionByNameActivity.java | 2 +- .../search/SearchStreet2ByNameActivity.java | 2 +- .../search/SearchStreetByNameActivity.java | 2 +- .../search/SearchTransportActivity.java | 2 +- .../plus/render/MapRenderRepositories.java | 2 +- .../osmand/plus/routing/RouteProvider.java | 2 +- .../osmand/plus/views/OsmandMapTileView.java | 2 +- .../plus/voice/CommandPlayerFactory.java | 2 +- 41 files changed, 143 insertions(+), 134 deletions(-) rename OsmAnd/src/net/osmand/plus/{activities => }/OsmandApplication.java (76%) diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 0d8e482ea3..b77f8db5b8 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -10,7 +10,7 @@ diff --git a/OsmAnd/src/net/osmand/plus/NameFinderPoiFilter.java b/OsmAnd/src/net/osmand/plus/NameFinderPoiFilter.java index f05057f3a6..8f26207564 100644 --- a/OsmAnd/src/net/osmand/plus/NameFinderPoiFilter.java +++ b/OsmAnd/src/net/osmand/plus/NameFinderPoiFilter.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java index 9da30d5436..63957600c6 100644 --- a/OsmAnd/src/net/osmand/plus/NavigationService.java +++ b/OsmAnd/src/net/osmand/plus/NavigationService.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/OnNavigationServiceAlarmReceiver.java b/OsmAnd/src/net/osmand/plus/OnNavigationServiceAlarmReceiver.java index daa9537be6..a571d423cd 100644 --- a/OsmAnd/src/net/osmand/plus/OnNavigationServiceAlarmReceiver.java +++ b/OsmAnd/src/net/osmand/plus/OnNavigationServiceAlarmReceiver.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java similarity index 76% rename from OsmAnd/src/net/osmand/plus/activities/OsmandApplication.java rename to OsmAnd/src/net/osmand/plus/OsmandApplication.java index c824ffa8ff..8dee5616b0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -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,14 +39,13 @@ 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; @@ -57,63 +54,61 @@ public class OsmandApplication extends Application { DayNightHelper daynightHelper; NavigationService navigationService; RendererRegistry rendererRegistry; - - + // start variables private ProgressDialogImplementation startDialog; private List 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 = OsmandSettings.getOsmandSettings(this); + 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() { + + public OsmandSettings getSettings() { 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 pts = new ArrayList(); @@ -121,7 +116,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 +125,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 +160,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 +197,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 +266,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 +276,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 +310,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 +324,7 @@ public class OsmandApplication extends Application { } return GPXUtilities.writeGpxFile(f, gpx, this); } - + private void startApplicationBackground() { List warnings = null; try { @@ -345,9 +345,10 @@ 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 = OsmandSettings.getOsmandSettings(this) + .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 +383,13 @@ public class OsmandApplication extends Application { } } } - + protected void showWarnings(List 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 +408,6 @@ public class OsmandApplication extends Application { } }); } - private class DefaultExceptionHandler implements UncaughtExceptionHandler { @@ -425,7 +425,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 +438,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$ } } } - - + } diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index f7a15db7a1..075b052d07 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -14,7 +14,6 @@ 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; diff --git a/OsmAnd/src/net/osmand/plus/PoiFilter.java b/OsmAnd/src/net/osmand/plus/PoiFilter.java index 66571e7dec..3dca4ed81c 100644 --- a/OsmAnd/src/net/osmand/plus/PoiFilter.java +++ b/OsmAnd/src/net/osmand/plus/PoiFilter.java @@ -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 { diff --git a/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java b/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java index 9a7ddd6841..ac42530912 100644 --- a/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java +++ b/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/ResourceManager.java b/OsmAnd/src/net/osmand/plus/ResourceManager.java index 4ca1704200..a28aab9d28 100644 --- a/OsmAnd/src/net/osmand/plus/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/ResourceManager.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/SearchByNameFilter.java b/OsmAnd/src/net/osmand/plus/SearchByNameFilter.java index 0f56580ca3..6898db2db6 100644 --- a/OsmAnd/src/net/osmand/plus/SearchByNameFilter.java +++ b/OsmAnd/src/net/osmand/plus/SearchByNameFilter.java @@ -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 { diff --git a/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java b/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java index 847af45f1c..34c43849c3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java index 400b887269..571a6b317f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/DownloadTilesDialog.java b/OsmAnd/src/net/osmand/plus/activities/DownloadTilesDialog.java index 833193cd91..7119b5840c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DownloadTilesDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/DownloadTilesDialog.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java index a17b0e8a30..5495bf77a2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/EditingPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/EditingPOIActivity.java index afe3b39a7f..d6c0085d7b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditingPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditingPOIActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java index 611357dd95..94fc302016 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java index f701572ebd..50e57f024d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java index 6383a68d66..3cb5eb749b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java index 7ed5423b5a..025d211c59 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalOpenstreetmapActivity.java b/OsmAnd/src/net/osmand/plus/activities/LocalOpenstreetmapActivity.java index a92dc755a2..b078eef8d8 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalOpenstreetmapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalOpenstreetmapActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java index cdf6cddd42..0d80b86019 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 70038725cd..67ccf23e7e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index a52da9f987..c680300fa3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java index be4d2d4993..d875d0f6b3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java index 156d0a68ad..53f2890eda 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java index db0a4fb21a..7f4f1f10cd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/TestVoiceActivity.java b/OsmAnd/src/net/osmand/plus/activities/TestVoiceActivity.java index 6c3a36ef45..205103c2bd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/TestVoiceActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/TestVoiceActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java index 5c9320cae2..d5515b3356 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java index 6fd0ccb9ff..4b03bca59e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java index 3e5b262870..01835c093d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchBuildingByNameActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java index 7c70848356..294c04432d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index ad2dce1411..ba4c6885ec 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java index 6ca4d2eaad..7cf32da82f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java index 824594fee7..b8a0b71259 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchStreet2ByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchStreet2ByNameActivity.java index b5235885ec..2afd84fc1d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchStreet2ByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchStreet2ByNameActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchStreetByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchStreetByNameActivity.java index fb406973c2..cbeb16643c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchStreetByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchStreetByNameActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportActivity.java index b5511e9432..e254b94e00 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchTransportActivity.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index 2f6db0b931..04666c5185 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 79a8d09002..6e7e88bb7c 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 2451987930..f7c71ec4d0 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -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; diff --git a/OsmAnd/src/net/osmand/plus/voice/CommandPlayerFactory.java b/OsmAnd/src/net/osmand/plus/voice/CommandPlayerFactory.java index aab9902f81..0f798daa16 100644 --- a/OsmAnd/src/net/osmand/plus/voice/CommandPlayerFactory.java +++ b/OsmAnd/src/net/osmand/plus/voice/CommandPlayerFactory.java @@ -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; From 904659f90b116491e3883e6d01e7db12f0699fd0 Mon Sep 17 00:00:00 2001 From: Alexey Pelykh Date: Thu, 8 Mar 2012 01:43:02 +0200 Subject: [PATCH 2/2] Allow settings to be created on the upper level. Add interface for letter conditional overriding of default values for preferences --- .../net/osmand/OpenstreetmapRemoteUtil.java | 9 ++-- OsmAnd/src/net/osmand/OsmAndFormatter.java | 9 ++-- .../net/osmand/plus/FavouritesDbHelper.java | 3 +- .../net/osmand/plus/NavigationService.java | 2 +- .../net/osmand/plus/OsmandApplication.java | 30 ++++++++++--- .../src/net/osmand/plus/OsmandSettings.java | 44 ++++++++++++------- OsmAnd/src/net/osmand/plus/PoiFilter.java | 2 +- .../ContributionVersionActivity.java | 5 ++- .../activities/DownloadIndexActivity.java | 16 +++---- .../activities/EditPOIFilterActivity.java | 2 +- .../plus/activities/EditingPOIActivity.java | 4 +- .../plus/activities/FavouritesActivity.java | 12 ++--- .../activities/FavouritesListActivity.java | 8 ++-- .../plus/activities/LiveMonitoringHelper.java | 3 +- .../plus/activities/LocalIndexHelper.java | 2 +- .../plus/activities/LocalIndexesActivity.java | 6 +-- .../LocalOpenstreetmapActivity.java | 2 +- .../plus/activities/MainMenuActivity.java | 2 +- .../plus/activities/MapActivityActions.java | 8 ++-- .../activities/NavigatePointActivity.java | 7 +-- .../plus/activities/SavingTrackHelper.java | 3 +- .../plus/activities/SettingsActivity.java | 2 +- .../activities/ShowRouteInfoActivity.java | 2 +- .../activities/search/SearchActivity.java | 5 ++- .../search/SearchAddressActivity.java | 2 +- .../search/SearchAddressOnlineActivity.java | 7 +-- .../search/SearchByNameAbstractActivity.java | 3 +- .../search/SearchHistoryActivity.java | 10 ++--- .../activities/search/SearchPOIActivity.java | 2 +- .../search/SearchPoiFilterActivity.java | 2 +- .../search/SearchRegionByNameActivity.java | 2 +- .../search/SearchTransportActivity.java | 4 +- .../plus/render/MapRenderRepositories.java | 2 +- .../src/net/osmand/plus/views/GPXLayer.java | 3 +- .../net/osmand/plus/views/OsmBugsLayer.java | 9 ++-- .../osmand/plus/views/OsmandMapTileView.java | 2 +- .../voice/AbstractPrologCommandPlayer.java | 3 +- .../plus/voice/CommandPlayerFactory.java | 2 +- 38 files changed, 142 insertions(+), 99 deletions(-) diff --git a/OsmAnd/src/net/osmand/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/OpenstreetmapRemoteUtil.java index 87ab023339..767cde9a7b 100644 --- a/OsmAnd/src/net/osmand/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/OpenstreetmapRemoteUtil.java @@ -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(); diff --git a/OsmAnd/src/net/osmand/OsmAndFormatter.java b/OsmAnd/src/net/osmand/OsmAndFormatter.java index b06f151d3d..e77501653c 100644 --- a/OsmAnd/src/net/osmand/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/OsmAndFormatter.java @@ -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){ diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index c21bde67c0..5b3a49bef9 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -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()) { diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java index 63957600c6..f5cb605801 100644 --- a/OsmAnd/src/net/osmand/plus/NavigationService.java +++ b/OsmAnd/src/net/osmand/plus/NavigationService.java @@ -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(); diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 8dee5616b0..72be040bb4 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -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())) { diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 075b052d07..f22867438c 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -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 Type of preference value + */ + protected interface OsmandPreferenceWithOverridableDefault { + /** + * Overrides default value with given + * @param newDefaultValue New default value + */ + void overrideDefaultValue(T newDefaultValue); } - public interface OsmandPreference { + public interface OsmandPreference extends OsmandPreferenceWithOverridableDefault { T get(); boolean set(T obj); @@ -71,8 +72,10 @@ public class OsmandSettings { private List 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 { diff --git a/OsmAnd/src/net/osmand/plus/PoiFilter.java b/OsmAnd/src/net/osmand/plus/PoiFilter.java index 3dca4ed81c..231bec22d3 100644 --- a/OsmAnd/src/net/osmand/plus/PoiFilter.java +++ b/OsmAnd/src/net/osmand/plus/PoiFilter.java @@ -147,7 +147,7 @@ public class PoiFilter { public ResultMatcher getResultMatcher(final ResultMatcher 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() { @Override public boolean publish(Amenity object) { diff --git a/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java b/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java index 85ef70cbbb..caccb5d6b6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ContributionVersionActivity.java @@ -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 { diff --git a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java index 571a6b317f..c7cb25618b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/DownloadIndexActivity.java @@ -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 listAlreadyDownloadedWithAlternatives() { Set files = new TreeSet(); - 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 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); diff --git a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java index 5495bf77a2..6305a013f8 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditPOIFilterActivity.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/activities/EditingPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/EditingPOIActivity.java index d6c0085d7b..0f3b4a357d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditingPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditingPOIActivity.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java index 94fc302016..11e1bf071b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java @@ -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)); diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java index 50e57f024d..6fd1030a41 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesListActivity.java @@ -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, diff --git a/OsmAnd/src/net/osmand/plus/activities/LiveMonitoringHelper.java b/OsmAnd/src/net/osmand/plus/activities/LiveMonitoringHelper.java index d1190b3fa8..74b5d08320 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LiveMonitoringHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/LiveMonitoringHelper.java @@ -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(){ diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java index 3cb5eb749b..a86aa7c996 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java @@ -202,7 +202,7 @@ public class LocalIndexHelper { } public List getLocalIndexData(LocalIndexType type, LoadLocalIndexTask loadTask){ - OsmandSettings settings = OsmandSettings.getOsmandSettings(app.getApplicationContext()); + OsmandSettings settings = OsmandApplication.getSettings(); Map loadedMaps = app.getResourceManager().getIndexFileNames(); List result = new ArrayList(); diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java index 025d211c59..88f9fdfd80 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexesActivity.java @@ -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()); diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalOpenstreetmapActivity.java b/OsmAnd/src/net/osmand/plus/activities/LocalOpenstreetmapActivity.java index b078eef8d8..d9c6f98b1c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalOpenstreetmapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalOpenstreetmapActivity.java @@ -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) { diff --git a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java index 0d80b86019..2df3123ad4 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index c680300fa3..aa0faa6e7d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -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() { diff --git a/OsmAnd/src/net/osmand/plus/activities/NavigatePointActivity.java b/OsmAnd/src/net/osmand/plus/activities/NavigatePointActivity.java index b919111f97..5a4a6edaa1 100644 --- a/OsmAnd/src/net/osmand/plus/activities/NavigatePointActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/NavigatePointActivity.java @@ -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)); } diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index 91d718218e..46b5393f3e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -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 saveDataToGpx() { List warnings = new ArrayList(); - File dir = OsmandSettings.getOsmandSettings(ctx).getExternalStorageDirectory(); + File dir = OsmandApplication.getSettings().getExternalStorageDirectory(); if (dir.canWrite()) { dir = new File(dir, ResourceManager.GPX_PATH); dir.mkdirs(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java index 53f2890eda..2d6f5db552 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsActivity.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java index 7f4f1f10cd..9283f0ade6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoActivity.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java index aa514aef1c..e34ad4178b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java index 4b03bca59e..48dbcf8465 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressActivity.java @@ -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(); } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineActivity.java index 6f4bc5417a..b0ea8ca03a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchAddressOnlineActivity.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java index 3d7bf31af4..738997a4bc 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java @@ -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 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); diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryActivity.java index b0b0685b76..bdef273b44 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryActivity.java @@ -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 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); } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index ba4c6885ec..05838d3b16 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -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 diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java index 7cf32da82f..c9be010fec 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java @@ -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()); diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java index b8a0b71259..a4f00c79a6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchRegionByNameActivity.java @@ -33,7 +33,7 @@ public class SearchRegionByNameActivity extends SearchByNameAbstractActivity