From 33a2565c41545c9ea7619ba8ce90261cacb4b634 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Thu, 1 Apr 2021 20:49:49 +0300 Subject: [PATCH] Fix #11206 --- .../backend/OsmAndPreferencesDataStore.java | 6 +++-- .../fragments/RouteParametersFragment.java | 26 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java index 6e493ad34f..9c69b48b2c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndPreferencesDataStore.java @@ -43,7 +43,8 @@ public class OsmAndPreferencesDataStore extends PreferenceDataStore { @Override public void putBoolean(String key, boolean value) { - if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(key)) { + if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(key) + || osmandSettings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(key)) { osmandSettings.setPreference(key, !value, appMode); } else { osmandSettings.setPreference(key, value, appMode); @@ -107,7 +108,8 @@ public class OsmAndPreferencesDataStore extends PreferenceDataStore { OsmandPreference preference = osmandSettings.getPreference(key); if (preference instanceof BooleanPreference) { BooleanPreference booleanPreference = (BooleanPreference) preference; - if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(booleanPreference.getId())) { + if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(booleanPreference.getId()) + || osmandSettings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(booleanPreference.getId())) { return !booleanPreference.getModeValue(appMode); } return booleanPreference.getModeValue(appMode); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java index eb4f09f4aa..6f7a974ddd 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java @@ -31,9 +31,8 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; -import net.osmand.plus.routing.RouteService; import net.osmand.plus.development.OsmandDevelopmentPlugin; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.BooleanPreference; @@ -357,15 +356,14 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP } private void setupReverseDirectionRecalculation(PreferenceScreen screen) { - SwitchPreferenceEx recalcRouteReverseDirectionPreference = - createSwitchPreferenceEx(settings.DISABLE_WRONG_DIRECTION_RECALC.getId(), - R.string.in_case_of_reverse_direction, - R.layout.preference_with_descr_dialog_and_switch); - recalcRouteReverseDirectionPreference.setIcon( - getRoutingPrefIcon(settings.DISABLE_WRONG_DIRECTION_RECALC.getId())); - recalcRouteReverseDirectionPreference.setSummaryOn(R.string.shared_string_enabled); - recalcRouteReverseDirectionPreference.setSummaryOff(R.string.shared_string_disabled); - screen.addPreference(recalcRouteReverseDirectionPreference); + OsmandPreference preference = settings.DISABLE_WRONG_DIRECTION_RECALC; + SwitchPreferenceEx switchPreference = createSwitchPreferenceEx(preference.getId(), + R.string.in_case_of_reverse_direction, + R.layout.preference_with_descr_dialog_and_switch); + switchPreference.setIcon(getRoutingPrefIcon(preference.getId())); + switchPreference.setSummaryOn(R.string.shared_string_enabled); + switchPreference.setSummaryOff(R.string.shared_string_disabled); + screen.addPreference(switchPreference); } private void setupRouteRecalcHeader(PreferenceScreen screen) { @@ -546,7 +544,9 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - if (settings.DISABLE_COMPLEX_ROUTING.getId().equals(preference.getKey()) && newValue instanceof Boolean) { + if ((settings.DISABLE_COMPLEX_ROUTING.getId().equals(preference.getKey()) || + settings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(preference.getKey())) && + newValue instanceof Boolean) { return onConfirmPreferenceChange(preference.getKey(), !(Boolean) newValue, getApplyQueryType()); // pref ui was inverted } return onConfirmPreferenceChange(preference.getKey(), newValue, getApplyQueryType()); @@ -573,8 +573,6 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP applyPreference(ROUTING_RECALC_DISTANCE, applyToAllProfiles, valueToSave); applyPreference(settings.DISABLE_OFFROUTE_RECALC.getId(), applyToAllProfiles, !enabled); updateRouteRecalcDistancePref(); - } else if (settings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(prefId)) { - applyPreference(settings.DISABLE_WRONG_DIRECTION_RECALC.getId(), applyToAllProfiles, newValue); } else { super.onApplyPreferenceChange(prefId, applyToAllProfiles, newValue); }