From 84a15eda11e137ad30bec5da0aa5b2f21da58d23 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 4 Nov 2019 13:13:33 +0200 Subject: [PATCH 1/2] Make some preferences profile dependent --- .../src/net/osmand/plus/OsmandSettings.java | 45 +++++++++---------- .../plus/views/MapQuickActionLayer.java | 3 ++ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 278deda80f..ee5ad7a75e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1725,12 +1725,12 @@ public class OsmandSettings { public final CommonPreference GPS_STATUS_APP = new StringPreference("gps_status_app", "").makeGlobal(); // this value string is synchronized with settings_pref.xml preference name - public final OsmandPreference SHOW_OSM_BUGS = new BooleanPreference("show_osm_bugs", false).makeGlobal(); + public final OsmandPreference SHOW_OSM_BUGS = new BooleanPreference("show_osm_bugs", false).makeProfile().cache(); public final OsmandPreference SHOW_OSM_EDITS = new BooleanPreference("show_osm_edits", true).makeProfile().cache(); - public final CommonPreference SHOW_CLOSED_OSM_BUGS = new BooleanPreference("show_closed_osm_bugs", false).makeGlobal(); - public final CommonPreference SHOW_OSM_BUGS_MIN_ZOOM = new IntPreference("show_osm_bugs_min_zoom", 8).makeGlobal(); + public final CommonPreference SHOW_CLOSED_OSM_BUGS = new BooleanPreference("show_closed_osm_bugs", false).makeProfile().cache(); + public final CommonPreference SHOW_OSM_BUGS_MIN_ZOOM = new IntPreference("show_osm_bugs_min_zoom", 8).makeProfile().cache(); public final CommonPreference MAP_INFO_CONTROLS = new StringPreference("map_info_controls", "").makeProfile(); { @@ -1744,7 +1744,7 @@ public class OsmandSettings { public final OsmandPreference DEBUG_RENDERING_INFO = new BooleanPreference("debug_rendering", false).makeGlobal(); // this value string is synchronized with settings_pref.xml preference name - public final OsmandPreference SHOW_FAVORITES = new BooleanPreference("show_favorites", true).makeGlobal().cache(); + public final OsmandPreference SHOW_FAVORITES = new BooleanPreference("show_favorites", true).makeProfile().cache(); public final CommonPreference SHOW_ZOOM_BUTTONS_NAVIGATION = new BooleanPreference("show_zoom_buttons_navigation", false).makeProfile().cache(); @@ -1874,7 +1874,7 @@ public class OsmandSettings { public final CommonPreference HILLSHADE = new BooleanPreference("hillshade_layer", true).makeProfile(); - public final CommonPreference CONTOUR_LINES_ZOOM = new StringPreference("contour_lines_zoom", null).makeGlobal().cache(); + public final CommonPreference CONTOUR_LINES_ZOOM = new StringPreference("contour_lines_zoom", null).makeProfile().cache(); // this value string is synchronized with settings_pref.xml preference name public final CommonPreference MAP_OVERLAY = new StringPreference("map_overlay", null).makeProfile().cache(); @@ -1883,12 +1883,10 @@ public class OsmandSettings { public final CommonPreference MAP_UNDERLAY = new StringPreference("map_underlay", null).makeProfile().cache(); // this value string is synchronized with settings_pref.xml preference name - public final CommonPreference MAP_OVERLAY_TRANSPARENCY = new IntPreference("overlay_transparency", - 100).makeGlobal().cache(); + public final CommonPreference MAP_OVERLAY_TRANSPARENCY = new IntPreference("overlay_transparency", 100).makeProfile().cache(); // this value string is synchronized with settings_pref.xml preference name - public final CommonPreference MAP_TRANSPARENCY = new IntPreference("map_transparency", - 255).makeGlobal().cache(); + public final CommonPreference MAP_TRANSPARENCY = new IntPreference("map_transparency", 255).makeProfile().cache(); // this value string is synchronized with settings_pref.xml preference name public final CommonPreference MAP_TILE_SOURCES = new StringPreference("map_tile_sources", @@ -2832,34 +2830,35 @@ 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 StringPreference("quick_action_new", "").makeGlobal(); + public final CommonPreference QUICK_ACTION = new StringPreference("quick_action_new", "").makeProfile(); public final CommonPreference QUICK_ACTION_LIST = new StringPreference("quick_action_list", "").makeGlobal(); public final CommonPreference IS_QUICK_ACTION_TUTORIAL_SHOWN = new BooleanPreference("quick_action_tutorial", false).makeGlobal(); + private final CommonPreference QUICK_ACTION_FAB_MARGIN_X_PORTRAIT = new IntPreference(QUICK_FAB_MARGIN_X_PORTRAIT_MARGIN, 0).makeProfile(); + private final CommonPreference QUICK_ACTION_FAB_MARGIN_Y_PORTRAIT = new IntPreference(QUICK_FAB_MARGIN_Y_PORTRAIT_MARGIN, 0).makeProfile(); + private final CommonPreference QUICK_ACTION_FAB_MARGIN_X_LANDSCAPE_MARGIN = new IntPreference(QUICK_FAB_MARGIN_X_LANDSCAPE_MARGIN, 0).makeProfile(); + private final CommonPreference QUICK_ACTION_FAB_MARGIN_Y_LANDSCAPE_MARGIN = new IntPreference(QUICK_FAB_MARGIN_Y_LANDSCAPE_MARGIN, 0).makeProfile(); + public boolean setPortraitFabMargin(int x, int y) { - return settingsAPI.edit(globalPreferences).putInt(QUICK_FAB_MARGIN_X_PORTRAIT_MARGIN, x) - .putInt(QUICK_FAB_MARGIN_Y_PORTRAIT_MARGIN, y).commit(); + return QUICK_ACTION_FAB_MARGIN_X_PORTRAIT.set(x) && QUICK_ACTION_FAB_MARGIN_Y_PORTRAIT.set(y); } public boolean setLandscapeFabMargin(int x, int y) { - return settingsAPI.edit(globalPreferences).putInt(QUICK_FAB_MARGIN_X_LANDSCAPE_MARGIN, x) - .putInt(QUICK_FAB_MARGIN_Y_LANDSCAPE_MARGIN, y).commit(); + return QUICK_ACTION_FAB_MARGIN_X_LANDSCAPE_MARGIN.set(x) && QUICK_ACTION_FAB_MARGIN_Y_LANDSCAPE_MARGIN.set(y); } public Pair getPortraitFabMargin() { - if (settingsAPI.contains(globalPreferences, QUICK_FAB_MARGIN_X_PORTRAIT_MARGIN) && settingsAPI.contains(globalPreferences, QUICK_FAB_MARGIN_Y_PORTRAIT_MARGIN)) { - return new Pair<>(settingsAPI.getInt(globalPreferences, QUICK_FAB_MARGIN_X_PORTRAIT_MARGIN, 0), - settingsAPI.getInt(globalPreferences, QUICK_FAB_MARGIN_Y_PORTRAIT_MARGIN, 0)); + if (QUICK_ACTION_FAB_MARGIN_X_PORTRAIT.isSet() && QUICK_ACTION_FAB_MARGIN_Y_PORTRAIT.isSet()) { + return new Pair<>(QUICK_ACTION_FAB_MARGIN_X_PORTRAIT.get(), QUICK_ACTION_FAB_MARGIN_Y_PORTRAIT.get()); } return null; } public Pair getLandscapeFabMargin() { - if (settingsAPI.contains(globalPreferences, QUICK_FAB_MARGIN_X_LANDSCAPE_MARGIN) && settingsAPI.contains(globalPreferences, QUICK_FAB_MARGIN_Y_LANDSCAPE_MARGIN)) { - return new Pair<>(settingsAPI.getInt(globalPreferences, QUICK_FAB_MARGIN_X_LANDSCAPE_MARGIN, 0), - settingsAPI.getInt(globalPreferences, QUICK_FAB_MARGIN_Y_LANDSCAPE_MARGIN, 0)); + if (QUICK_ACTION_FAB_MARGIN_X_LANDSCAPE_MARGIN.isSet() && QUICK_ACTION_FAB_MARGIN_Y_LANDSCAPE_MARGIN.isSet()) { + return new Pair<>(QUICK_ACTION_FAB_MARGIN_X_LANDSCAPE_MARGIN.get(), QUICK_ACTION_FAB_MARGIN_Y_LANDSCAPE_MARGIN.get()); } return null; } @@ -3134,13 +3133,13 @@ public class OsmandSettings { (ListStringPreference) new ListStringPreference("transport_default_settings", "transportStops", ",").makeProfile(); public final OsmandPreference SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME = - new BooleanPreference("show_arrival_time", true).makeGlobal(); + new BooleanPreference("show_arrival_time", true).makeProfile(); public final OsmandPreference SHOW_INTERMEDIATE_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME = - new BooleanPreference("show_intermediate_arrival_time", true).makeGlobal(); + new BooleanPreference("show_intermediate_arrival_time", true).makeProfile(); public final OsmandPreference SHOW_RELATIVE_BEARING_OTHERWISE_REGULAR_BEARING = - new BooleanPreference("show_relative_bearing", true).makeGlobal(); + new BooleanPreference("show_relative_bearing", true).makeProfile(); public final OsmandPreference AGPS_DATA_LAST_TIME_DOWNLOADED = new LongPreference("agps_data_downloaded", 0).makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java b/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java index 07f0661289..01c85a216f 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java @@ -137,6 +137,9 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe setLayerState(false); isLayerOn = quickActionRegistry.isQuickActionOn(); setupQuickActionBtnVisibility(); + if (isLayerOn) { + setQuickActionButtonMargin(); + } } private boolean showTutorialIfNeeded() { From a9cf8f25b50d8bd4c6e9560eb25e9b1344fb9c47 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 4 Nov 2019 13:21:23 +0200 Subject: [PATCH 2/2] Set minSdkVersion to 15 --- OsmAnd/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 666be451f5..4d52e76344 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -43,7 +43,7 @@ android { } defaultConfig { - minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 14 + minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15 targetSdkVersion 28 versionCode 350 versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode