From defff46e4cd6d14a5209af17db74f4137e93dbbb Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 19 Nov 2019 14:07:41 +0200 Subject: [PATCH 1/2] Fix possible npe --- .../plus/activities/SettingsNavigationActivity.java | 9 ++++----- .../osmand/plus/settings/VehicleParametersFragment.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index ec9239f8f1..9f23747ad0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -664,9 +664,9 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { }); return true; } else if (preference == defaultSpeed) { - showSeekbarSettingsDialog(this, false); + showSeekbarSettingsDialog(this, false, settings.getApplicationMode()); } else if (preference == defaultSpeedOnly) { - showSeekbarSettingsDialog(this, true); + showSeekbarSettingsDialog(this, true, settings.getApplicationMode()); } return false; } @@ -720,14 +720,13 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { return bld.show(); } - public static void showSeekbarSettingsDialog(Activity activity, final boolean defaultSpeedOnly) { - if (activity == null) { + public static void showSeekbarSettingsDialog(Activity activity, final boolean defaultSpeedOnly, final ApplicationMode mode) { + if (activity == null || mode == null) { return; } final OsmandApplication app = (OsmandApplication) activity.getApplication(); final OsmandSettings settings = app.getSettings(); - final ApplicationMode mode = settings.getApplicationMode(); GeneralRouter router = getRouter(app.getRoutingConfig(), mode); SpeedConstants units = settings.SPEED_SYSTEM.get(); String speedUnits = units.toShortString(activity); diff --git a/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java index a376145c6f..c0d3cff143 100644 --- a/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/VehicleParametersFragment.java @@ -102,7 +102,7 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O public boolean onPreferenceClick(Preference preference) { if (preference.getKey().equals(GeneralRouter.DEFAULT_SPEED)) { RouteService routeService = getSelectedAppMode().getRouteService(); - showSeekbarSettingsDialog(getActivity(), routeService == RouteService.STRAIGHT); + showSeekbarSettingsDialog(getActivity(), routeService == RouteService.STRAIGHT, getSelectedAppMode()); return true; } return super.onPreferenceClick(preference); From f149bed8cd59d90e99261e59df566c13e0457da4 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 20 Nov 2019 10:32:40 +0200 Subject: [PATCH 2/2] Fix quick action --- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 02528208d6..26bdd7f245 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -2861,7 +2861,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 StringPreference("quick_action_new", "").makeProfile(); + public final CommonPreference QUICK_ACTION = new StringPreference("quick_action_new", "").makeGlobal(); public final CommonPreference QUICK_ACTION_LIST = new StringPreference("quick_action_list", "").makeGlobal();