diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index f3a1ebf203..25ee7cc407 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -12,6 +12,7 @@
-->
+ In case of reverse direction
Select a track file for which a new segment will be added.
Navigation profile
Threshold distance
diff --git a/OsmAnd/res/xml/accessibility_settings.xml b/OsmAnd/res/xml/accessibility_settings.xml
index 3c1096fe37..0afc4fae17 100644
--- a/OsmAnd/res/xml/accessibility_settings.xml
+++ b/OsmAnd/res/xml/accessibility_settings.xml
@@ -47,29 +47,6 @@
android:layout="@layout/simple_divider_item"
android:selectable="false" />
-
-
-
-
-
-
-
-
0 && wrongMovementDirection && !isStraight
- && (currentLocation.distanceTo(routeNodes.get(currentRoute)) > allowableDeviation)) {
+ if ((allowableDeviation > 0 && wrongMovementDirection && !isStraight
+ && (currentLocation.distanceTo(routeNodes.get(currentRoute)) > allowableDeviation)) && !settings.DISABLE_WRONG_DIRECTION_RECALC.get()) {
log.info("Recalculate route, because wrong movement direction: " + currentLocation.distanceTo(routeNodes.get(currentRoute))); //$NON-NLS-1$
isDeviatedFromRoute = true;
calculateRoute = true;
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java
index e584c367a1..70f6110928 100644
--- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java
@@ -1892,8 +1892,8 @@ public class OsmandSettings {
new BooleanAccessibilityPreference("disable_offroute_recalc", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
-// public final OsmandPreference DISABLE_WRONG_DIRECTION_RECALC =
-// new BooleanAccessibilityPreference("disable_wrong_direction_recalc", false).makeProfile();
+ public final OsmandPreference DISABLE_WRONG_DIRECTION_RECALC =
+ new BooleanAccessibilityPreference("disable_wrong_direction_recalc", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference DIRECTION_AUDIO_FEEDBACK =
diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java
index 360e98e845..8c7052983e 100644
--- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java
@@ -8,6 +8,7 @@ import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
@@ -16,6 +17,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import androidx.preference.PreferenceViewHolder;
@@ -61,6 +63,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
private static final String RELIEF_SMOOTHNESS_FACTOR = "relief_smoothness_factor";
private static final String ROUTING_SHORT_WAY = "prouting_short_way";
private static final String ROUTING_RECALC_DISTANCE= "routing_recalc_distance";
+ private static final String ROUTING_RECALC_WRONG_DIRECTION= "disable_wrong_direction_recalc";
public static final float DISABLE_MODE = -1.0f;
public static final float DEFAULT_MODE = 0.0f;
@@ -156,8 +159,6 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
fastRoute.setSummaryOn(R.string.shared_string_on);
fastRoute.setSummaryOff(R.string.shared_string_off);
- setupSelectRouteRecalcDistance(screen);
-
if (am.getRouteService() == RouteProvider.RouteService.OSMAND){
GeneralRouter router = app.getRouter(am);
clearParameters();
@@ -260,6 +261,36 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
straightAngle.setIcon(getRoutingPrefIcon("routing_recalc_distance")); //TODO change for appropriate icon when available
getPreferenceScreen().addPreference(straightAngle);
}
+
+ addDivider(screen);
+ addRouteRecalcHeader(screen);
+ setupSelectRouteRecalcDistance(screen);
+ setupReverseDirectionRecalculation(screen);
+ }
+
+ private void addDivider(PreferenceScreen screen) {
+ Preference divider = new Preference(requireContext());
+ divider.setLayoutResource(R.layout.simple_divider_item);
+ screen.addPreference(divider);
+ }
+
+ private void setupReverseDirectionRecalculation(PreferenceScreen screen) {
+ SwitchPreferenceEx recalcRouteReverseDirectionPreference =
+ createSwitchPreferenceEx(app.getSettings().DISABLE_WRONG_DIRECTION_RECALC.getId(),
+ R.string.in_case_of_reverse_direction,
+ R.layout.preference_with_descr_dialog_and_switch);
+ recalcRouteReverseDirectionPreference.setIcon(
+ getRoutingPrefIcon(app.getSettings().DISABLE_WRONG_DIRECTION_RECALC.getId()));
+ recalcRouteReverseDirectionPreference.setSummaryOn(R.string.shared_string_on);
+ recalcRouteReverseDirectionPreference.setSummaryOff(R.string.shared_string_off);
+ screen.addPreference(recalcRouteReverseDirectionPreference);
+ }
+
+ private void addRouteRecalcHeader(PreferenceScreen screen) {
+ PreferenceCategory routingCategory = new PreferenceCategory(requireContext());
+ routingCategory.setLayoutResource(R.layout.preference_category_with_descr);
+ routingCategory.setTitle(R.string.recalculate_route);
+ screen.addPreference(routingCategory);
}
@Override
@@ -544,7 +575,8 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
return getPersistentPrefIcon(R.drawable.ic_action_road_works_dark);
case ROUTING_RECALC_DISTANCE:
return getPersistentPrefIcon(R.drawable.ic_action_minimal_distance);
-
+ case ROUTING_RECALC_WRONG_DIRECTION:
+ return getPersistentPrefIcon(R.drawable.ic_action_reverse_direction);
default:
return null;
}