From 2867736814b406309807724440bd6af34654ad37 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 7 Oct 2020 23:08:57 +0300 Subject: [PATCH] refactor OsmandSettings remove Enum --- .../plus/inapp/InAppPurchaseHelperImpl.java | 3 +- .../plus/inapp/InAppPurchaseHelperImpl.java | 2 +- OsmAnd/src/net/osmand/FileUtils.java | 13 + OsmAnd/src/net/osmand/aidl/ConnectedApp.java | 1 - .../src/net/osmand/plus/AppInitializer.java | 2 +- .../osmand/plus/AppVersionUpgradeOnInit.java | 19 +- .../net/osmand/plus/ContextMenuAdapter.java | 3 - .../net/osmand/plus/GpxSelectionHelper.java | 2 +- .../src/net/osmand/plus/OsmAndFormatter.java | 6 +- .../net/osmand/plus/OsmandApplication.java | 19 +- .../osmand/plus/activities/MapActivity.java | 2 +- .../plus/activities/SettingsBaseActivity.java | 3 - .../activities/SettingsGeneralActivity.java | 6 +- .../SettingsNavigationActivity.java | 11 +- .../osmand/plus/audionotes/NotesFragment.java | 1 - .../plus/audionotes/NotesSortByMode.java | 14 + .../SortByMenuBottomSheetDialogFragment.java | 1 - .../dashboard/DashChooseAppDirFragment.java | 5 +- .../plus/development/TestVoiceActivity.java | 2 +- .../osmand/plus/dialogs/ConfigureMapMenu.java | 12 +- .../plus/dialogs/DetailsBottomSheet.java | 2 +- .../osmand/plus/dialogs/RasterMapMenu.java | 6 +- .../ui/DataStoragePlaceDialogFragment.java | 5 +- .../DayNightHelper.java | 4 +- .../net/osmand/plus/helpers/GpxUiHelper.java | 43 +- .../osmand/plus/helpers/WaypointHelper.java | 13 +- .../plus/helpers/enums/AngularConstants.java | 28 + .../plus/helpers/enums/AutoZoomMap.java | 19 + .../plus/helpers/enums/DayNightMode.java | 62 ++ .../plus/helpers/enums/DrivingRegion.java | 62 ++ .../plus/helpers/enums/MetricsConstants.java | 30 + .../plus/helpers/enums/SpeedConstants.java | 33 + .../plus/helpers/enums/TracksSortByMode.java | 38 ++ .../plus/liveupdates/LiveUpdatesFragment.java | 2 +- .../MapContextMenuFragment.java | 3 +- .../builders/AmenityMenuBuilder.java | 9 +- .../DirectionIndicationDialogFragment.java | 1 - .../plus/mapmarkers/MapMarkersMode.java | 37 ++ .../OptionsBottomSheetDialogFragment.java | 3 +- .../SelectFileBottomSheet.java | 2 +- .../plus/myplaces/AvailableGPXFragment.java | 2 +- .../TrackActivityFragmentAdapter.java | 2 - .../parkingpoint/ParkingPositionPlugin.java | 6 - .../actions/DayNightModeAction.java | 7 +- .../LayerTransparencySeekbarMode.java | 22 + .../plus/rastermaps/MapOverlayAction.java | 3 +- .../plus/rastermaps/MapUnderlayAction.java | 1 - .../rastermaps/OsmandRasterMapsPlugin.java | 10 +- .../MapRouteInfoMenu.java | 3 - .../osmand/plus/routing/RouteProvider.java | 3 - .../osmand/plus/routing/RoutingHelper.java | 5 +- .../BooleanAccessibilityPreference.java | 2 - .../backend/BooleanStringPreference.java | 25 + .../settings/backend/CommonPreference.java | 1 - .../backend/ListStringPreference.java | 2 - .../backend/OsmAndPreferencesDataStore.java | 2 - .../settings/backend/OsmandPreference.java | 1 - .../plus/settings/backend/OsmandSettings.java | 583 ++++-------------- .../ChangeDataStorageBottomSheet.java | 4 +- ...ecalculateRouteInDeviationBottomSheet.java | 5 +- .../fragments/DataStorageFragment.java | 3 +- .../GeneralProfileSettingsFragment.java | 31 +- .../MapDuringNavigationFragment.java | 8 +- .../fragments/RouteParametersFragment.java | 1 - .../fragments/VehicleParametersFragment.java | 4 +- .../fragments/VoiceAnnouncesFragment.java | 3 +- .../preferences/ListPreferenceEx.java | 1 - .../osmand/plus/srtmplugin/SRTMPlugin.java | 1 - .../plus/srtmplugin/TerrainFragment.java | 5 +- .../osmand/plus/srtmplugin/TerrainLayer.java | 3 +- .../osmand/plus/srtmplugin/TerrainMode.java | 6 + .../plus/track/ShowStartFinishCard.java | 3 +- .../plus/track/TrackAppearanceFragment.java | 4 +- .../osmand/plus/views/layers/GPXLayer.java | 2 +- .../plus/views/layers/MapControlsLayer.java | 5 +- .../plus/views/layers/RulerControlLayer.java | 9 +- .../osmand/plus/views/layers/RulerMode.java | 7 + .../mapwidgets/MapInfoWidgetsFactory.java | 5 +- .../mapwidgets/RouteInfoWidgetsFactory.java | 2 - .../views/mapwidgets/widgets/AlarmWidget.java | 7 +- .../views/mapwidgets/widgets/RulerWidget.java | 2 +- .../widgetstates/BearingWidgetState.java | 4 +- .../widgetstates/CompassRulerWidgetState.java | 2 +- .../widgetstates/TimeWidgetState.java | 2 +- .../voice/AbstractPrologCommandPlayer.java | 2 +- .../WikiArticleBaseDialogFragment.java | 3 +- .../plus/wikipedia/WikiArticleShowImages.java | 15 + ...pediaOptionsBottomSheetDialogFragment.java | 1 - .../WikivoyageShowPicturesDialogFragment.java | 2 +- .../WikivoyageArticleDialogFragment.java | 2 +- ...oyageOptionsBottomSheetDialogFragment.java | 2 +- 91 files changed, 703 insertions(+), 662 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/audionotes/NotesSortByMode.java rename OsmAnd/src/net/osmand/plus/{activities => helpers}/DayNightHelper.java (98%) create mode 100644 OsmAnd/src/net/osmand/plus/helpers/enums/AngularConstants.java create mode 100644 OsmAnd/src/net/osmand/plus/helpers/enums/AutoZoomMap.java create mode 100644 OsmAnd/src/net/osmand/plus/helpers/enums/DayNightMode.java create mode 100644 OsmAnd/src/net/osmand/plus/helpers/enums/DrivingRegion.java create mode 100644 OsmAnd/src/net/osmand/plus/helpers/enums/MetricsConstants.java create mode 100644 OsmAnd/src/net/osmand/plus/helpers/enums/SpeedConstants.java create mode 100644 OsmAnd/src/net/osmand/plus/helpers/enums/TracksSortByMode.java create mode 100644 OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersMode.java create mode 100644 OsmAnd/src/net/osmand/plus/rastermaps/LayerTransparencySeekbarMode.java create mode 100644 OsmAnd/src/net/osmand/plus/settings/backend/BooleanStringPreference.java create mode 100644 OsmAnd/src/net/osmand/plus/srtmplugin/TerrainMode.java create mode 100644 OsmAnd/src/net/osmand/plus/views/layers/RulerMode.java create mode 100644 OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleShowImages.java diff --git a/OsmAnd/src-google/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java b/OsmAnd/src-google/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java index c6925a5e63..5bd9f2cb23 100644 --- a/OsmAnd/src-google/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java +++ b/OsmAnd/src-google/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java @@ -23,6 +23,7 @@ import net.osmand.plus.inapp.InAppPurchases.InAppPurchase; import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; import net.osmand.plus.inapp.InAppPurchasesImpl.InAppPurchaseLiveUpdatesOldSubscription; import net.osmand.plus.inapp.util.BillingManager; +import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.util.Algorithms; @@ -407,7 +408,7 @@ public class InAppPurchaseHelperImpl extends InAppPurchaseHelper { } } } - OsmandSettings.OsmandPreference subscriptionCancelledTime = ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_TIME; + OsmandPreference subscriptionCancelledTime = ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_TIME; if (!subscribedToLiveUpdates && ctx.getSettings().LIVE_UPDATES_PURCHASED.get()) { if (subscriptionCancelledTime.get() == 0) { subscriptionCancelledTime.set(System.currentTimeMillis()); diff --git a/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java b/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java index c3d6fc193c..0f3536e5d0 100644 --- a/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java +++ b/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java @@ -31,7 +31,7 @@ import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; import net.osmand.plus.inapp.InAppPurchases.InAppSubscriptionIntroductoryInfo; import net.osmand.plus.inapp.InAppPurchasesImpl.InAppPurchaseLiveUpdatesOldSubscription; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; +import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.util.Algorithms; import java.lang.ref.WeakReference; diff --git a/OsmAnd/src/net/osmand/FileUtils.java b/OsmAnd/src/net/osmand/FileUtils.java index 65ea676356..1f9a755be5 100644 --- a/OsmAnd/src/net/osmand/FileUtils.java +++ b/OsmAnd/src/net/osmand/FileUtils.java @@ -223,6 +223,19 @@ public class FileUtils { return tempDir; } + public static boolean isWritable(File dirToTest) { + boolean isWriteable; + try { + dirToTest.mkdirs(); + File writeTestFile = File.createTempFile("osmand_", ".tmp", dirToTest); + isWriteable = writeTestFile.exists(); + writeTestFile.delete(); + } catch (IOException e) { + isWriteable = false; + } + return isWriteable; + } + public interface RenameCallback { void renamedTo(File file); } diff --git a/OsmAnd/src/net/osmand/aidl/ConnectedApp.java b/OsmAnd/src/net/osmand/aidl/ConnectedApp.java index 0d4c9bc36b..be25ab931d 100644 --- a/OsmAnd/src/net/osmand/aidl/ConnectedApp.java +++ b/OsmAnd/src/net/osmand/aidl/ConnectedApp.java @@ -22,7 +22,6 @@ import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.layers.AidlMapLayer; import net.osmand.plus.views.layers.MapInfoLayer; diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 0ae24b7c5f..78364460a7 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -28,7 +28,7 @@ import net.osmand.map.OsmandRegions.RegionTranslation; import net.osmand.map.WorldRegion; import net.osmand.osm.AbstractPoiType; import net.osmand.osm.MapPoiTypes; -import net.osmand.plus.activities.DayNightHelper; +import net.osmand.plus.helpers.DayNightHelper; import net.osmand.plus.activities.LocalIndexHelper; import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.SavingTrackHelper; diff --git a/OsmAnd/src/net/osmand/plus/AppVersionUpgradeOnInit.java b/OsmAnd/src/net/osmand/plus/AppVersionUpgradeOnInit.java index 0ab61f725a..49e354ea8b 100644 --- a/OsmAnd/src/net/osmand/plus/AppVersionUpgradeOnInit.java +++ b/OsmAnd/src/net/osmand/plus/AppVersionUpgradeOnInit.java @@ -10,6 +10,7 @@ import com.google.gson.reflect.TypeToken; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.plus.api.SettingsAPI; +import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.EnumStringPreference; import net.osmand.plus.settings.backend.OsmandPreference; @@ -18,6 +19,7 @@ import net.osmand.util.Algorithms; import java.lang.reflect.Type; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -133,7 +135,7 @@ class AppVersionUpgradeOnInit { startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_7_01).commit(); } if (prevAppVersion < VERSION_3_8_00) { - app.getSettings().migrateQuickActionStates(); + migrateQuickActionStates(); startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_8_00).commit(); } startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, lastVersion).commit(); @@ -253,6 +255,21 @@ class AppVersionUpgradeOnInit { } } + public void migrateQuickActionStates() { + String quickActionsJson = settings.getSettingsAPI().getString(settings.getGlobalPreferences(), "quick_action_new", ""); + if (!Algorithms.isEmpty(quickActionsJson)) { + Gson gson = new GsonBuilder().create(); + Type type = new TypeToken>() { + }.getType(); + HashMap quickActions = gson.fromJson(quickActionsJson, type); + if (!Algorithms.isEmpty(quickActions)) { + for (ApplicationMode mode : ApplicationMode.allPossibleValues()) { + settings.setQuickActions(quickActions, mode); + } + } + } + } + private void migrateEnumPref(EnumStringPreference enumPref, SharedPreferences sharedPreferences) { Object value = sharedPreferences.getAll().get(enumPref.getId()); if (value instanceof Integer) { diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index c076f75ee2..c6226d6615 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -38,9 +38,6 @@ import net.osmand.plus.dialogs.HelpArticleDialogFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmAndAppCustomization; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.ContextMenuItemsPreference; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; import net.osmand.plus.settings.backend.ContextMenuItemsPreference; import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.util.Algorithms; diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 7217e8af5f..923bbe646a 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -29,7 +29,7 @@ import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.routing.RouteProvider; -import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.track.GpxSplitType; import net.osmand.plus.track.GradientScaleType; import net.osmand.util.Algorithms; diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java index 2ac142d06a..b58b3eba5e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java @@ -15,9 +15,9 @@ import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiType; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.AngularConstants; -import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants; -import net.osmand.plus.settings.backend.OsmandSettings.SpeedConstants; +import net.osmand.plus.helpers.enums.AngularConstants; +import net.osmand.plus.helpers.enums.MetricsConstants; +import net.osmand.plus.helpers.enums.SpeedConstants; import net.osmand.util.Algorithms; import java.text.DateFormatSymbols; diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 43c3a17f09..1a48650a4d 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -30,6 +30,7 @@ import androidx.multidex.MultiDex; import androidx.multidex.MultiDexApplication; import net.osmand.AndroidUtils; +import net.osmand.FileUtils; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.access.AccessibilityPlugin; @@ -42,7 +43,7 @@ import net.osmand.osm.MapPoiTypes; import net.osmand.osm.io.NetworkUtils; import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.access.AccessibilityMode; -import net.osmand.plus.activities.DayNightHelper; +import net.osmand.plus.helpers.DayNightHelper; import net.osmand.plus.activities.ExitActivity; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SavingTrackHelper; @@ -56,7 +57,9 @@ import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.download.DownloadService; import net.osmand.plus.download.IndexItem; import net.osmand.plus.helpers.AvoidSpecificRoads; +import net.osmand.plus.helpers.enums.DrivingRegion; import net.osmand.plus.helpers.LockHelper; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.mapmarkers.MapMarkersDbHelper; @@ -189,7 +192,7 @@ public class OsmandApplication extends MultiDexApplication { osmandSettings.initExternalStorageDirectory(); } externalStorageDirectory = osmandSettings.getExternalStorageDirectory(); - if (!OsmandSettings.isWritable(externalStorageDirectory)) { + if (!FileUtils.isWritable(externalStorageDirectory)) { externalStorageDirectoryReadOnly = true; externalStorageDirectory = osmandSettings.getInternalAppPath(); } @@ -983,15 +986,15 @@ public class OsmandApplication extends MultiDexApplication { } public void setupDrivingRegion(WorldRegion reg) { - OsmandSettings.DrivingRegion drg = null; + DrivingRegion drg = null; WorldRegion.RegionParams params = reg.getParams(); // boolean americanSigns = "american".equals(params.getRegionRoadSigns()); boolean leftHand = "yes".equals(params.getRegionLeftHandDriving()); - OsmandSettings.MetricsConstants mc1 = "miles".equals(params.getRegionMetric()) ? - OsmandSettings.MetricsConstants.MILES_AND_FEET : OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS; - OsmandSettings.MetricsConstants mc2 = "miles".equals(params.getRegionMetric()) ? - OsmandSettings.MetricsConstants.MILES_AND_METERS : OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS; - for (OsmandSettings.DrivingRegion r : OsmandSettings.DrivingRegion.values()) { + MetricsConstants mc1 = "miles".equals(params.getRegionMetric()) ? + MetricsConstants.MILES_AND_FEET : MetricsConstants.KILOMETERS_AND_METERS; + MetricsConstants mc2 = "miles".equals(params.getRegionMetric()) ? + MetricsConstants.MILES_AND_METERS : MetricsConstants.KILOMETERS_AND_METERS; + for (DrivingRegion r : DrivingRegion.values()) { if (r.leftHandDriving == leftHand && (r.defMetrics == mc1 || r.defMetrics == mc2)) { drg = r; break; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 8533c9c463..083c95d279 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -74,6 +74,7 @@ import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndLocationSimulation; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.helpers.DayNightHelper; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; @@ -132,7 +133,6 @@ import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab; import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; import net.osmand.plus.settings.fragments.ConfigureProfileFragment; diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java index 58f0b57029..316de777b0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java @@ -32,9 +32,6 @@ import net.osmand.plus.R; import net.osmand.plus.profiles.AppProfileArrayAdapter; import net.osmand.plus.profiles.ProfileDataObject; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; import org.apache.commons.logging.Log; diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index aaf206ca06..225384349c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -42,9 +42,9 @@ import net.osmand.osm.io.NetworkUtils; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmandApplication; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.AngularConstants; -import net.osmand.plus.settings.backend.OsmandSettings.DrivingRegion; -import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants; +import net.osmand.plus.helpers.enums.AngularConstants; +import net.osmand.plus.helpers.enums.DrivingRegion; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.base.MapViewTrackingUtilities; diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index 89c0806d0a..a0a5c74992 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -34,11 +34,12 @@ import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuItem; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.AutoZoomMap; +import net.osmand.plus.helpers.enums.AutoZoomMap; import net.osmand.plus.settings.backend.OsmandPreference; -import net.osmand.plus.settings.backend.OsmandSettings.SpeedConstants; +import net.osmand.plus.helpers.enums.SpeedConstants; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.Version; @@ -49,10 +50,6 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper; import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.AutoZoomMap; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; -import net.osmand.plus.settings.backend.OsmandSettings.SpeedConstants; import net.osmand.plus.voice.CommandPlayer; import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter.GeneralRouterProfile; @@ -176,7 +173,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { //array size must be equal! Float[] speedLimitsKmhPos = new Float[]{0f, 5f, 7f, 10f, 15f, 20f}; Float[] speedLimitsMphPos = new Float[]{0f, 3f, 5f, 7f, 10f, 15f}; - if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) { + if (settings.METRIC_SYSTEM.get() == MetricsConstants.KILOMETERS_AND_METERS) { String[] speedNames = new String[speedLimitsKmh.length]; String[] speedNamesPos = new String[speedLimitsKmhPos.length]; for (int i = 0; i < speedLimitsKmh.length; i++) { diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java index 09acdca8d8..8e911b04fc 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java @@ -38,7 +38,6 @@ import net.osmand.PlatformUtil; import net.osmand.data.PointDescription; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.settings.backend.OsmandSettings.NotesSortByMode; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.activities.ActionBarProgressActivity; diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesSortByMode.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesSortByMode.java new file mode 100644 index 0000000000..cf791dbf26 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesSortByMode.java @@ -0,0 +1,14 @@ +package net.osmand.plus.audionotes; + +public enum NotesSortByMode { + BY_TYPE, + BY_DATE; + + public boolean isByType() { + return this == BY_TYPE; + } + + public boolean isByDate() { + return this == BY_DATE; + } +} diff --git a/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java index 2e228874b0..06fa83f6ca 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java @@ -4,7 +4,6 @@ import android.os.Bundle; import android.view.View; import net.osmand.plus.settings.backend.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.NotesSortByMode; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java index 9f37cd1b41..883010ea46 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java @@ -30,6 +30,7 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import net.osmand.AndroidUtils; +import net.osmand.FileUtils; import net.osmand.ValueHolder; import net.osmand.plus.OsmandApplication; import net.osmand.plus.settings.backend.OsmandSettings; @@ -113,7 +114,7 @@ public class DashChooseAppDirFragment { boolean copyFiles = !currentAppFile.getAbsolutePath().equals(selectedFile.getAbsolutePath()) && !mapsCopied; warningReadonly.setVisibility(copyFiles ? View.VISIBLE : View.GONE); if (copyFiles) { - if (!OsmandSettings.isWritable(currentAppFile)) { + if (!FileUtils.isWritable(currentAppFile)) { warningReadonly.setText(activity.getString(R.string.android_19_location_disabled, currentAppFile.getAbsolutePath())); } else { @@ -385,7 +386,7 @@ public class DashChooseAppDirFragment { @Override public void onClick(View v) { - boolean wr = OsmandSettings.isWritable(selectedFile); + boolean wr = FileUtils.isWritable(selectedFile); if (wr) { boolean changed = !currentAppFile.getAbsolutePath().equals(selectedFile.getAbsolutePath()); getMyApplication().setExternalStorageDirectory(type, selectedFile.getAbsolutePath()); diff --git a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java index 2e4dfc3dfb..a9a0ba563e 100644 --- a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java @@ -151,7 +151,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity { v += "\n \u25CF BT SCO: The current app profile is not set to use 'Phone call audio'."; } - //OsmandSettings.OsmandPreference pref = ((OsmandApplication) getApplication()).getSettings().VOICE_PROMPT_DELAY[stream]; + //OsmandPreference pref = ((OsmandApplication) getApplication()).getSettings().VOICE_PROMPT_DELAY[stream]; //if(pref != null) { // v += "\n \u25CF Voice prompt delay for selected output: " + pref.get() + "\u00A0ms"; //} diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 97534b5bdf..1c01808be8 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -33,6 +33,7 @@ import net.osmand.plus.ContextMenuItem; import net.osmand.plus.DialogListItemAdapter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.helpers.enums.DayNightMode; import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.CommonPreference; @@ -44,9 +45,6 @@ import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.render.RendererRegistry; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.ListStringPreference; import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.transport.TransportLinesMenu; import net.osmand.plus.views.OsmandMapTileView; @@ -311,7 +309,7 @@ public class ConfigureMapMenu { DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.SHORT); String sunriseTime = dateFormat.format(sunriseSunset.getSunrise()); String sunsetTime = dateFormat.format(sunriseSunset.getSunset()); - OsmandSettings.DayNightMode dayNightMode = activity.getMyApplication().getSettings().DAYNIGHT_MODE.get(); + DayNightMode dayNightMode = activity.getMyApplication().getSettings().DAYNIGHT_MODE.get(); if (dayNightMode.isDay() || dayNightMode.isNight()) { if (sunriseSunset.isDaytime()) { description = String.format(app.getString(R.string.sunset_at), sunsetTime); @@ -338,9 +336,9 @@ public class ConfigureMapMenu { final OsmandMapTileView view = activity.getMapView(); AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes)); bld.setTitle(R.string.daynight); - final String[] items = new String[OsmandSettings.DayNightMode.values().length]; + final String[] items = new String[DayNightMode.values().length]; for (int i = 0; i < items.length; i++) { - items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(app); + items[i] = DayNightMode.values()[i].toHumanString(app); } int i = view.getSettings().DAYNIGHT_MODE.get().ordinal(); bld.setNegativeButton(R.string.shared_string_dismiss, null); @@ -349,7 +347,7 @@ public class ConfigureMapMenu { @Override public void onClick(View v) { int which = (int) v.getTag(); - view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]); + view.getSettings().DAYNIGHT_MODE.set(DayNightMode.values()[which]); refreshMapComplete(activity); activity.getDashboard().refreshContent(true); // adapter.getItem(pos).setDescription(s, getDayNightDescr(activity)); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java index 4e8febb56e..ecb8f04b86 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java @@ -27,7 +27,7 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemTwoChoicesButton.OnBo import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; import net.osmand.plus.helpers.FontCache; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; +import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.bottomsheets.BasePreferenceBottomSheet; import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleStorageProperties; diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java index e5414bd0b4..8219cc5a23 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java @@ -12,7 +12,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode; +import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityLayers; @@ -182,8 +182,8 @@ public class RasterMapMenu { @NonNull public static Boolean isSeekbarVisible(OsmandApplication app, RasterMapType type) { - final OsmandSettings.LayerTransparencySeekbarMode currentMapTypeSeekbarMode = - type == RasterMapType.OVERLAY ? OsmandSettings.LayerTransparencySeekbarMode.OVERLAY : OsmandSettings.LayerTransparencySeekbarMode.UNDERLAY; + final LayerTransparencySeekbarMode currentMapTypeSeekbarMode = + type == RasterMapType.OVERLAY ? LayerTransparencySeekbarMode.OVERLAY : LayerTransparencySeekbarMode.UNDERLAY; LayerTransparencySeekbarMode seekbarMode = app.getSettings().LAYER_TRANSPARENCY_SEEKBAR_MODE.get(); return seekbarMode == LayerTransparencySeekbarMode.UNDEFINED || seekbarMode == currentMapTypeSeekbarMode; } diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java index dceeac1862..f97784cb36 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java @@ -21,6 +21,7 @@ import androidx.annotation.NonNull; import androidx.fragment.app.FragmentManager; import net.osmand.AndroidUtils; +import net.osmand.FileUtils; import net.osmand.IProgress; import net.osmand.plus.OnDismissDialogFragmentListener; import net.osmand.plus.OsmandApplication; @@ -71,7 +72,7 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment { File internalStorage = getInternalStorageDirectory(activity); File external1Storage = getExternal1StorageDirectory(activity); - if (external1Storage != null && external1Storage.exists() && OsmandSettings.isWritable(external1Storage)) { + if (external1Storage != null && external1Storage.exists() && FileUtils.isWritable(external1Storage)) { deviceStorage = external1Storage; deviceStorageType = OsmandSettings.EXTERNAL_STORAGE_TYPE_EXTERNAL_FILE; deviceStorageName = getString(R.string.storage_directory_external); @@ -246,7 +247,7 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment { }; public boolean saveFilesLocation(int type, File selectedFile, Activity context) { - boolean wr = OsmandSettings.isWritable(selectedFile); + boolean wr = FileUtils.isWritable(selectedFile); if (wr) { ((OsmandApplication) context.getApplication()) .setExternalStorageDirectory(type, selectedFile.getAbsolutePath()); diff --git a/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DayNightHelper.java similarity index 98% rename from OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java rename to OsmAnd/src/net/osmand/plus/helpers/DayNightHelper.java index f9ca2afca4..ea4f6a1ae7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/DayNightHelper.java @@ -1,4 +1,4 @@ -package net.osmand.plus.activities; +package net.osmand.plus.helpers; import java.util.Date; @@ -8,9 +8,9 @@ import java.util.TimeZone; import net.osmand.Location; import net.osmand.PlatformUtil; import net.osmand.StateChangedListener; +import net.osmand.plus.helpers.enums.DayNightMode; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings.DayNightMode; import net.osmand.util.SunriseSunset; import org.apache.commons.logging.Log; diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 2305d1beec..47650dc2ec 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -80,6 +80,8 @@ import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.helpers.enums.MetricsConstants; +import net.osmand.plus.helpers.enums.SpeedConstants; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; @@ -95,7 +97,6 @@ import net.osmand.plus.dialogs.GpxAppearanceAdapter; import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.routing.RouteCalculationResult; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRulesStorage; import net.osmand.router.RouteStatisticsHelper; @@ -1041,7 +1042,7 @@ public class GpxUiHelper { private static float setupAxisDistance(OsmandApplication ctx, AxisBase axisBase, float meters) { OsmandSettings settings = ctx.getSettings(); - OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get(); + MetricsConstants mc = settings.METRIC_SYSTEM.get(); float divX; String format1 = "{0,number,0.#} "; @@ -1050,10 +1051,10 @@ public class GpxUiHelper { float granularity = 1f; int mainUnitStr; float mainUnitInMeters; - if (mc == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) { + if (mc == MetricsConstants.KILOMETERS_AND_METERS) { mainUnitStr = R.string.km; mainUnitInMeters = METERS_IN_KILOMETER; - } else if (mc == OsmandSettings.MetricsConstants.NAUTICAL_MILES) { + } else if (mc == MetricsConstants.NAUTICAL_MILES) { mainUnitStr = R.string.nm; mainUnitInMeters = METERS_IN_ONE_NAUTICALMILE; } else { @@ -1067,10 +1068,10 @@ public class GpxUiHelper { if (meters >= 100 * mainUnitInMeters || meters > 9.99f * mainUnitInMeters || meters > 0.999f * mainUnitInMeters || - mc == OsmandSettings.MetricsConstants.MILES_AND_FEET && meters > 0.249f * mainUnitInMeters || - mc == OsmandSettings.MetricsConstants.MILES_AND_METERS && meters > 0.249f * mainUnitInMeters || - mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS && meters > 0.249f * mainUnitInMeters || - mc == OsmandSettings.MetricsConstants.NAUTICAL_MILES && meters > 0.99f * mainUnitInMeters) { + mc == MetricsConstants.MILES_AND_FEET && meters > 0.249f * mainUnitInMeters || + mc == MetricsConstants.MILES_AND_METERS && meters > 0.249f * mainUnitInMeters || + mc == MetricsConstants.MILES_AND_YARDS && meters > 0.249f * mainUnitInMeters || + mc == MetricsConstants.NAUTICAL_MILES && meters > 0.99f * mainUnitInMeters) { divX = mainUnitInMeters; if (fmt == null) { @@ -1080,13 +1081,13 @@ public class GpxUiHelper { } else { fmt = null; granularity = 1f; - if (mc == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS || mc == OsmandSettings.MetricsConstants.MILES_AND_METERS) { + if (mc == MetricsConstants.KILOMETERS_AND_METERS || mc == MetricsConstants.MILES_AND_METERS) { divX = 1f; mainUnitStr = R.string.m; - } else if (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) { + } else if (mc == MetricsConstants.MILES_AND_FEET) { divX = 1f / FEET_IN_ONE_METER; mainUnitStr = R.string.foot; - } else if (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS) { + } else if (mc == MetricsConstants.MILES_AND_YARDS) { divX = 1f / YARDS_IN_ONE_METER; mainUnitStr = R.string.yard; } else { @@ -1308,8 +1309,8 @@ public class GpxUiHelper { boolean drawFilled, boolean calcWithoutGaps) { OsmandSettings settings = ctx.getSettings(); - OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get(); - boolean useFeet = (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) || (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS); + MetricsConstants mc = settings.METRIC_SYSTEM.get(); + boolean useFeet = (mc == MetricsConstants.MILES_AND_FEET) || (mc == MetricsConstants.MILES_AND_YARDS); boolean light = settings.isLightContent(); final float convEle = useFeet ? 3.28084f : 1.0f; @@ -1410,19 +1411,19 @@ public class GpxUiHelper { divX = setupAxisDistance(ctx, xAxis, calcWithoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance); } - OsmandSettings.SpeedConstants sps = settings.SPEED_SYSTEM.get(); + SpeedConstants sps = settings.SPEED_SYSTEM.get(); float mulSpeed = Float.NaN; float divSpeed = Float.NaN; final String mainUnitY = sps.toShortString(ctx); - if (sps == OsmandSettings.SpeedConstants.KILOMETERS_PER_HOUR) { + if (sps == SpeedConstants.KILOMETERS_PER_HOUR) { mulSpeed = 3.6f; - } else if (sps == OsmandSettings.SpeedConstants.MILES_PER_HOUR) { + } else if (sps == SpeedConstants.MILES_PER_HOUR) { mulSpeed = 3.6f * METERS_IN_KILOMETER / METERS_IN_ONE_MILE; - } else if (sps == OsmandSettings.SpeedConstants.NAUTICALMILES_PER_HOUR) { + } else if (sps == SpeedConstants.NAUTICALMILES_PER_HOUR) { mulSpeed = 3.6f * METERS_IN_KILOMETER / METERS_IN_ONE_NAUTICALMILE; - } else if (sps == OsmandSettings.SpeedConstants.MINUTES_PER_KILOMETER) { + } else if (sps == SpeedConstants.MINUTES_PER_KILOMETER) { divSpeed = METERS_IN_KILOMETER / 60; - } else if (sps == OsmandSettings.SpeedConstants.MINUTES_PER_MILE) { + } else if (sps == SpeedConstants.MINUTES_PER_MILE) { divSpeed = METERS_IN_ONE_MILE / 60; } else { mulSpeed = 1f; @@ -1573,8 +1574,8 @@ public class GpxUiHelper { } OsmandSettings settings = ctx.getSettings(); boolean light = settings.isLightContent(); - OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get(); - boolean useFeet = (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) || (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS); + MetricsConstants mc = settings.METRIC_SYSTEM.get(); + boolean useFeet = (mc == MetricsConstants.MILES_AND_FEET) || (mc == MetricsConstants.MILES_AND_YARDS); final float convEle = useFeet ? 3.28084f : 1.0f; final float totalDistance = calcWithoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java index b143653754..7f20de3e60 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java @@ -24,6 +24,9 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.IntermediatePointsDialog; import net.osmand.plus.base.PointImageDrawable; +import net.osmand.plus.helpers.enums.DrivingRegion; +import net.osmand.plus.helpers.enums.MetricsConstants; +import net.osmand.plus.helpers.enums.SpeedConstants; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.routing.AlarmInfo; @@ -31,8 +34,6 @@ import net.osmand.plus.routing.AlarmInfo.AlarmInfoType; import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.VoiceRouter; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants; import net.osmand.util.MapUtils; import java.util.ArrayList; @@ -193,7 +194,7 @@ public class WaypointHelper { return found; } - public AlarmInfo getMostImportantAlarm(OsmandSettings.SpeedConstants sc, boolean showCameras) { + public AlarmInfo getMostImportantAlarm(SpeedConstants sc, boolean showCameras) { Location lastProjection = app.getRoutingHelper().getLastProjection(); float mxspeed = route.getCurrentMaxSpeed(); float delta = app.getSettings().SPEED_LIMIT_EXCEED_KMH.get() / 3.6f; @@ -291,7 +292,7 @@ public class WaypointHelper { } public AlarmInfo calculateMostImportantAlarm(RouteDataObject ro, Location loc, MetricsConstants mc, - OsmandSettings.SpeedConstants sc, boolean showCameras) { + SpeedConstants sc, boolean showCameras) { float mxspeed = ro.getMaximumSpeed(ro.bearingVsRouteDirection(loc)); float delta = app.getSettings().SPEED_LIMIT_EXCEED_KMH.get() / 3.6f; AlarmInfo speedAlarm = createSpeedAlarm(sc, mxspeed, loc, delta); @@ -331,7 +332,7 @@ public class WaypointHelper { return null; } - private static AlarmInfo createSpeedAlarm(OsmandSettings.SpeedConstants sc, float mxspeed, Location loc, float delta) { + private static AlarmInfo createSpeedAlarm(SpeedConstants sc, float mxspeed, Location loc, float delta) { AlarmInfo speedAlarm = null; if (mxspeed != 0 && loc != null && loc.hasSpeed() && mxspeed != RouteDataObject.NONE_MAX_SPEED) { if (loc.getSpeed() > mxspeed + delta) { @@ -790,7 +791,7 @@ public class WaypointHelper { } else if (type == ALARMS) { //assign alarm list icons manually for now String typeString = ((AlarmInfo) point).getType().toString(); - OsmandSettings.DrivingRegion region = app.getSettings().DRIVING_REGION.get(); + DrivingRegion region = app.getSettings().DRIVING_REGION.get(); if (typeString.equals("SPEED_CAMERA")) { return AppCompatResources.getDrawable(uiCtx, R.drawable.mx_highway_speed_camera); } else if (typeString.equals("BORDER_CONTROL")) { diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/AngularConstants.java b/OsmAnd/src/net/osmand/plus/helpers/enums/AngularConstants.java new file mode 100644 index 0000000000..9962144fa4 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/helpers/enums/AngularConstants.java @@ -0,0 +1,28 @@ +package net.osmand.plus.helpers.enums; + +import android.content.Context; + +import net.osmand.plus.R; + +public enum AngularConstants { + DEGREES(R.string.shared_string_degrees, "°"), + DEGREES360(R.string.shared_string_degrees, "°"), + MILLIRADS(R.string.shared_string_milliradians, "mil"); + + private final int key; + private final String unit; + + AngularConstants(int key, String unit) { + this.key = key; + this.unit = unit; + } + + public String toHumanString(Context ctx) { + return ctx.getString(key); + } + + public String getUnitSymbol() { + return unit; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/AutoZoomMap.java b/OsmAnd/src/net/osmand/plus/helpers/enums/AutoZoomMap.java new file mode 100644 index 0000000000..f092c19be7 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/helpers/enums/AutoZoomMap.java @@ -0,0 +1,19 @@ +package net.osmand.plus.helpers.enums; + +import net.osmand.plus.R; + +public enum AutoZoomMap { + FARTHEST(R.string.auto_zoom_farthest, 1f, 15.5f), + FAR(R.string.auto_zoom_far, 1.4f, 17f), + CLOSE(R.string.auto_zoom_close, 2f, 19f); + public final float coefficient; + public final int name; + public final float maxZoom; + + AutoZoomMap(int name, float coefficient, float maxZoom) { + this.name = name; + this.coefficient = coefficient; + this.maxZoom = maxZoom; + + } +} diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/DayNightMode.java b/OsmAnd/src/net/osmand/plus/helpers/enums/DayNightMode.java new file mode 100644 index 0000000000..9c8865e877 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/helpers/enums/DayNightMode.java @@ -0,0 +1,62 @@ +package net.osmand.plus.helpers.enums; + +import android.content.Context; +import android.hardware.Sensor; +import android.hardware.SensorManager; + +import androidx.annotation.DrawableRes; +import androidx.annotation.StringRes; + +import net.osmand.plus.R; + +public enum DayNightMode { + AUTO(R.string.daynight_mode_auto, R.drawable.ic_action_map_sunset), + DAY(R.string.daynight_mode_day, R.drawable.ic_action_map_day), + NIGHT(R.string.daynight_mode_night, R.drawable.ic_action_map_night), + SENSOR(R.string.daynight_mode_sensor, R.drawable.ic_action_map_light_sensor); + + private final int key; + @DrawableRes + private final int drawableRes; + + DayNightMode(@StringRes int key, @DrawableRes int drawableRes) { + this.key = key; + this.drawableRes = drawableRes; + } + + public String toHumanString(Context ctx) { + return ctx.getString(key); + } + + @DrawableRes + public int getIconRes() { + return drawableRes; + } + + public boolean isSensor() { + return this == SENSOR; + } + + public boolean isAuto() { + return this == AUTO; + } + + public boolean isDay() { + return this == DAY; + } + + public boolean isNight() { + return this == NIGHT; + } + + public static DayNightMode[] possibleValues(Context context) { + SensorManager mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); + Sensor mLight = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); + boolean isLightSensorEnabled = mLight != null; + if (isLightSensorEnabled) { + return DayNightMode.values(); + } else { + return new DayNightMode[]{AUTO, DAY, NIGHT}; + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/DrivingRegion.java b/OsmAnd/src/net/osmand/plus/helpers/enums/DrivingRegion.java new file mode 100644 index 0000000000..70c825926e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/helpers/enums/DrivingRegion.java @@ -0,0 +1,62 @@ +package net.osmand.plus.helpers.enums; + +import android.content.Context; + +import net.osmand.plus.R; + +import java.util.Locale; + +/** + * Class represents specific for driving region + * Signs, leftHandDriving + */ +public enum DrivingRegion { + + EUROPE_ASIA(R.string.driving_region_europe_asia, MetricsConstants.KILOMETERS_AND_METERS, false), + US(R.string.driving_region_us, MetricsConstants.MILES_AND_FEET, false), + CANADA(R.string.driving_region_canada, MetricsConstants.KILOMETERS_AND_METERS, false), + UK_AND_OTHERS(R.string.driving_region_uk, MetricsConstants.MILES_AND_METERS, true), + JAPAN(R.string.driving_region_japan, MetricsConstants.KILOMETERS_AND_METERS, true), + AUSTRALIA(R.string.driving_region_australia, MetricsConstants.KILOMETERS_AND_METERS, true); + + public final boolean leftHandDriving; + public final MetricsConstants defMetrics; + public final int name; + + DrivingRegion(int name, MetricsConstants def, boolean leftHandDriving) { + this.name = name; + defMetrics = def; + this.leftHandDriving = leftHandDriving; + } + + public boolean isAmericanTypeSigns() { + return this == DrivingRegion.AUSTRALIA || + this == DrivingRegion.US || + this == DrivingRegion.CANADA; + } + + public String getDescription(Context ctx) { + return ctx.getString(leftHandDriving ? R.string.left_side_navigation : R.string.right_side_navigation) + + ", " + + defMetrics.toHumanString(ctx).toLowerCase(); + } + + public static DrivingRegion getDrivingRegionByLocale() { + Locale df = Locale.getDefault(); + if (df == null) { + return DrivingRegion.EUROPE_ASIA; + } + if (df.getCountry().equalsIgnoreCase(Locale.US.getCountry())) { + return DrivingRegion.US; + } else if (df.getCountry().equalsIgnoreCase(Locale.CANADA.getCountry())) { + return DrivingRegion.CANADA; + } else if (df.getCountry().equalsIgnoreCase(Locale.JAPAN.getCountry())) { + return DrivingRegion.JAPAN; + } else if (df.getCountry().equalsIgnoreCase("au")) { + return DrivingRegion.AUSTRALIA; + } else if(df.getCountry().equalsIgnoreCase(Locale.UK.getCountry())) { + return DrivingRegion.UK_AND_OTHERS; + } + return DrivingRegion.EUROPE_ASIA; + } +} diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/MetricsConstants.java b/OsmAnd/src/net/osmand/plus/helpers/enums/MetricsConstants.java new file mode 100644 index 0000000000..23034b5277 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/helpers/enums/MetricsConstants.java @@ -0,0 +1,30 @@ +package net.osmand.plus.helpers.enums; + +import android.content.Context; + +import net.osmand.plus.R; + +public enum MetricsConstants { + KILOMETERS_AND_METERS(R.string.si_km_m, "km-m"), + MILES_AND_FEET(R.string.si_mi_feet, "mi-f"), + MILES_AND_METERS(R.string.si_mi_meters, "mi-m"), + MILES_AND_YARDS(R.string.si_mi_yard, "mi-y"), + NAUTICAL_MILES(R.string.si_nm, "nm"); + + private final int key; + private final String ttsString; + + MetricsConstants(int key, String ttsString) { + this.key = key; + this.ttsString = ttsString; + } + + public String toHumanString(Context ctx) { + return ctx.getString(key); + } + + public String toTTSString() { + return ttsString; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/SpeedConstants.java b/OsmAnd/src/net/osmand/plus/helpers/enums/SpeedConstants.java new file mode 100644 index 0000000000..15a54513eb --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/helpers/enums/SpeedConstants.java @@ -0,0 +1,33 @@ +package net.osmand.plus.helpers.enums; + +import android.content.Context; + +import net.osmand.plus.R; + +public enum SpeedConstants { + KILOMETERS_PER_HOUR(R.string.km_h, R.string.si_kmh, false), + MILES_PER_HOUR(R.string.mile_per_hour, R.string.si_mph, true), + METERS_PER_SECOND(R.string.m_s, R.string.si_m_s, false), + MINUTES_PER_MILE(R.string.min_mile, R.string.si_min_m, true), + MINUTES_PER_KILOMETER(R.string.min_km, R.string.si_min_km, false), + NAUTICALMILES_PER_HOUR(R.string.nm_h, R.string.si_nm_h, true); + + public final int key; + public final int descr; + public final boolean imperial; + + SpeedConstants(int key, int descr, boolean imperial) { + this.key = key; + this.descr = descr; + this.imperial = imperial; + } + + public String toHumanString(Context ctx) { + return ctx.getString(descr); + } + + public String toShortString(Context ctx) { + return ctx.getString(key); + } + +} diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/TracksSortByMode.java b/OsmAnd/src/net/osmand/plus/helpers/enums/TracksSortByMode.java new file mode 100644 index 0000000000..6b4177c701 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/helpers/enums/TracksSortByMode.java @@ -0,0 +1,38 @@ +package net.osmand.plus.helpers.enums; + +import androidx.annotation.DrawableRes; +import androidx.annotation.StringRes; + +import net.osmand.plus.R; + +public enum TracksSortByMode { + BY_DATE(R.string.sort_last_modified, R.drawable.ic_action_time_start), + BY_NAME_ASCENDING(R.string.sort_name_ascending, R.drawable.ic_action_sort_by_name_ascending), + BY_NAME_DESCENDING(R.string.sort_name_descending, R.drawable.ic_action_sort_by_name_descending); + + private final int iconId; + private final int nameId; + + TracksSortByMode(int nameId, int iconId) { + this.nameId = nameId; + this.iconId = iconId; + } + + public boolean isByName() { + return this == BY_NAME_ASCENDING || this == BY_NAME_DESCENDING; + } + + public boolean isByDate() { + return this == BY_DATE; + } + + @StringRes + public int getNameId() { + return nameId; + } + + @DrawableRes + public int getIconId() { + return iconId; + } +} diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index f7c5f8bc59..c503162910 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -314,7 +314,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc public void add(LocalIndexInfo info) { CommonPreference preference = preferenceLiveUpdatesOn( - info.getFileName(), getSettings()); + info.getFileName(), app.getSettings()); if (preference.get()) { dataShouldUpdate.add(info); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 27dd2c89c3..7977a9ddc6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -76,7 +76,6 @@ import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; import net.osmand.plus.routepreparationmenu.ChooseRouteFragment; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmandMapTileView; @@ -644,7 +643,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo // Action buttons ContextMenuAdapter adapter = menu.getActionsContextMenuAdapter(false); List items = adapter.getVisibleItems(); - List mainIds = ((OsmandSettings.MainContextMenuItemsSettings) mapActivity.getMyApplication() + List mainIds = ((MainContextMenuItemsSettings) mapActivity.getMyApplication() .getSettings().CONTEXT_MENU_ACTIONS_ITEMS.get()).getMainIds(); ContextMenuAdapter mainAdapter = new ContextMenuAdapter(requireMyApplication()); ContextMenuAdapter additionalAdapter = new ContextMenuAdapter(requireMyApplication()); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 5a4618ca4f..f0d33b68dd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -36,8 +36,7 @@ import net.osmand.plus.mapcontextmenu.CollapsableView; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.poi.PoiUIFilter; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.views.layers.POIMapLayer; import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.widgets.tools.ClickableSpanTouchListener; @@ -70,7 +69,7 @@ public class AmenityMenuBuilder extends MenuBuilder { private static final String WIKI_LINK = ".wikipedia.org/w"; public final static Log LOG = PlatformUtil.getLog(AmenityMenuBuilder.class); private final static DecimalFormat DF = new DecimalFormat("#.##"); - private OsmandSettings.MetricsConstants metricSystem; + private MetricsConstants metricSystem; private final Amenity amenity; @@ -714,10 +713,10 @@ public class AmenityMenuBuilder extends MenuBuilder { case "seamark_height": if (Algorithms.isFloat(value)) { double valueAsDouble = Double.valueOf(value); - if (metricSystem == OsmandSettings.MetricsConstants.MILES_AND_FEET) { + if (metricSystem == MetricsConstants.MILES_AND_FEET) { formattedValue = String.valueOf(DF.format(valueAsDouble * OsmAndFormatter.FEET_IN_ONE_METER)) + " " + mapActivity.getResources().getString(R.string.foot); - } else if (metricSystem == OsmandSettings.MetricsConstants.MILES_AND_YARDS) { + } else if (metricSystem == MetricsConstants.MILES_AND_YARDS) { formattedValue = String.valueOf(DF.format(valueAsDouble * OsmAndFormatter.YARDS_IN_ONE_METER)) + " " + mapActivity.getResources().getString(R.string.yard); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java index c82230a464..d624ec7947 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java @@ -32,7 +32,6 @@ import com.github.ksoichiro.android.observablescrollview.ScrollState; import net.osmand.AndroidUtils; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.MapMarkersMode; import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersMode.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersMode.java new file mode 100644 index 0000000000..840da1ad92 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersMode.java @@ -0,0 +1,37 @@ +package net.osmand.plus.mapmarkers; + +import android.content.Context; + +import net.osmand.plus.R; + +public enum MapMarkersMode { + TOOLBAR(R.string.shared_string_topbar), + WIDGETS(R.string.shared_string_widgets), + NONE(R.string.shared_string_none); + + private final int key; + + MapMarkersMode(int key) { + this.key = key; + } + + public String toHumanString(Context ctx) { + return ctx.getString(key); + } + + public boolean isToolbar() { + return this == TOOLBAR; + } + + public boolean isWidgets() { + return this == WIDGETS; + } + + public boolean isNone() { + return this == NONE; + } + + public static MapMarkersMode[] possibleValues(Context context) { + return new MapMarkersMode[]{TOOLBAR, WIDGETS, NONE}; + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java index 487ee2073c..4627ed764b 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java @@ -14,7 +14,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import net.osmand.AndroidUtils; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.helpers.AndroidUiHelper; @@ -63,7 +62,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment } ((ImageView) mainView.findViewById(R.id.sort_by_icon)).setImageDrawable(getContentIcon(R.drawable.ic_sort_waypoint_dark)); - OsmandSettings.MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get(); + MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get(); int displayedCount = getMyApplication().getSettings().DISPLAYED_MARKERS_WIDGETS_COUNT.get(); ImageView showDirectionIcon = (ImageView) mainView.findViewById(R.id.show_direction_icon); int imageResId = 0; diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java b/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java index 24d3ec8282..c155ec493c 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java @@ -25,6 +25,7 @@ import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.helpers.GpxTrackAdapter; import net.osmand.plus.helpers.GpxTrackAdapter.OnItemClickListener; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.helpers.enums.TracksSortByMode; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener; @@ -38,7 +39,6 @@ import java.util.Map; import static net.osmand.plus.SimplePopUpMenuItemAdapter.*; import static net.osmand.plus.helpers.GpxUiHelper.getSortedGPXFilesInfo; -import static net.osmand.plus.settings.backend.OsmandSettings.*; import static net.osmand.util.Algorithms.collectDirs; public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index fae190ea01..31cb5375fe 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -84,7 +84,7 @@ import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.TracksSortByMode; +import net.osmand.plus.helpers.enums.TracksSortByMode; import java.io.File; import java.text.DateFormat; diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java index f99046de4d..4451354fc8 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java @@ -58,8 +58,6 @@ import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.dialogs.GpxAppearanceAdapter; import net.osmand.plus.measurementtool.GpxData; import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; import net.osmand.plus.track.GpxSplitType; import net.osmand.plus.track.SplitTrackAsyncTask; import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener; diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index bc0ff794c5..d131721376 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -7,7 +7,6 @@ import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.text.format.DateFormat; -import android.text.format.Time; import android.view.View; import android.widget.ArrayAdapter; import android.widget.CheckBox; @@ -36,20 +35,15 @@ import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.layers.MapInfoLayer; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; -import java.util.Date; import java.util.List; -import java.util.Locale; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MARK_AS_PARKING_LOC; diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java index 0be5c0f715..8314341371 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java @@ -6,8 +6,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.DayNightMode; +import net.osmand.plus.helpers.enums.DayNightMode; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.quickaction.QuickAction; @@ -27,9 +26,9 @@ public class DayNightModeAction extends QuickAction { @Override public void execute(MapActivity activity) { if (activity.getMyApplication().getDaynightHelper().isNightMode()) { - activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY); + activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(DayNightMode.DAY); } else { - activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.NIGHT); + activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(DayNightMode.NIGHT); } } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/LayerTransparencySeekbarMode.java b/OsmAnd/src/net/osmand/plus/rastermaps/LayerTransparencySeekbarMode.java new file mode 100644 index 0000000000..1fd8b2f91d --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/rastermaps/LayerTransparencySeekbarMode.java @@ -0,0 +1,22 @@ +package net.osmand.plus.rastermaps; + +import android.content.Context; + +import net.osmand.plus.R; + +public enum LayerTransparencySeekbarMode { + OVERLAY(R.string.overlay_transparency), + UNDERLAY(R.string.map_transparency), + OFF(R.string.shared_string_off), + UNDEFINED(R.string.shared_string_none); + + private final int key; + + LayerTransparencySeekbarMode(int key) { + this.key = key; + } + + public String toHumanString(Context ctx) { + return ctx.getString(key); + } +} diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java index 575196f8a2..7972b264aa 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java @@ -16,7 +16,6 @@ import com.google.gson.reflect.TypeToken; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; @@ -137,7 +136,7 @@ public class MapOverlayAction extends SwitchableAction> { if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.UNDEFINED) { settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(LayerTransparencySeekbarMode.OVERLAY); } - if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == OsmandSettings.LayerTransparencySeekbarMode.OVERLAY) { + if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.OVERLAY) { activity.getMapLayers().getMapControlsLayer().showTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY, true); } } else { diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java index d938174c1f..ca79cb4895 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java @@ -17,7 +17,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index 5d79637b1a..942a34cbf1 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -31,7 +31,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.activities.DownloadTilesDialog; @@ -41,9 +40,6 @@ import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; import net.osmand.plus.dialogs.RasterMapMenu; import net.osmand.plus.quickaction.QuickActionType; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode; import net.osmand.plus.views.MapTileLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.util.Algorithms; @@ -562,10 +558,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { } MapActivityLayers mapLayers = mapActivity.getMapLayers(); ITileSource map = layer.getMap(); - final OsmandSettings.LayerTransparencySeekbarMode currentMapTypeSeekbarMode = type == + final LayerTransparencySeekbarMode currentMapTypeSeekbarMode = type == OsmandRasterMapsPlugin.RasterMapType.OVERLAY - ? OsmandSettings.LayerTransparencySeekbarMode.OVERLAY - : OsmandSettings.LayerTransparencySeekbarMode.UNDERLAY; + ? LayerTransparencySeekbarMode.OVERLAY + : LayerTransparencySeekbarMode.UNDERLAY; if (map != null) { mapTypePreference.set(null); if (callback != null) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 7c8238e7a1..927a085c8c 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -105,9 +105,6 @@ import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.search.QuickSearchHelper; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; import net.osmand.plus.widgets.TextViewExProgress; import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter.RoutingParameter; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 6a5599fa1a..a21b8898e6 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -30,13 +30,10 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.Version; import net.osmand.plus.render.NativeOsmandLibrary; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter.RoutingParameter; import net.osmand.router.GeneralRouter.RoutingParameterType; import net.osmand.router.PrecalculatedRouteDirection; -import net.osmand.router.RouteCalculationProgress; import net.osmand.router.RouteExporter; import net.osmand.router.RouteImporter; import net.osmand.router.RoutePlannerFrontEnd; diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 4fd5b1dd65..e92c8c0504 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -21,6 +21,7 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.notifications.OsmandNotification.NotificationType; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; @@ -408,8 +409,8 @@ public class RoutingHelper { } else if (mode.getRouteService() == RouteService.DIRECT_TO) { return -1.0f; } else if (mode.getRouteService() == RouteService.STRAIGHT) { - OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.getModeValue(mode); - if (mc == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS || mc == OsmandSettings.MetricsConstants.MILES_AND_METERS) { + MetricsConstants mc = settings.METRIC_SYSTEM.getModeValue(mode); + if (mc == MetricsConstants.KILOMETERS_AND_METERS || mc == MetricsConstants.MILES_AND_METERS) { return 500.f; } else { // 1/4 mile diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/BooleanAccessibilityPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/BooleanAccessibilityPreference.java index c376b6a99a..145a566b77 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/BooleanAccessibilityPreference.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/BooleanAccessibilityPreference.java @@ -1,7 +1,5 @@ package net.osmand.plus.settings.backend; -import net.osmand.plus.ApplicationMode; - class BooleanAccessibilityPreference extends BooleanPreference { BooleanAccessibilityPreference(OsmandSettings osmandSettings, String id, boolean defaultValue) { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/BooleanStringPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/BooleanStringPreference.java new file mode 100644 index 0000000000..8ca99f8521 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/backend/BooleanStringPreference.java @@ -0,0 +1,25 @@ +package net.osmand.plus.settings.backend; + +public class BooleanStringPreference extends BooleanPreference { + + public BooleanStringPreference(OsmandSettings osmandSettings, String id, boolean defaultValue) { + super(osmandSettings, id, defaultValue); + } + + @Override + public Boolean getValue(Object prefs, Boolean defaultValue) { + Boolean value; + try { + value = parseString(getSettingsAPI().getString(prefs, getId(), defaultValue.toString())); + } catch (ClassCastException e) { + value = getSettingsAPI().getBoolean(prefs, getId(), defaultValue); + setValue(prefs, value); + } + return value; + } + + @Override + protected boolean setValue(Object prefs, Boolean val) { + return getSettingsAPI().edit(prefs).putString(getId(), val != null ? val.toString() : null).commit(); + } +} diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/CommonPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/CommonPreference.java index 0a53139dc1..ea1c251375 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/CommonPreference.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/CommonPreference.java @@ -1,6 +1,5 @@ package net.osmand.plus.settings.backend; -import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandApplication; import net.osmand.plus.api.SettingsAPI; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ListStringPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/ListStringPreference.java index ff611593cc..661a42341a 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ListStringPreference.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ListStringPreference.java @@ -1,7 +1,5 @@ package net.osmand.plus.settings.backend; -import net.osmand.plus.ApplicationMode; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java index d4eaf070f2..135055c234 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java @@ -1,7 +1,5 @@ package net.osmand.plus.settings.backend; -import net.osmand.plus.ApplicationMode; - import java.util.Set; import androidx.annotation.NonNull; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandPreference.java index ae9a3f5e3a..897f9c22b0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandPreference.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandPreference.java @@ -1,7 +1,6 @@ package net.osmand.plus.settings.backend; import net.osmand.StateChangedListener; -import net.osmand.plus.ApplicationMode; import org.json.JSONException; import org.json.JSONObject; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 6a00a9f5a3..f66f81de57 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -6,29 +6,19 @@ import android.annotation.TargetApi; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; -import android.hardware.Sensor; -import android.hardware.SensorManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Build; import android.os.Environment; -import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.StringRes; import androidx.core.util.Pair; -import androidx.preference.PreferenceDataStore; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; +import net.osmand.FileUtils; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.ValueHolder; -import net.osmand.data.FavouritePoint; -import net.osmand.aidl.OsmandAidlApi; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.map.ITileSource; @@ -36,8 +26,6 @@ import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager.TileSourceTemplate; import net.osmand.osm.MapPoiTypes; import net.osmand.osm.io.NetworkUtils; -import net.osmand.plus.ApplicationMode; -import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.SQLiteTileSource; @@ -46,19 +34,30 @@ import net.osmand.plus.access.RelativeDirectionStyle; import net.osmand.plus.api.SettingsAPI; import net.osmand.plus.api.SettingsAPI.SettingsEditor; import net.osmand.plus.api.SettingsAPIImpl; +import net.osmand.plus.audionotes.NotesSortByMode; import net.osmand.plus.dialogs.RateUsBottomSheetDialogFragment.RateUsState; +import net.osmand.plus.helpers.enums.AngularConstants; +import net.osmand.plus.helpers.enums.AutoZoomMap; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; +import net.osmand.plus.helpers.enums.DayNightMode; +import net.osmand.plus.helpers.enums.DrivingRegion; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.helpers.SearchHistoryHelper; +import net.osmand.plus.helpers.enums.SpeedConstants; +import net.osmand.plus.helpers.enums.TracksSortByMode; import net.osmand.plus.mapillary.MapillaryPlugin; import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format; +import net.osmand.plus.mapmarkers.MapMarkersMode; import net.osmand.plus.profiles.LocationIcon; import net.osmand.plus.profiles.NavigationIcon; import net.osmand.plus.profiles.ProfileIconColors; +import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode; import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.routing.RouteProvider.RouteService; -import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; -import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBuilder; +import net.osmand.plus.srtmplugin.TerrainMode; +import net.osmand.plus.views.layers.RulerMode; import net.osmand.plus.voice.CommandPlayer; +import net.osmand.plus.wikipedia.WikiArticleShowImages; import net.osmand.render.RenderingRulesStorage; import net.osmand.util.Algorithms; @@ -78,7 +77,6 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; @@ -213,7 +211,7 @@ public class OsmandSettings { } // TODO doesn't look correct package visibility - public Object getProfilePreferences(String modeKey) { + Object getProfilePreferences(String modeKey) { return settingsAPI.getPreferenceObject(getSharedPreferencesNameForKey(modeKey)); } @@ -693,51 +691,47 @@ public class OsmandSettings { return false; } - public final CommonPreference RULER_MODE = new EnumStringPreference<>("ruler_mode", RulerMode.FIRST, RulerMode.values()).makeGlobal(); + public final CommonPreference RULER_MODE = new EnumStringPreference<>(this, "ruler_mode", RulerMode.FIRST, RulerMode.values()).makeGlobal(); - public final OsmandPreference SHOW_COMPASS_CONTROL_RULER = new BooleanPreference("show_compass_ruler", true).makeGlobal(); + public final OsmandPreference SHOW_COMPASS_CONTROL_RULER = new BooleanPreference(this, "show_compass_ruler", true).makeGlobal(); - public final CommonPreference SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeProfile(); - public final CommonPreference SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile(); + public final CommonPreference SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference(this, "show_lines_to_first_markers", false).makeProfile(); + public final CommonPreference SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference(this, "show_arrows_to_first_markers", false).makeProfile(); - public final CommonPreference WIKI_ARTICLE_SHOW_IMAGES_ASKED = new BooleanPreference("wikivoyage_show_images_asked", false).makeGlobal(); - public final CommonPreference WIKI_ARTICLE_SHOW_IMAGES = new EnumStringPreference<>("wikivoyage_show_imgs", WikiArticleShowImages.OFF, WikiArticleShowImages.values()).makeGlobal(); - public final CommonPreference GLOBAL_WIKIPEDIA_POI_ENABLED = new BooleanPreference("global_wikipedia_poi_enabled", false).makeProfile(); - public final ListStringPreference WIKIPEDIA_POI_ENABLED_LANGUAGES = (ListStringPreference) new ListStringPreference("wikipedia_poi_enabled_languages", null, ",").makeProfile().cache(); + public final CommonPreference WIKI_ARTICLE_SHOW_IMAGES_ASKED = new BooleanPreference(this, "wikivoyage_show_images_asked", false).makeGlobal(); + public final CommonPreference WIKI_ARTICLE_SHOW_IMAGES = new EnumStringPreference<>(this, "wikivoyage_show_imgs", WikiArticleShowImages.OFF, WikiArticleShowImages.values()).makeGlobal(); + public final CommonPreference GLOBAL_WIKIPEDIA_POI_ENABLED = new BooleanPreference(this, "global_wikipedia_poi_enabled", false).makeProfile(); + public final ListStringPreference WIKIPEDIA_POI_ENABLED_LANGUAGES = (ListStringPreference) new ListStringPreference(this, "wikipedia_poi_enabled_languages", null, ",").makeProfile().cache(); - public final CommonPreference SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference("select_marker_on_single_tap", false).makeProfile(); - public final CommonPreference KEEP_PASSED_MARKERS_ON_MAP = new BooleanPreference("keep_passed_markers_on_map", true).makeProfile(); + public final CommonPreference SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference(this, "select_marker_on_single_tap", false).makeProfile(); + public final CommonPreference KEEP_PASSED_MARKERS_ON_MAP = new BooleanPreference(this, "keep_passed_markers_on_map", true).makeProfile(); - public final CommonPreference COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference("coords_input_use_right_side", true).makeGlobal(); - public final OsmandPreference COORDS_INPUT_FORMAT = new EnumStringPreference<>("coords_input_format", Format.DD_MM_MMM, Format.values()).makeGlobal(); - public final CommonPreference COORDS_INPUT_USE_OSMAND_KEYBOARD = new BooleanPreference("coords_input_use_osmand_keyboard", Build.VERSION.SDK_INT >= 16).makeGlobal(); - public final CommonPreference COORDS_INPUT_TWO_DIGITS_LONGTITUDE = new BooleanPreference("coords_input_two_digits_longitude", false).makeGlobal(); + public final CommonPreference COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference(this, "coords_input_use_right_side", true).makeGlobal(); + public final OsmandPreference COORDS_INPUT_FORMAT = new EnumStringPreference<>(this, "coords_input_format", Format.DD_MM_MMM, Format.values()).makeGlobal(); + public final CommonPreference COORDS_INPUT_USE_OSMAND_KEYBOARD = new BooleanPreference(this, "coords_input_use_osmand_keyboard", Build.VERSION.SDK_INT >= 16).makeGlobal(); + public final CommonPreference COORDS_INPUT_TWO_DIGITS_LONGTITUDE = new BooleanPreference(this, "coords_input_two_digits_longitude", false).makeGlobal(); - public final CommonPreference USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal(); - public final CommonPreference MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal(); - public final CommonPreference MAPILLARY_FILTER_USERNAME = new StringPreference("mapillary_filter_username", "").makeGlobal(); - public final CommonPreference MAPILLARY_FILTER_FROM_DATE = new LongPreference("mapillary_filter_from_date", 0).makeGlobal(); - public final CommonPreference MAPILLARY_FILTER_TO_DATE = new LongPreference("mapillary_filter_to_date", 0).makeGlobal(); - public final CommonPreference MAPILLARY_FILTER_PANO = new BooleanPreference("mapillary_filter_pano", false).makeGlobal(); + public final CommonPreference USE_MAPILLARY_FILTER = new BooleanPreference(this, "use_mapillary_filters", false).makeGlobal(); + public final CommonPreference MAPILLARY_FILTER_USER_KEY = new StringPreference(this, "mapillary_filter_user_key", "").makeGlobal(); + public final CommonPreference MAPILLARY_FILTER_USERNAME = new StringPreference(this, "mapillary_filter_username", "").makeGlobal(); + public final CommonPreference MAPILLARY_FILTER_FROM_DATE = new LongPreference(this, "mapillary_filter_from_date", 0).makeGlobal(); + public final CommonPreference MAPILLARY_FILTER_TO_DATE = new LongPreference(this, "mapillary_filter_to_date", 0).makeGlobal(); + public final CommonPreference MAPILLARY_FILTER_PANO = new BooleanPreference(this, "mapillary_filter_pano", false).makeGlobal(); - public final CommonPreference USE_FAST_RECALCULATION = new BooleanPreference("use_fast_recalculation", true).makeGlobal().cache(); - public final CommonPreference FORCE_PRIVATE_ACCESS_ROUTING_ASKED = new BooleanPreference("force_private_access_routing", false).makeProfile().cache(); + public final CommonPreference USE_FAST_RECALCULATION = new BooleanPreference(this, "use_fast_recalculation", true).makeGlobal().cache(); + public final CommonPreference FORCE_PRIVATE_ACCESS_ROUTING_ASKED = new BooleanPreference(this, "force_private_access_routing", false).makeProfile().cache(); - public final CommonPreference SHOW_CARD_TO_CHOOSE_DRAWER = new BooleanPreference("show_card_to_choose_drawer", false).makeGlobal(); - public final CommonPreference SHOW_DASHBOARD_ON_START = new BooleanPreference("should_show_dashboard_on_start", false).makeGlobal(); - public final CommonPreference SHOW_DASHBOARD_ON_MAP_SCREEN = new BooleanPreference("show_dashboard_on_map_screen", false).makeGlobal(); - public final CommonPreference SHOW_OSMAND_WELCOME_SCREEN = new BooleanPreference("show_osmand_welcome_screen", true).makeGlobal(); + public final CommonPreference SHOW_CARD_TO_CHOOSE_DRAWER = new BooleanPreference(this, "show_card_to_choose_drawer", false).makeGlobal(); + public final CommonPreference SHOW_DASHBOARD_ON_START = new BooleanPreference(this, "should_show_dashboard_on_start", false).makeGlobal(); + public final CommonPreference SHOW_DASHBOARD_ON_MAP_SCREEN = new BooleanPreference(this, "show_dashboard_on_map_screen", false).makeGlobal(); + public final CommonPreference SHOW_OSMAND_WELCOME_SCREEN = new BooleanPreference(this, "show_osmand_welcome_screen", true).makeGlobal(); - public final CommonPreference API_NAV_DRAWER_ITEMS_JSON = new StringPreference("api_nav_drawer_items_json", "{}").makeGlobal(); - public final CommonPreference API_CONNECTED_APPS_JSON = new StringPreference("api_connected_apps_json", "[]").makeGlobal(); - public final CommonPreference NAV_DRAWER_LOGO = new StringPreference("drawer_logo", "").makeProfile(); - public final CommonPreference NAV_DRAWER_URL = new StringPreference("drawer_url", "").makeProfile(); + public final CommonPreference API_NAV_DRAWER_ITEMS_JSON = new StringPreference(this, "api_nav_drawer_items_json", "{}").makeGlobal(); + public final CommonPreference API_CONNECTED_APPS_JSON = new StringPreference(this, "api_connected_apps_json", "[]").makeGlobal(); + public final CommonPreference NAV_DRAWER_LOGO = new StringPreference(this, "drawer_logo", "").makeProfile(); + public final CommonPreference NAV_DRAWER_URL = new StringPreference(this, "drawer_url", "").makeProfile(); - public final CommonPreference NUMBER_OF_STARTS_FIRST_XMAS_SHOWN = new IntPreference("number_of_starts_first_xmas_shown", 0).makeGlobal(); - - public final OsmandPreference AVAILABLE_APP_MODES = new StringPreference("available_application_modes", "car,bicycle,pedestrian,public_transport,").makeGlobal().cache(); - - public final OsmandPreference LAST_FAV_CATEGORY_ENTERED = new StringPreference("last_fav_category", "").makeGlobal(); + public final CommonPreference NUMBER_OF_STARTS_FIRST_XMAS_SHOWN = new IntPreference(this, "number_of_starts_first_xmas_shown", 0).makeGlobal(); public final OsmandPreference AVAILABLE_APP_MODES = new StringPreference(this, "available_application_modes", "car,bicycle,pedestrian,public_transport,").makeGlobal().cache(); @@ -844,22 +838,7 @@ public class OsmandSettings { } protected DrivingRegion getDefaultValue() { - Locale df = Locale.getDefault(); - if (df == null) { - return DrivingRegion.EUROPE_ASIA; - } - if (df.getCountry().equalsIgnoreCase(Locale.US.getCountry())) { - return DrivingRegion.US; - } else if (df.getCountry().equalsIgnoreCase(Locale.CANADA.getCountry())) { - return DrivingRegion.CANADA; - } else if (df.getCountry().equalsIgnoreCase(Locale.JAPAN.getCountry())) { - return DrivingRegion.JAPAN; - } else if (df.getCountry().equalsIgnoreCase("au")) { - return DrivingRegion.AUSTRALIA; - } else if(df.getCountry().equalsIgnoreCase(Locale.UK.getCountry())) { - return DrivingRegion.UK_AND_OTHERS; - } - return DrivingRegion.EUROPE_ASIA; + return DrivingRegion.getDrivingRegionByLocale(); } }.makeProfile().cache(); @@ -1040,31 +1019,31 @@ public class OsmandSettings { // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference ACCESSIBILITY_SMART_AUTOANNOUNCE = new BooleanAccessibilityPreference(this, "accessibility_smart_autoannounce", true).makeProfile(); - + // this value string is synchronized with settings_pref.xml preference name // cache of metrics constants as they are used very often public final OsmandPreference ACCESSIBILITY_AUTOANNOUNCE_PERIOD = new IntPreference(this, "accessibility_autoannounce_period", 10000).makeProfile().cache(); // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference DISABLE_OFFROUTE_RECALC = - new BooleanPreference(this,"disable_offroute_recalc", false).makeProfile(); + new BooleanPreference(this, "disable_offroute_recalc", false).makeProfile(); // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference DISABLE_WRONG_DIRECTION_RECALC = - new BooleanPreference("disable_wrong_direction_recalc", false).makeProfile(); - + new BooleanPreference(this, "disable_wrong_direction_recalc", false).makeProfile(); + // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference DIRECTION_AUDIO_FEEDBACK = - new BooleanAccessibilityPreference(this, "direction_audio_feedback", false).makeProfile(); - + new BooleanAccessibilityPreference(this, "direction_audio_feedback", false).makeProfile(); + // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference DIRECTION_HAPTIC_FEEDBACK = - new BooleanAccessibilityPreference(this, "direction_haptic_feedback", false).makeProfile(); + new BooleanAccessibilityPreference(this, "direction_haptic_feedback", false).makeProfile(); // magnetic field doesn'torkmost of the time on some phones - public final OsmandPreference USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeProfile().cache(); - public final OsmandPreference USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeProfile().cache(); - public final OsmandPreference USE_VOLUME_BUTTONS_AS_ZOOM = new BooleanPreference("use_volume_buttons_as_zoom", false).makeProfile().cache(); + public final OsmandPreference USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference(this, "use_magnetic_field_sensor_compass", false).makeProfile().cache(); + public final OsmandPreference USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference(this, "use_kalman_filter_compass", true).makeProfile().cache(); + public final OsmandPreference USE_VOLUME_BUTTONS_AS_ZOOM = new BooleanPreference(this, "use_volume_buttons_as_zoom", false).makeProfile().cache(); public final OsmandPreference DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference(this, "do_not_show_startup_messages", false).makeGlobal().cache(); public final OsmandPreference SHOW_DOWNLOAD_MAP_DIALOG = new BooleanPreference(this, "show_download_map_dialog", true).makeGlobal().cache(); @@ -1117,23 +1096,23 @@ public class OsmandSettings { public final OsmandPreference INAPPS_READ = new BooleanPreference(this, "inapps_read", false).makeGlobal(); - public final OsmandPreference BILLING_USER_ID = new StringPreference("billing_user_id", "").makeGlobal(); - public final OsmandPreference BILLING_USER_TOKEN = new StringPreference("billing_user_token", "").makeGlobal(); - public final OsmandPreference BILLING_USER_NAME = new StringPreference("billing_user_name", "").makeGlobal(); - public final OsmandPreference BILLING_USER_EMAIL = new StringPreference("billing_user_email", "").makeGlobal(); - public final OsmandPreference BILLING_USER_COUNTRY = new StringPreference("billing_user_country", "").makeGlobal(); - public final OsmandPreference BILLING_USER_COUNTRY_DOWNLOAD_NAME = new StringPreference("billing_user_country_download_name", BILLING_USER_DONATION_NONE_PARAMETER).makeGlobal(); - public final OsmandPreference BILLING_HIDE_USER_NAME = new BooleanPreference("billing_hide_user_name", false).makeGlobal(); - public final OsmandPreference BILLING_PURCHASE_TOKEN_SENT = new BooleanPreference("billing_purchase_token_sent", false).makeGlobal(); - public final OsmandPreference BILLING_PURCHASE_TOKENS_SENT = new StringPreference("billing_purchase_tokens_sent", "").makeGlobal(); - public final OsmandPreference LIVE_UPDATES_PURCHASED = new BooleanPreference("billing_live_updates_purchased", false).makeGlobal(); - public final OsmandPreference LIVE_UPDATES_PURCHASE_CANCELLED_TIME = new LongPreference("live_updates_purchase_cancelled_time", 0).makeGlobal(); - public final OsmandPreference LIVE_UPDATES_PURCHASE_CANCELLED_FIRST_DLG_SHOWN = new BooleanPreference("live_updates_purchase_cancelled_first_dlg_shown", false).makeGlobal(); - public final OsmandPreference LIVE_UPDATES_PURCHASE_CANCELLED_SECOND_DLG_SHOWN = new BooleanPreference("live_updates_purchase_cancelled_second_dlg_shown", false).makeGlobal(); - public final OsmandPreference FULL_VERSION_PURCHASED = new BooleanPreference("billing_full_version_purchased", false).makeGlobal(); - public final OsmandPreference DEPTH_CONTOURS_PURCHASED = new BooleanPreference("billing_sea_depth_purchased", false).makeGlobal(); - public final OsmandPreference CONTOUR_LINES_PURCHASED = new BooleanPreference("billing_srtm_purchased", false).makeGlobal(); - public final OsmandPreference EMAIL_SUBSCRIBED = new BooleanPreference("email_subscribed", false).makeGlobal(); + public final OsmandPreference BILLING_USER_ID = new StringPreference(this, "billing_user_id", "").makeGlobal(); + public final OsmandPreference BILLING_USER_TOKEN = new StringPreference(this, "billing_user_token", "").makeGlobal(); + public final OsmandPreference BILLING_USER_NAME = new StringPreference(this, "billing_user_name", "").makeGlobal(); + public final OsmandPreference BILLING_USER_EMAIL = new StringPreference(this, "billing_user_email", "").makeGlobal(); + public final OsmandPreference BILLING_USER_COUNTRY = new StringPreference(this, "billing_user_country", "").makeGlobal(); + public final OsmandPreference BILLING_USER_COUNTRY_DOWNLOAD_NAME = new StringPreference(this, "billing_user_country_download_name", BILLING_USER_DONATION_NONE_PARAMETER).makeGlobal(); + public final OsmandPreference BILLING_HIDE_USER_NAME = new BooleanPreference(this, "billing_hide_user_name", false).makeGlobal(); + public final OsmandPreference BILLING_PURCHASE_TOKEN_SENT = new BooleanPreference(this, "billing_purchase_token_sent", false).makeGlobal(); + public final OsmandPreference BILLING_PURCHASE_TOKENS_SENT = new StringPreference(this, "billing_purchase_tokens_sent", "").makeGlobal(); + public final OsmandPreference LIVE_UPDATES_PURCHASED = new BooleanPreference(this, "billing_live_updates_purchased", false).makeGlobal(); + public final OsmandPreference LIVE_UPDATES_PURCHASE_CANCELLED_TIME = new LongPreference(this, "live_updates_purchase_cancelled_time", 0).makeGlobal(); + public final OsmandPreference LIVE_UPDATES_PURCHASE_CANCELLED_FIRST_DLG_SHOWN = new BooleanPreference(this, "live_updates_purchase_cancelled_first_dlg_shown", false).makeGlobal(); + public final OsmandPreference LIVE_UPDATES_PURCHASE_CANCELLED_SECOND_DLG_SHOWN = new BooleanPreference(this, "live_updates_purchase_cancelled_second_dlg_shown", false).makeGlobal(); + public final OsmandPreference FULL_VERSION_PURCHASED = new BooleanPreference(this, "billing_full_version_purchased", false).makeGlobal(); + public final OsmandPreference DEPTH_CONTOURS_PURCHASED = new BooleanPreference(this, "billing_sea_depth_purchased", false).makeGlobal(); + public final OsmandPreference CONTOUR_LINES_PURCHASED = new BooleanPreference(this, "billing_srtm_purchased", false).makeGlobal(); + public final OsmandPreference EMAIL_SUBSCRIBED = new BooleanPreference(this, "email_subscribed", false).makeGlobal(); public final OsmandPreference DISCOUNT_ID = new IntPreference(this, "discount_id", 0).makeGlobal(); public final OsmandPreference DISCOUNT_SHOW_NUMBER_OF_STARTS = new IntPreference(this, "number_of_starts_on_discount_show", 0).makeGlobal(); @@ -1284,17 +1263,19 @@ public class OsmandSettings { { SPEAK_TRAFFIC_WARNINGS.setModeDefaultValue(ApplicationMode.CAR, true); } + public final CommonPreference SPEAK_PEDESTRIAN = new BooleanPreference(this, "speak_pedestrian", false).makeProfile().cache(); + { SPEAK_PEDESTRIAN.setModeDefaultValue(ApplicationMode.CAR, true); } + public final OsmandPreference SPEAK_SPEED_LIMIT = new BooleanPreference(this, "speak_speed_limit", false).makeProfile().cache(); public final OsmandPreference SPEAK_SPEED_CAMERA = new BooleanPreference(this, "speak_cameras", false).makeProfile().cache(); public final OsmandPreference SPEAK_TUNNELS = new BooleanPreference(this, "speak_tunnels", false).makeProfile().cache(); - public final OsmandPreference ANNOUNCE_WPT = new BooleanPreference(this, "announce_wpt", true) { - public final OsmandPreference SPEED_CAMERAS_UNINSTALLED = new BooleanPreference("speed_cameras_uninstalled", false).makeGlobal(); - public final OsmandPreference SPEED_CAMERAS_ALERT_SHOWED = new BooleanPreference("speed_cameras_alert_showed", false).makeGlobal(); + public final OsmandPreference SPEED_CAMERAS_UNINSTALLED = new BooleanPreference(this, "speed_cameras_uninstalled", false).makeGlobal(); + public final OsmandPreference SPEED_CAMERAS_ALERT_SHOWED = new BooleanPreference(this, "speed_cameras_alert_showed", false).makeGlobal(); public Set getForbiddenTypes() { Set typeNames = new HashSet<>(); @@ -1304,7 +1285,7 @@ public class OsmandSettings { return typeNames; } - public final OsmandPreference ANNOUNCE_WPT = new BooleanPreference("announce_wpt", true) { + public final OsmandPreference ANNOUNCE_WPT = new BooleanPreference(this, "announce_wpt", true) { @Override protected boolean setValue(Object prefs, Boolean val) { boolean valueSaved = super.setValue(prefs, val); @@ -1343,11 +1324,7 @@ public class OsmandSettings { public final OsmandPreference GPX_ROUTE_CALC_OSMAND_PARTS = new BooleanPreference(this, "gpx_routing_calculate_osmand_route", true).makeGlobal().cache(); public final OsmandPreference GPX_CALCULATE_RTEPT = new BooleanPreference(this, "gpx_routing_calculate_rtept", true).makeGlobal().cache(); public final OsmandPreference GPX_ROUTE_CALC = new BooleanPreference(this, "calc_gpx_route", false).makeGlobal().cache(); - public final OsmandPreference SHOW_START_FINISH_ICONS = new BooleanPreference("show_start_finish_icons", true).makeGlobal().cache(); - - public final OsmandPreference GPX_ROUTE_CALC_OSMAND_PARTS = new BooleanPreference("gpx_routing_calculate_osmand_route", true).makeGlobal().cache(); -// public final OsmandPreference GPX_CALCULATE_RTEPT = new BooleanPreference("gpx_routing_calculate_rtept", true).makeGlobal().cache(); - public final OsmandPreference GPX_ROUTE_CALC = new BooleanPreference("calc_gpx_route", false).makeGlobal().cache(); + public final OsmandPreference SHOW_START_FINISH_ICONS = new BooleanPreference(this, "show_start_finish_icons", true).makeGlobal().cache(); public final OsmandPreference AVOID_TOLL_ROADS = new BooleanPreference(this, "avoid_toll_roads", false).makeProfile().cache(); public final OsmandPreference AVOID_MOTORWAY = new BooleanPreference(this, "avoid_motorway", false).makeProfile().cache(); @@ -1358,11 +1335,11 @@ public class OsmandSettings { public final OsmandPreference LAST_UPDATES_CARD_REFRESH = new LongPreference(this, "last_updates_card_refresh", 0).makeGlobal(); - public final CommonPreference CURRENT_TRACK_COLOR = new IntPreference("current_track_color", 0).makeGlobal().cache(); - public final CommonPreference CURRENT_TRACK_WIDTH = new StringPreference("current_track_width", "").makeGlobal().cache(); - public final CommonPreference CURRENT_TRACK_SHOW_ARROWS = new BooleanPreference("current_track_show_arrows", false).makeGlobal().cache(); - public final CommonPreference CURRENT_TRACK_SHOW_START_FINISH = new BooleanPreference("current_track_show_start_finish", true).makeGlobal().cache(); - public final ListStringPreference CUSTOM_TRACK_COLORS = (ListStringPreference) new ListStringPreference("custom_track_colors", null, ",").makeGlobal(); + public final CommonPreference CURRENT_TRACK_COLOR = new IntPreference(this, "current_track_color", 0).makeGlobal().cache(); + public final CommonPreference CURRENT_TRACK_WIDTH = new StringPreference(this, "current_track_width", "").makeGlobal().cache(); + public final CommonPreference CURRENT_TRACK_SHOW_ARROWS = new BooleanPreference(this, "current_track_show_arrows", false).makeGlobal().cache(); + public final CommonPreference CURRENT_TRACK_SHOW_START_FINISH = new BooleanPreference(this, "current_track_show_start_finish", true).makeGlobal().cache(); + public final ListStringPreference CUSTOM_TRACK_COLORS = (ListStringPreference) new ListStringPreference(this, "custom_track_colors", null, ",").makeGlobal(); // this value string is synchronized with settings_pref.xml preference name public final CommonPreference SAVE_TRACK_INTERVAL = new IntPreference(this, "save_track_interval", 5000).makeProfile(); @@ -1372,7 +1349,7 @@ public class OsmandSettings { SAVE_TRACK_INTERVAL.setModeDefaultValue(ApplicationMode.BICYCLE, 5000); SAVE_TRACK_INTERVAL.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 10000); } - + // Please note that SAVE_TRACK_MIN_DISTANCE, SAVE_TRACK_PRECISION, SAVE_TRACK_MIN_SPEED should all be "0" for the default profile, as we have no interface to change them public final CommonPreference SAVE_TRACK_MIN_DISTANCE = new FloatPreference(this, "save_track_min_distance", 0).makeProfile(); //{ @@ -1420,6 +1397,7 @@ public class OsmandSettings { public final CommonPreference SHOW_OSM_BUGS_MIN_ZOOM = new IntPreference(this, "show_osm_bugs_min_zoom", 8).makeProfile().cache(); public final CommonPreference MAP_INFO_CONTROLS = new StringPreference(this, "map_info_controls", "").makeProfile(); + { for (ApplicationMode mode : ApplicationMode.allPossibleValues()) { MAP_INFO_CONTROLS.setModeDefaultValue(mode, ""); @@ -1474,7 +1452,7 @@ public class OsmandSettings { KEEP_INFORMING.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0); } - public final CommonPreference USE_SYSTEM_SCREEN_TIMEOUT = new BooleanPreference("use_system_screen_timeout", false).makeProfile(); + public final CommonPreference USE_SYSTEM_SCREEN_TIMEOUT = new BooleanPreference(this, "use_system_screen_timeout", false).makeProfile(); public final CommonPreference TURN_SCREEN_ON_TIME_INT = new IntPreference(this, "turn_screen_on_time_int", 0).makeProfile(); @@ -1485,16 +1463,16 @@ public class OsmandSettings { } public final CommonPreference TURN_SCREEN_ON_SENSOR = new BooleanPreference(this, "turn_screen_on_sensor", false).makeProfile(); - + { TURN_SCREEN_ON_SENSOR.setModeDefaultValue(ApplicationMode.CAR, false); TURN_SCREEN_ON_SENSOR.setModeDefaultValue(ApplicationMode.BICYCLE, false); TURN_SCREEN_ON_SENSOR.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false); } - public final CommonPreference TURN_SCREEN_ON_NAVIGATION_INSTRUCTIONS = new BooleanPreference("turn_screen_on_navigation_instructions", false).makeProfile(); + public final CommonPreference TURN_SCREEN_ON_NAVIGATION_INSTRUCTIONS = new BooleanPreference(this, "turn_screen_on_navigation_instructions", false).makeProfile(); - public final CommonPreference TURN_SCREEN_ON_POWER_BUTTON = new BooleanPreference("turn_screen_on_power_button", false).makeProfile(); + public final CommonPreference TURN_SCREEN_ON_POWER_BUTTON = new BooleanPreference(this, "turn_screen_on_power_button", false).makeProfile(); // this value string is synchronized with settings_pref.xml preference name // try without AUTO_FOLLOW_ROUTE_NAV (see forum discussion 'Simplify our navigation preference menu') @@ -1567,7 +1545,8 @@ public class OsmandSettings { VOICE_PROMPT_DELAY[3] = new IntPreference(this, "voice_prompt_delay_3", 0).makeGlobal().cache(); /*AudioManager.STREAM_MUSIC*/ VOICE_PROMPT_DELAY[5] = new IntPreference(this, "voice_prompt_delay_5", 0).makeGlobal().cache(); /*AudioManager.STREAM_NOTIFICATION*/ } - public final OsmandPreference DISPLAY_TTS_UTTERANCE = new BooleanPreference("display_tts_utterance", false).makeGlobal(); + + public final OsmandPreference DISPLAY_TTS_UTTERANCE = new BooleanPreference(this, "display_tts_utterance", false).makeGlobal(); // this value string is synchronized with settings_pref.xml preference name public final CommonPreference MAP_ONLINE_DATA = new BooleanPreference(this, "map_online_data", false).makeProfile(); @@ -1636,8 +1615,8 @@ public class OsmandSettings { public final OsmandPreference SHOW_COORDINATES_WIDGET = new BooleanPreference(this, "show_coordinates_widget", false).makeProfile().cache(); - public final CommonPreference NOTES_SORT_BY_MODE = new EnumStringPreference<>("notes_sort_by_mode", NotesSortByMode.BY_DATE, NotesSortByMode.values()); - public final CommonPreference TRACKS_SORT_BY_MODE = new EnumStringPreference<>("tracks_sort_by_mode", TracksSortByMode.BY_DATE, TracksSortByMode.values()); + public final CommonPreference NOTES_SORT_BY_MODE = new EnumStringPreference<>(this, "notes_sort_by_mode", NotesSortByMode.BY_DATE, NotesSortByMode.values()); + public final CommonPreference TRACKS_SORT_BY_MODE = new EnumStringPreference<>(this, "tracks_sort_by_mode", TracksSortByMode.BY_DATE, TracksSortByMode.values()); public final OsmandPreference ANIMATE_MY_LOCATION = new BooleanPreference(this, "animate_my_location", true).makeProfile().cache(); @@ -1791,7 +1770,7 @@ public class OsmandSettings { setExternalStorageDirectoryPre19(getInternalAppPath().getAbsolutePath()); } else { File externalStorage = getExternal1AppPath(); - if (externalStorage != null && OsmandSettings.isWritable(externalStorage)) { + if (externalStorage != null && FileUtils.isWritable(externalStorage)) { setExternalStorageDirectoryV19(EXTERNAL_STORAGE_TYPE_EXTERNAL_FILE, getExternal1AppPath().getAbsolutePath()); } else { @@ -1843,7 +1822,7 @@ public class OsmandSettings { int type = settingsAPI.getInt(globalPreferences, EXTERNAL_STORAGE_DIR_TYPE_V19, -1); File location = getDefaultLocationV19(); if (type == -1) { - if (isWritable(location)) { + if (FileUtils.isWritable(location)) { if (tp != null) { tp.value = settingsAPI.contains(globalPreferences, EXTERNAL_STORAGE_DIR_V19) ? EXTERNAL_STORAGE_TYPE_SPECIFIED : @@ -1881,20 +1860,6 @@ public class OsmandSettings { return new File(location); } - - public static boolean isWritable(File dirToTest) { - boolean isWriteable = false; - try { - dirToTest.mkdirs(); - File writeTestFile = File.createTempFile("osmand_", ".tmp", dirToTest); - isWriteable = writeTestFile.exists(); - writeTestFile.delete(); - } catch (IOException e) { - isWriteable = false; - } - return isWriteable; - } - public boolean isExternalStorageDirectoryTypeSpecifiedV19() { return settingsAPI.contains(globalPreferences, EXTERNAL_STORAGE_DIR_TYPE_V19); } @@ -2008,10 +1973,6 @@ public class OsmandSettings { } } - private Object objectToShow; - private boolean editObjectToShow; - private String searchRequestToShow; - public void setSearchRequestToShow(String request) { this.searchRequestToShow = request; } @@ -2039,7 +2000,7 @@ public class OsmandSettings { } public void setMapLocationToShow(double latitude, double longitude, int zoom, PointDescription pointDescription, - boolean addToHistory, Object toShow) { + boolean addToHistory, Object toShow) { SettingsEditor edit = settingsAPI.edit(globalPreferences); edit.putFloat(MAP_LAT_TO_SHOW, (float) latitude); edit.putFloat(MAP_LON_TO_SHOW, (float) longitude); @@ -2103,7 +2064,6 @@ public class OsmandSettings { public final static String INTERMEDIATE_POINTS = "intermediate_points"; //$NON-NLS-1$ public final static String INTERMEDIATE_POINTS_DESCRIPTION = "intermediate_points_description"; //$NON-NLS-1$ - private IntermediatePointsStorage intermediatePointsStorage = new IntermediatePointsStorage(); public final static String POINT_NAVIGATE_LAT_BACKUP = "point_navigate_lat_backup"; //$NON-NLS-1$ public final static String POINT_NAVIGATE_LON_BACKUP = "point_navigate_lon_backup"; //$NON-NLS-1$ @@ -2363,7 +2323,7 @@ public class OsmandSettings { public static final String QUICK_FAB_MARGIN_X_LANDSCAPE_MARGIN = "quick_fab_margin_x_landscape_margin"; public static final String QUICK_FAB_MARGIN_Y_LANDSCAPE_MARGIN = "quick_fab_margin_y_landscape_margin"; - public final CommonPreference QUICK_ACTION = new BooleanPreference("quick_action_state", false).makeProfile(); + public final CommonPreference QUICK_ACTION = new BooleanPreference(this, "quick_action_state", false).makeProfile(); public final CommonPreference QUICK_ACTION_LIST = new StringPreference(this, "quick_action_list", "").makeGlobal(); @@ -2538,7 +2498,7 @@ public class OsmandSettings { public final ListStringPreference POI_FILTERS_ORDER = (ListStringPreference) new ListStringPreference(this, "poi_filters_order", null, ",,").makeProfile().cache(); - + public final ListStringPreference INACTIVE_POI_FILTERS = (ListStringPreference) new ListStringPreference(this, "inactive_poi_filters", null, ",,").makeProfile().cache(); @@ -2609,11 +2569,9 @@ public class OsmandSettings { RENDERER.setModeDefaultValue(ApplicationMode.SKI, RendererRegistry.WINTER_SKI_RENDER); } - Map> customRendersProps = new LinkedHashMap>(); - public CommonPreference getCustomRenderProperty(String attrName) { if (!customRendersProps.containsKey(attrName)) { - customRendersProps.put(attrName, new StringPreference(RENDERER_PREFERENCE_PREFIX + attrName, "").makeProfile()); + customRendersProps.put(attrName, new StringPreference(this, RENDERER_PREFERENCE_PREFIX + attrName, "").makeProfile()); } return customRendersProps.get(attrName); } @@ -2623,29 +2581,24 @@ public class OsmandSettings { getCustomRenderProperty("defAppMode"); } - Map> customBooleanRendersProps = new LinkedHashMap>(); - public CommonPreference getCustomRenderBooleanProperty(String attrName) { if (!customBooleanRendersProps.containsKey(attrName)) { - customBooleanRendersProps.put(attrName, new BooleanPreference(RENDERER_PREFERENCE_PREFIX + attrName, false).makeProfile()); + customBooleanRendersProps.put(attrName, new BooleanPreference(this, RENDERER_PREFERENCE_PREFIX + attrName, false).makeProfile()); } return customBooleanRendersProps.get(attrName); } - Map> customRoutingProps = new LinkedHashMap<>(); - public CommonPreference getCustomRoutingProperty(String attrName, String defValue) { if (!customRoutingProps.containsKey(attrName)) { - customRoutingProps.put(attrName, new StringPreference(ROUTING_PREFERENCE_PREFIX + attrName, defValue).makeProfile()); + customRoutingProps.put(attrName, new StringPreference(this, ROUTING_PREFERENCE_PREFIX + attrName, defValue).makeProfile()); } return customRoutingProps.get(attrName); } - Map> customBooleanRoutingProps = new LinkedHashMap<>(); public CommonPreference getCustomRoutingBooleanProperty(String attrName, boolean defaulfValue) { if (!customBooleanRoutingProps.containsKey(attrName)) { - customBooleanRoutingProps.put(attrName, new BooleanStringPreference(ROUTING_PREFERENCE_PREFIX + attrName, defaulfValue).makeProfile()); + customBooleanRoutingProps.put(attrName, new BooleanStringPreference(this, ROUTING_PREFERENCE_PREFIX + attrName, defaulfValue).makeProfile()); } return customBooleanRoutingProps.get(attrName); } @@ -2663,9 +2616,9 @@ public class OsmandSettings { public final OsmandPreference MAP_ACTIVITY_ENABLED = new BooleanPreference(this, "map_activity_enabled", false).makeGlobal(); // this value string is synchronized with settings_pref.xml preference name - public final OsmandPreference SAFE_MODE = new BooleanPreference("safe_mode", false).makeGlobal(); - public final OsmandPreference PT_SAFE_MODE = new BooleanPreference("pt_safe_mode", false).makeGlobal(); - public final OsmandPreference NATIVE_RENDERING_FAILED = new BooleanPreference("native_rendering_failed_init", false).makeGlobal(); + public final OsmandPreference SAFE_MODE = new BooleanPreference(this, "safe_mode", false).makeGlobal(); + public final OsmandPreference PT_SAFE_MODE = new BooleanPreference(this, "pt_safe_mode", false).makeGlobal(); + public final OsmandPreference NATIVE_RENDERING_FAILED = new BooleanPreference(this, "native_rendering_failed_init", false).makeGlobal(); public final OsmandPreference USE_OPENGL_RENDER = new BooleanPreference(this, "use_opengl_render", false /*Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH*/ @@ -2681,12 +2634,12 @@ public class OsmandSettings { public final OsmandPreference FOLLOW_THE_ROUTE = new BooleanPreference(this, "follow_to_route", false).makeGlobal(); public final OsmandPreference FOLLOW_THE_GPX_ROUTE = new StringPreference(this, "follow_gpx", null).makeGlobal(); - + public final OsmandPreference SELECTED_TRAVEL_BOOK = new StringPreference(this, "selected_travel_book", "").makeGlobal(); public final ListStringPreference DISPLAYED_TRANSPORT_SETTINGS = (ListStringPreference) new ListStringPreference(this, "displayed_transport_settings", null, ",").makeProfile(); - + public final OsmandPreference SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME = new BooleanPreference(this, "show_arrival_time", true).makeProfile(); @@ -2741,7 +2694,7 @@ public class OsmandSettings { new IntPreference(this, "FAVORITES_TAB", 0).makeGlobal().cache(); public final CommonPreference OSMAND_THEME = - new IntPreference("osmand_theme", OSMAND_LIGHT_THEME) { + new IntPreference(this, "osmand_theme", OSMAND_LIGHT_THEME) { @Override public void readFromJson(JSONObject json, ApplicationMode appMode) throws JSONException { Integer theme = parseString(json.getString(getId())); @@ -2792,7 +2745,6 @@ public class OsmandSettings { new BooleanPreference(this, "fluorescent_overlays", false).makeGlobal().cache(); - // public final OsmandPreference NUMBER_OF_FREE_DOWNLOADS_V2 = new IntPreference("free_downloads_v2", 0).makeGlobal(); public final OsmandPreference NUMBER_OF_FREE_DOWNLOADS = new IntPreference(this, NUMBER_OF_FREE_DOWNLOADS_ID, 0).makeGlobal(); @@ -2811,7 +2763,7 @@ public class OsmandSettings { new EnumStringPreference<>(this, "rate_us_state", RateUsState.INITIAL_STATE, RateUsState.values()).makeGlobal(); public final CommonPreference CUSTOM_APP_MODES_KEYS = - new StringPreference(this, "custom_app_modes_keys", "").makeGlobal().cache(); + new StringPreference(this, "custom_app_modes_keys", "").makeGlobal().cache(); public Set getCustomAppModesKeys() { String appModesKeys = CUSTOM_APP_MODES_KEYS.get(); @@ -2823,6 +2775,16 @@ public class OsmandSettings { return res; } + public void setQuickActions(HashMap quickActions, ApplicationMode mode) { + if (!QUICK_ACTION.isSetForMode(mode)) { + Boolean actionState = quickActions.get(mode.getStringKey()); + if (actionState == null) { + actionState = QUICK_ACTION.getDefaultValue(); + } + setPreference(QUICK_ACTION.getId(), actionState, mode); + } + } + public String[] getAppModeBeanPrefsIds() { return new String[]{ ICON_COLOR.getId(), @@ -2871,305 +2833,4 @@ public class OsmandSettings { DRIVING_REGION_AUTOMATIC }; } - - public enum DayNightMode { - AUTO(R.string.daynight_mode_auto, R.drawable.ic_action_map_sunset), - DAY(R.string.daynight_mode_day, R.drawable.ic_action_map_day), - NIGHT(R.string.daynight_mode_night, R.drawable.ic_action_map_night), - SENSOR(R.string.daynight_mode_sensor, R.drawable.ic_action_map_light_sensor); - - private final int key; - @DrawableRes - private final int drawableRes; - - DayNightMode(@StringRes int key, @DrawableRes int drawableRes) { - this.key = key; - this.drawableRes = drawableRes; - } - - public String toHumanString(Context ctx) { - return ctx.getString(key); - } - - @DrawableRes - public int getIconRes() { - return drawableRes; - } - - public boolean isSensor() { - return this == SENSOR; - } - - public boolean isAuto() { - return this == AUTO; - } - - public boolean isDay() { - return this == DAY; - } - - public boolean isNight() { - return this == NIGHT; - } - - public static DayNightMode[] possibleValues(Context context) { - SensorManager mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); - Sensor mLight = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); - boolean isLightSensorEnabled = mLight != null; - if (isLightSensorEnabled) { - return DayNightMode.values(); - } else { - return new DayNightMode[]{AUTO, DAY, NIGHT}; - } - } - } - - - public enum LayerTransparencySeekbarMode { - OVERLAY(R.string.overlay_transparency), - UNDERLAY(R.string.map_transparency), - OFF(R.string.shared_string_off), - UNDEFINED(R.string.shared_string_none); - - private final int key; - - LayerTransparencySeekbarMode(int key) { - this.key = key; - } - - public String toHumanString(Context ctx) { - return ctx.getString(key); - } - } - - public enum NotesSortByMode { - BY_TYPE, - BY_DATE; - - public boolean isByType() { - return this == BY_TYPE; - } - - public boolean isByDate() { - return this == BY_DATE; - } - } - - public enum TracksSortByMode { - BY_DATE(R.string.sort_last_modified, R.drawable.ic_action_time_start), - BY_NAME_ASCENDING(R.string.sort_name_ascending, R.drawable.ic_action_sort_by_name_ascending), - BY_NAME_DESCENDING(R.string.sort_name_descending, R.drawable.ic_action_sort_by_name_descending); - - private final int iconId; - private final int nameId; - - TracksSortByMode(int nameId, int iconId) { - this.nameId = nameId; - this.iconId = iconId; - } - - public boolean isByName() { - return this == BY_NAME_ASCENDING || this == BY_NAME_DESCENDING; - } - - public boolean isByDate() { - return this == BY_DATE; - } - - @StringRes - public int getNameId() { - return nameId; - } - - @DrawableRes - public int getIconId() { - return iconId; - } - } - - public enum MapMarkersMode { - TOOLBAR(R.string.shared_string_topbar), - WIDGETS(R.string.shared_string_widgets), - NONE(R.string.shared_string_none); - - private final int key; - - MapMarkersMode(int key) { - this.key = key; - } - - public String toHumanString(Context ctx) { - return ctx.getString(key); - } - - public boolean isToolbar() { - return this == TOOLBAR; - } - - public boolean isWidgets() { - return this == WIDGETS; - } - - public boolean isNone() { - return this == NONE; - } - - public static MapMarkersMode[] possibleValues(Context context) { - return new MapMarkersMode[]{TOOLBAR, WIDGETS, NONE}; - } - } - - public enum SpeedConstants { - KILOMETERS_PER_HOUR(R.string.km_h, R.string.si_kmh, false), - MILES_PER_HOUR(R.string.mile_per_hour, R.string.si_mph, true), - METERS_PER_SECOND(R.string.m_s, R.string.si_m_s, false), - MINUTES_PER_MILE(R.string.min_mile, R.string.si_min_m, true), - MINUTES_PER_KILOMETER(R.string.min_km, R.string.si_min_km, false), - NAUTICALMILES_PER_HOUR(R.string.nm_h, R.string.si_nm_h, true); - - public final int key; - public final int descr; - public final boolean imperial; - - SpeedConstants(int key, int descr, boolean imperial) { - this.key = key; - this.descr = descr; - this.imperial = imperial; - } - - - - public String toHumanString(Context ctx) { - return ctx.getString(descr); - } - - public String toShortString(Context ctx) { - return ctx.getString(key); - } - - - } - - public enum MetricsConstants { - KILOMETERS_AND_METERS(R.string.si_km_m, "km-m"), - MILES_AND_FEET(R.string.si_mi_feet, "mi-f"), - MILES_AND_METERS(R.string.si_mi_meters, "mi-m"), - MILES_AND_YARDS(R.string.si_mi_yard, "mi-y"), - NAUTICAL_MILES(R.string.si_nm, "nm"); - - private final int key; - private final String ttsString; - - MetricsConstants(int key, String ttsString) { - this.key = key; - this.ttsString = ttsString; - } - - public String toHumanString(Context ctx) { - return ctx.getString(key); - } - - public String toTTSString() { - return ttsString; - } - - } - - public enum AngularConstants { - DEGREES(R.string.shared_string_degrees, "°"), - DEGREES360(R.string.shared_string_degrees, "°"), - MILLIRADS(R.string.shared_string_milliradians, "mil"); - - private final int key; - private final String unit; - - AngularConstants(int key, String unit) { - this.key = key; - this.unit = unit; - } - - public String toHumanString(Context ctx) { - return ctx.getString(key); - } - public String getUnitSymbol() { - return unit; - } - - } - - public enum AutoZoomMap { - FARTHEST(R.string.auto_zoom_farthest, 1f, 15.5f), - FAR(R.string.auto_zoom_far, 1.4f, 17f), - CLOSE(R.string.auto_zoom_close, 2f, 19f); - public final float coefficient; - public final int name; - public final float maxZoom; - - AutoZoomMap(int name, float coefficient, float maxZoom) { - this.name = name; - this.coefficient = coefficient; - this.maxZoom = maxZoom; - - } - } - - /** - * Class represents specific for driving region - * Signs, leftHandDriving - */ - public enum DrivingRegion { - - EUROPE_ASIA(R.string.driving_region_europe_asia, MetricsConstants.KILOMETERS_AND_METERS, false), - US(R.string.driving_region_us, MetricsConstants.MILES_AND_FEET, false), - CANADA(R.string.driving_region_canada, MetricsConstants.KILOMETERS_AND_METERS, false), - UK_AND_OTHERS(R.string.driving_region_uk, MetricsConstants.MILES_AND_METERS, true), - JAPAN(R.string.driving_region_japan, MetricsConstants.KILOMETERS_AND_METERS, true), - AUSTRALIA(R.string.driving_region_australia, MetricsConstants.KILOMETERS_AND_METERS, true); - - public final boolean leftHandDriving; - public final MetricsConstants defMetrics; - public final int name; - - DrivingRegion(int name, MetricsConstants def, boolean leftHandDriving) { - this.name = name; - defMetrics = def; - this.leftHandDriving = leftHandDriving; - } - - public boolean isAmericanTypeSigns() { - return this == OsmandSettings.DrivingRegion.AUSTRALIA || - this == OsmandSettings.DrivingRegion.US || - this == OsmandSettings.DrivingRegion.CANADA; - } - - public String getDescription(Context ctx) { - return ctx.getString(leftHandDriving ? R.string.left_side_navigation : R.string.right_side_navigation) + - ", " + - defMetrics.toHumanString(ctx).toLowerCase(); - } - } - - public enum RulerMode { - FIRST, - SECOND, - EMPTY - } - - public enum WikiArticleShowImages { - ON(R.string.shared_string_on), - OFF(R.string.shared_string_off), - WIFI(R.string.shared_string_wifi_only); - - public final int name; - - WikiArticleShowImages(int name) { - this.name = name; - } - } - - public enum TerrainMode { - HILLSHADE, - SLOPE - } - } diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeDataStorageBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeDataStorageBottomSheet.java index 334cc42aa8..e61faafe16 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeDataStorageBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeDataStorageBottomSheet.java @@ -11,8 +11,8 @@ import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; +import net.osmand.FileUtils; import net.osmand.PlatformUtil; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; @@ -63,7 +63,7 @@ public class ChangeDataStorageBottomSheet extends BasePreferenceBottomSheet { CharSequence desc = null; File currentStorageFile = new File(currentDirectory.getDirectory()); - if ((!OsmandSettings.isWritable(currentStorageFile))) { + if ((!FileUtils.isWritable(currentStorageFile))) { desc = String.format(getString(R.string.android_19_location_disabled), currentStorageFile.getAbsoluteFile()); } else { String from = currentDirectory.getKey().equals(MANUALLY_SPECIFIED) ? currentDirectory.getDirectory() : currentDirectory.getTitle(); diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java index 5d37d40b3b..d2679564a8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java @@ -14,6 +14,7 @@ import androidx.fragment.app.FragmentManager; import com.google.android.material.slider.Slider; import net.osmand.AndroidUtils; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; @@ -76,8 +77,8 @@ public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBot int contentPaddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small); int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding); - OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get(); - if (mc == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) { + MetricsConstants mc = settings.METRIC_SYSTEM.get(); + if (mc == MetricsConstants.KILOMETERS_AND_METERS) { entryValues = new Float[]{10.f, 20.0f, 30.0f, 50.0f, 100.0f, 200.0f, 500.0f, 1000.0f, 1500.0f}; } else { entryValues = new Float[]{9.1f, 18.3f, 30.5f, 45.7f, 91.5f, 183.0f, 482.0f, 965.0f, 1609.0f}; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DataStorageFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DataStorageFragment.java index 93719a83ab..842b53e2fa 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DataStorageFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DataStorageFragment.java @@ -23,6 +23,7 @@ import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceViewHolder; import net.osmand.AndroidUtils; +import net.osmand.FileUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.ProgressImplementation; @@ -408,7 +409,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto String newDirectory = newStorageDirectory.getDirectory(); int type = newStorageDirectory.getType(); File newDirectoryFile = new File(newDirectory); - boolean wr = OsmandSettings.isWritable(newDirectoryFile); + boolean wr = FileUtils.isWritable(newDirectoryFile); if (wr) { app.setExternalStorageDirectory(type, newDirectory); reloadData(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java index 0cd1e628bb..3a81548285 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/GeneralProfileSettingsFragment.java @@ -22,9 +22,12 @@ import androidx.preference.PreferenceViewHolder; import androidx.preference.SwitchPreferenceCompat; import net.osmand.data.PointDescription; +import net.osmand.plus.helpers.enums.AngularConstants; +import net.osmand.plus.helpers.enums.MetricsConstants; +import net.osmand.plus.helpers.enums.SpeedConstants; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.DrivingRegion; +import net.osmand.plus.helpers.enums.DrivingRegion; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.Version; @@ -186,7 +189,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme } private void setupUnitsOfLengthPref() { - OsmandSettings.MetricsConstants[] metricsConstants = OsmandSettings.MetricsConstants.values(); + MetricsConstants[] metricsConstants = MetricsConstants.values(); String[] entries = new String[metricsConstants.length]; Integer[] entryValues = new Integer[metricsConstants.length]; @@ -208,20 +211,20 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme } private void setupAngularUnitsPref() { - OsmandSettings.AngularConstants[] ac = OsmandSettings.AngularConstants.values(); + AngularConstants[] ac = AngularConstants.values(); String[] entries = new String[ac.length]; Integer[] entryValues = new Integer[ac.length]; for (int i = 0; i < entries.length; i++) { - if (ac[i] == OsmandSettings.AngularConstants.DEGREES) { - entries[i] = OsmandSettings.AngularConstants.DEGREES.toHumanString(app) + " 180"; - entryValues[i] = OsmandSettings.AngularConstants.DEGREES.ordinal(); - } else if (ac[i] == OsmandSettings.AngularConstants.DEGREES360) { - entries[i] = OsmandSettings.AngularConstants.DEGREES.toHumanString(app) + " 360"; - entryValues[i] = OsmandSettings.AngularConstants.DEGREES360.ordinal(); + if (ac[i] == AngularConstants.DEGREES) { + entries[i] = AngularConstants.DEGREES.toHumanString(app) + " 180"; + entryValues[i] = AngularConstants.DEGREES.ordinal(); + } else if (ac[i] == AngularConstants.DEGREES360) { + entries[i] = AngularConstants.DEGREES.toHumanString(app) + " 360"; + entryValues[i] = AngularConstants.DEGREES360.ordinal(); } else { entries[i] = ac[i].toHumanString(app); - entryValues[i] = OsmandSettings.AngularConstants.MILLIRADS.ordinal(); + entryValues[i] = AngularConstants.MILLIRADS.ordinal(); } } @@ -232,7 +235,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme } private void setupSpeedSystemPref() { - OsmandSettings.SpeedConstants[] speedConstants = OsmandSettings.SpeedConstants.values(); + SpeedConstants[] speedConstants = SpeedConstants.values(); String[] entries = new String[speedConstants.length]; Integer[] entryValues = new Integer[speedConstants.length]; @@ -377,14 +380,14 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme if (mapViewTrackingUtilities != null) { mapViewTrackingUtilities.resetDrivingRegionUpdate(); } - } else if (newValue instanceof OsmandSettings.DrivingRegion) { + } else if (newValue instanceof DrivingRegion) { applyPreference(settings.DRIVING_REGION_AUTOMATIC.getId(), applyToAllProfiles, false); if (applyToAllProfiles) { for (ApplicationMode appMode : ApplicationMode.allPossibleValues()) { - settings.DRIVING_REGION.setModeValue(appMode, (OsmandSettings.DrivingRegion) newValue); + settings.DRIVING_REGION.setModeValue(appMode, (DrivingRegion) newValue); } } else { - settings.DRIVING_REGION.setModeValue(selectedMode, (OsmandSettings.DrivingRegion) newValue); + settings.DRIVING_REGION.setModeValue(selectedMode, (DrivingRegion) newValue); } } updateAllSettings(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/MapDuringNavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/MapDuringNavigationFragment.java index 06aa0c4c08..0fe5a6d6a3 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/MapDuringNavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/MapDuringNavigationFragment.java @@ -2,8 +2,8 @@ package net.osmand.plus.settings.fragments; import androidx.preference.Preference; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.AutoZoomMap; +import net.osmand.plus.helpers.enums.MetricsConstants; +import net.osmand.plus.helpers.enums.AutoZoomMap; import net.osmand.plus.R; import net.osmand.plus.settings.preferences.ListPreferenceEx; import net.osmand.plus.settings.preferences.SwitchPreferenceEx; @@ -78,7 +78,7 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment { Float[] valuesKmh = new Float[]{0f, 5f, 7f, 10f, 15f, 20f}; Float[] valuesMph = new Float[]{0f, 3f, 5f, 7f, 10f, 15f}; String[] names; - if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) { + if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == MetricsConstants.KILOMETERS_AND_METERS) { names = new String[valuesKmh.length]; for (int i = 0; i < names.length; i++) { names[i] = valuesKmh[i].intValue() + " " + getString(R.string.km_h); @@ -113,7 +113,7 @@ public class MapDuringNavigationFragment extends BaseSettingsFragment { } else { applyPreference(settings.AUTO_ZOOM_MAP.getId(), applyToAllProfiles, true); applyPreference(settings.AUTO_ZOOM_MAP_SCALE.getId(), - applyToAllProfiles, OsmandSettings.AutoZoomMap.values()[position - 1]); + applyToAllProfiles, AutoZoomMap.values()[position - 1]); } } } else { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java index 00ec37480a..12e1fba73c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java @@ -37,7 +37,6 @@ import net.osmand.plus.activities.SettingsBaseActivity; import net.osmand.plus.activities.SettingsNavigationActivity; import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.routing.RoutingHelper; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; import net.osmand.plus.settings.bottomsheets.RecalculateRouteInDeviationBottomSheet; import net.osmand.plus.settings.preferences.ListPreferenceEx; import net.osmand.plus.settings.preferences.MultiSelectBooleanPreference; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java index df1af1a693..dfed2c5930 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java @@ -14,7 +14,7 @@ import net.osmand.plus.activities.SettingsBaseActivity; import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.settings.backend.StringPreference; import net.osmand.plus.settings.bottomsheets.VehicleParametersBottomSheet; import net.osmand.plus.settings.bottomsheets.VehicleSizeAssets; import net.osmand.plus.settings.preferences.ListPreferenceEx; @@ -72,7 +72,7 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O parameter.getDescription()); String defValue = parameter.getType() == RoutingParameterType.NUMERIC ? ROUTING_PARAMETER_NUMERIC_DEFAULT : ROUTING_PARAMETER_SYMBOLIC_DEFAULT; - OsmandSettings.StringPreference pref = (OsmandSettings.StringPreference) app.getSettings() + StringPreference pref = (StringPreference) app.getSettings() .getCustomRoutingProperty(parameterId, defValue); VehicleSizeAssets assets = VehicleSizeAssets.getAssets(parameterId, routerProfile); Object[] values = parameter.getPossibleValues(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java index 4ff8f3262d..8013baeb63 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/VoiceAnnouncesFragment.java @@ -18,6 +18,7 @@ import androidx.preference.SwitchPreferenceCompat; import net.osmand.AndroidUtils; import net.osmand.plus.dialogs.SpeedCamerasBottomSheet; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; @@ -107,7 +108,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr Float[] valuesKmh = new Float[]{-10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f}; Float[] valuesMph = new Float[]{-7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f}; String[] names; - if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) { + if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == MetricsConstants.KILOMETERS_AND_METERS) { names = new String[valuesKmh.length]; for (int i = 0; i < names.length; i++) { names[i] = valuesKmh[i].intValue() + " " + getString(R.string.km_h); diff --git a/OsmAnd/src/net/osmand/plus/settings/preferences/ListPreferenceEx.java b/OsmAnd/src/net/osmand/plus/settings/preferences/ListPreferenceEx.java index b1ea56806d..07e5d088b9 100644 --- a/OsmAnd/src/net/osmand/plus/settings/preferences/ListPreferenceEx.java +++ b/OsmAnd/src/net/osmand/plus/settings/preferences/ListPreferenceEx.java @@ -8,7 +8,6 @@ import androidx.preference.DialogPreference; import androidx.preference.PreferenceDataStore; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings.PreferencesDataStore; import net.osmand.plus.settings.backend.OsmAndPreferencesDataStore; public class ListPreferenceEx extends DialogPreference { diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index 7b477176a4..5a186e75d0 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -21,7 +21,6 @@ import net.osmand.plus.DialogListItemAdapter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.TerrainMode; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java index b613d2ba13..3635aafe89 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainFragment.java @@ -43,7 +43,6 @@ import net.osmand.plus.download.DownloadValidationManager; import net.osmand.plus.download.IndexItem; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.TerrainMode; import net.osmand.plus.widgets.style.CustomTypefaceSpan; import org.apache.commons.logging.Log; @@ -55,8 +54,8 @@ import java.util.List; import static net.osmand.plus.UiUtilities.CustomRadioButtonType.*; import static net.osmand.plus.download.DownloadActivityType.HILLSHADE_FILE; import static net.osmand.plus.download.DownloadActivityType.SLOPE_FILE; -import static net.osmand.plus.settings.backend.OsmandSettings.TerrainMode.HILLSHADE; -import static net.osmand.plus.settings.backend.OsmandSettings.TerrainMode.SLOPE; +import static net.osmand.plus.srtmplugin.TerrainMode.HILLSHADE; +import static net.osmand.plus.srtmplugin.TerrainMode.SLOPE; import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MAX_ZOOM; import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MIN_ZOOM; diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java index 8f75c68259..79e47de648 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java @@ -18,7 +18,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.SQLiteTileSource; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; -import net.osmand.plus.settings.backend.OsmandSettings.TerrainMode; import net.osmand.plus.views.MapTileLayer; import net.osmand.util.Algorithms; @@ -31,7 +30,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import static net.osmand.plus.settings.backend.OsmandSettings.TerrainMode.HILLSHADE; +import static net.osmand.plus.srtmplugin.TerrainMode.HILLSHADE; public class TerrainLayer extends MapTileLayer { diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainMode.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainMode.java new file mode 100644 index 0000000000..e9f3d20d9f --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainMode.java @@ -0,0 +1,6 @@ +package net.osmand.plus.srtmplugin; + +public enum TerrainMode { + HILLSHADE, + SLOPE +} diff --git a/OsmAnd/src/net/osmand/plus/track/ShowStartFinishCard.java b/OsmAnd/src/net/osmand/plus/track/ShowStartFinishCard.java index 3941bdbb15..eaf145379c 100644 --- a/OsmAnd/src/net/osmand/plus/track/ShowStartFinishCard.java +++ b/OsmAnd/src/net/osmand/plus/track/ShowStartFinishCard.java @@ -10,8 +10,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.routepreparationmenu.cards.BaseCard; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; +import net.osmand.plus.settings.backend.OsmandPreference; class ShowStartFinishCard extends BaseCard { diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index 81a43da20f..2276d57cd2 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -41,7 +41,7 @@ import net.osmand.plus.dialogs.GpxAppearanceAdapter; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; -import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener; import net.osmand.render.RenderingRulesStorage; @@ -185,7 +185,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement } if (color == 0) { RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer(); - OsmandSettings.CommonPreference prefColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR); + CommonPreference prefColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR); color = GpxAppearanceAdapter.parseTrackColor(renderer, prefColor.get()); } trackDrawInfo.setColor(color); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 641944ce21..46d51bca33 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -50,7 +50,7 @@ import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; import net.osmand.plus.render.OsmandRenderer; import net.osmand.plus.render.OsmandRenderer.RenderingContext; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; +import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.track.SaveGpxAsyncTask; import net.osmand.plus.track.TrackDrawInfo; import net.osmand.plus.views.OsmandMapLayer; diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index 2d813e0bd9..6a4cf344c7 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -47,7 +47,7 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode; +import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; @@ -67,9 +67,6 @@ import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmAndAppCustomization; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.corenative.NativeCoreContext; diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RulerControlLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RulerControlLayer.java index 7847b6e7c3..e6f864af3d 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RulerControlLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RulerControlLayer.java @@ -29,10 +29,9 @@ import net.osmand.data.QuadPoint; import net.osmand.data.RotatedTileBox; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.settings.backend.OsmandPreference; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.AngularConstants; -import net.osmand.plus.settings.backend.OsmandSettings.RulerMode; +import net.osmand.plus.helpers.enums.AngularConstants; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.views.OsmandMapLayer; @@ -72,7 +71,7 @@ public class RulerControlLayer extends OsmandMapLayer { private QuadPoint cacheCenter; private float cacheMapDensity; private OsmandPreference mapDensity; - private OsmandSettings.MetricsConstants cacheMetricSystem; + private MetricsConstants cacheMetricSystem; private int cacheIntZoom; private LatLon cacheCenterLatLon; private long cacheMultiTouchEndTime; @@ -452,7 +451,7 @@ public class RulerControlLayer extends OsmandMapLayer { updateCenter(tb, center); } - OsmandSettings.MetricsConstants currentMetricSystem = app.getSettings().METRIC_SYSTEM.get(); + MetricsConstants currentMetricSystem = app.getSettings().METRIC_SYSTEM.get(); boolean updateCache = tb.getZoom() != cacheIntZoom || !tb.getCenterLatLon().equals(cacheCenterLatLon) || mapDensity.get() != cacheMapDensity || cacheMetricSystem != currentMetricSystem; diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RulerMode.java b/OsmAnd/src/net/osmand/plus/views/layers/RulerMode.java new file mode 100644 index 0000000000..db5d6d8e61 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/views/layers/RulerMode.java @@ -0,0 +1,7 @@ +package net.osmand.plus.views.layers; + +public enum RulerMode { + FIRST, + SECOND, + EMPTY +} diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index bf75a64bac..4aafc1b2af 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -48,9 +48,8 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider.GPSInfo; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.RulerMode; +import net.osmand.plus.views.layers.RulerMode; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; @@ -66,8 +65,6 @@ import net.osmand.plus.routepreparationmenu.ShowAlongTheRouteBottomSheet; import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.RulerMode; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.layers.RulerControlLayer; diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index 782dc4c04f..f77bc27f36 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -25,8 +25,6 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; import net.osmand.plus.routing.RoutingHelper; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.mapwidgets.widgets.AlarmWidget; diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/AlarmWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/AlarmWidget.java index a75422967d..2dc092139e 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/AlarmWidget.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/AlarmWidget.java @@ -16,6 +16,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.helpers.enums.DrivingRegion; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.routing.AlarmInfo; import net.osmand.plus.routing.RoutingHelper; @@ -40,7 +41,7 @@ public class AlarmWidget { private int imgId; private String cachedText; private String cachedBottomText; - private OsmandSettings.DrivingRegion cachedRegion; + private DrivingRegion cachedRegion; public AlarmWidget(final OsmandApplication app, MapActivity ma) { layout = ma.findViewById(R.id.map_alarm_warning); @@ -81,9 +82,9 @@ public class AlarmWidget { int locimgId = R.drawable.warnings_limit; String text = ""; String bottomText = ""; - OsmandSettings.DrivingRegion region = settings.DRIVING_REGION.get(); + DrivingRegion region = settings.DRIVING_REGION.get(); boolean americanType = region.isAmericanTypeSigns(); - boolean isCanadianRegion = region == OsmandSettings.DrivingRegion.CANADA; + boolean isCanadianRegion = region == DrivingRegion.CANADA; if (alarm.getType() == AlarmInfo.AlarmInfoType.SPEED_LIMIT) { if (isCanadianRegion) { locimgId = R.drawable.warnings_speed_limit_ca; diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/RulerWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/RulerWidget.java index 8d576c72cf..636ef0af5a 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/RulerWidget.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgets/RulerWidget.java @@ -10,7 +10,7 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; +import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/BearingWidgetState.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/BearingWidgetState.java index ce4761eab1..d3fc793ee1 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/BearingWidgetState.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/BearingWidgetState.java @@ -2,14 +2,14 @@ package net.osmand.plus.views.mapwidgets.widgetstates; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.settings.backend.OsmandPreference; public class BearingWidgetState extends WidgetState { public static final int BEARING_WIDGET_STATE_RELATIVE_BEARING = R.id.bearing_widget_state_relative_bearing; public static final int BEARING_WIDGET_STATE_MAGNETIC_BEARING = R.id.bearing_widget_state_magnetic_bearing; - private final OsmandSettings.OsmandPreference showRelativeBearing; + private final OsmandPreference showRelativeBearing; public BearingWidgetState(OsmandApplication ctx) { super(ctx); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/CompassRulerWidgetState.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/CompassRulerWidgetState.java index eb77043746..39de1d653c 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/CompassRulerWidgetState.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/CompassRulerWidgetState.java @@ -2,7 +2,7 @@ package net.osmand.plus.views.mapwidgets.widgetstates; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; +import net.osmand.plus.settings.backend.OsmandPreference; public class CompassRulerWidgetState extends WidgetState { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/TimeWidgetState.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/TimeWidgetState.java index 3274245a0c..b42d5a970d 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/TimeWidgetState.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/widgetstates/TimeWidgetState.java @@ -2,7 +2,7 @@ package net.osmand.plus.views.mapwidgets.widgetstates; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference; +import net.osmand.plus.settings.backend.OsmandPreference; public class TimeWidgetState extends WidgetState { diff --git a/OsmAnd/src/net/osmand/plus/voice/AbstractPrologCommandPlayer.java b/OsmAnd/src/net/osmand/plus/voice/AbstractPrologCommandPlayer.java index 74c0de1508..44f301945f 100644 --- a/OsmAnd/src/net/osmand/plus/voice/AbstractPrologCommandPlayer.java +++ b/OsmAnd/src/net/osmand/plus/voice/AbstractPrologCommandPlayer.java @@ -12,7 +12,7 @@ import net.osmand.StateChangedListener; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmandApplication; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants; +import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.R; import net.osmand.plus.api.AudioFocusHelper; diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java index 302140ba03..0e15c2b4a9 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleBaseDialogFragment.java @@ -13,7 +13,6 @@ import androidx.annotation.NonNull; import net.osmand.AndroidUtils; import net.osmand.IndexConstants; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.wikivoyage.WikiBaseDialogFragment; @@ -94,7 +93,7 @@ public abstract class WikiArticleBaseDialogFragment extends WikiBaseDialogFragme protected void updateWebSettings() { - OsmandSettings.WikiArticleShowImages showImages = getSettings().WIKI_ARTICLE_SHOW_IMAGES.get(); + WikiArticleShowImages showImages = getSettings().WIKI_ARTICLE_SHOW_IMAGES.get(); WebSettings webSettings = contentWebView.getSettings(); switch (showImages) { case ON: diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleShowImages.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleShowImages.java new file mode 100644 index 0000000000..ea3d8a925b --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleShowImages.java @@ -0,0 +1,15 @@ +package net.osmand.plus.wikipedia; + +import net.osmand.plus.R; + +public enum WikiArticleShowImages { + ON(R.string.shared_string_on), + OFF(R.string.shared_string_off), + WIFI(R.string.shared_string_wifi_only); + + public final int name; + + WikiArticleShowImages(int name) { + this.name = name; + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaOptionsBottomSheetDialogFragment.java index f05bb9273f..7c2b23867e 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaOptionsBottomSheetDialogFragment.java @@ -10,7 +10,6 @@ import androidx.fragment.app.Fragment; import net.osmand.plus.OsmandApplication; import net.osmand.plus.settings.backend.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.WikiArticleShowImages; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageShowPicturesDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageShowPicturesDialogFragment.java index 07c748cd28..824a2e9e49 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageShowPicturesDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageShowPicturesDialogFragment.java @@ -18,7 +18,7 @@ import androidx.fragment.app.Fragment; import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings.WikiArticleShowImages; +import net.osmand.plus.wikipedia.WikiArticleShowImages; import net.osmand.plus.R; import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.helpers.AndroidUiHelper; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index be9d3f2e58..fa704688a0 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -50,7 +50,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import static net.osmand.plus.settings.backend.OsmandSettings.WikiArticleShowImages.OFF; +import static net.osmand.plus.wikipedia.WikiArticleShowImages.OFF; public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragment { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java index ea09a79314..988598c359 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageOptionsBottomSheetDialogFragment.java @@ -16,7 +16,7 @@ import net.osmand.PicassoUtils; import net.osmand.plus.OnDialogFragmentResultListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.settings.backend.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings.WikiArticleShowImages; +import net.osmand.plus.wikipedia.WikiArticleShowImages; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;