no route recalculation wrong direction issue fix

This commit is contained in:
simon 2020-08-13 16:40:20 +03:00
parent 8d9e5423df
commit 58d005bdf7
5 changed files with 40 additions and 30 deletions

View file

@ -12,6 +12,7 @@
--> -->
<string name="in_case_of_reverse_direction">In case of reverse direction</string>
<string name="rourte_between_points_add_track_desc">Select a track file for which a new segment will be added.</string> <string name="rourte_between_points_add_track_desc">Select a track file for which a new segment will be added.</string>
<string name="navigation_profile">Navigation profile</string> <string name="navigation_profile">Navigation profile</string>
<string name="threshold_distance">Threshold distance</string> <string name="threshold_distance">Threshold distance</string>

View file

@ -47,29 +47,6 @@
android:layout="@layout/simple_divider_item" android:layout="@layout/simple_divider_item"
android:selectable="false" /> android:selectable="false" />
<PreferenceCategory
android:key="route_recalculation"
android:layout="@layout/preference_category_with_descr"
android:title="@string/route_recalculation" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="disable_offroute_recalc"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/access_disable_offroute_recalc" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="disable_wrong_direction_recalc"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/access_disable_wrong_direction_recalc" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<net.osmand.plus.settings.preferences.ListPreferenceEx <net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="direction_style" android:key="direction_style"
android:layout="@layout/preference_with_descr" android:layout="@layout/preference_with_descr"

View file

@ -477,8 +477,8 @@ public class RoutingHelper {
boolean isStraight = boolean isStraight =
route.getRouteService() == RouteService.DIRECT_TO || route.getRouteService() == RouteService.STRAIGHT; route.getRouteService() == RouteService.DIRECT_TO || route.getRouteService() == RouteService.STRAIGHT;
boolean wrongMovementDirection = checkWrongMovementDirection(currentLocation, next); boolean wrongMovementDirection = checkWrongMovementDirection(currentLocation, next);
if (allowableDeviation > 0 && wrongMovementDirection && !isStraight if ((allowableDeviation > 0 && wrongMovementDirection && !isStraight
&& (currentLocation.distanceTo(routeNodes.get(currentRoute)) > allowableDeviation)) { && (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$ log.info("Recalculate route, because wrong movement direction: " + currentLocation.distanceTo(routeNodes.get(currentRoute))); //$NON-NLS-1$
isDeviatedFromRoute = true; isDeviatedFromRoute = true;
calculateRoute = true; calculateRoute = true;

View file

@ -1892,8 +1892,8 @@ public class OsmandSettings {
new BooleanAccessibilityPreference("disable_offroute_recalc", false).makeProfile(); new BooleanAccessibilityPreference("disable_offroute_recalc", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
// public final OsmandPreference<Boolean> DISABLE_WRONG_DIRECTION_RECALC = public final OsmandPreference<Boolean> DISABLE_WRONG_DIRECTION_RECALC =
// new BooleanAccessibilityPreference("disable_wrong_direction_recalc", false).makeProfile(); new BooleanAccessibilityPreference("disable_wrong_direction_recalc", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> DIRECTION_AUDIO_FEEDBACK = public final OsmandPreference<Boolean> DIRECTION_AUDIO_FEEDBACK =

View file

@ -8,6 +8,7 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -16,6 +17,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import androidx.preference.PreferenceViewHolder; 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 RELIEF_SMOOTHNESS_FACTOR = "relief_smoothness_factor";
private static final String ROUTING_SHORT_WAY = "prouting_short_way"; 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_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 DISABLE_MODE = -1.0f;
public static final float DEFAULT_MODE = 0.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.setSummaryOn(R.string.shared_string_on);
fastRoute.setSummaryOff(R.string.shared_string_off); fastRoute.setSummaryOff(R.string.shared_string_off);
setupSelectRouteRecalcDistance(screen);
if (am.getRouteService() == RouteProvider.RouteService.OSMAND){ if (am.getRouteService() == RouteProvider.RouteService.OSMAND){
GeneralRouter router = app.getRouter(am); GeneralRouter router = app.getRouter(am);
clearParameters(); 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 straightAngle.setIcon(getRoutingPrefIcon("routing_recalc_distance")); //TODO change for appropriate icon when available
getPreferenceScreen().addPreference(straightAngle); 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 @Override
@ -544,7 +575,8 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
return getPersistentPrefIcon(R.drawable.ic_action_road_works_dark); return getPersistentPrefIcon(R.drawable.ic_action_road_works_dark);
case ROUTING_RECALC_DISTANCE: case ROUTING_RECALC_DISTANCE:
return getPersistentPrefIcon(R.drawable.ic_action_minimal_distance); return getPersistentPrefIcon(R.drawable.ic_action_minimal_distance);
case ROUTING_RECALC_WRONG_DIRECTION:
return getPersistentPrefIcon(R.drawable.ic_action_reverse_direction);
default: default:
return null; return null;
} }