From a301490d117e9e43ec13208fd1bdcdaaa9d4b0a8 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 17 Mar 2019 16:52:44 +0100 Subject: [PATCH] Fix issues with routing helper --- .../AvoidRoadsBottomSheetDialogFragment.java | 10 +++++----- .../plus/routepreparationmenu/MapRouteInfoMenu.java | 6 +++--- .../routepreparationmenu/RouteOptionsBottomSheet.java | 2 +- OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java | 2 ++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java index 7bda8e71d6..2a1102d289 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java @@ -86,7 +86,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr } } if (routingParametersMap == null) { - routingParametersMap = generateStylesMap(app); + routingParametersMap = getRoutingParametersMap(app); } if (removedImpassableRoads == null) { removedImpassableRoads = new ArrayList(); @@ -95,7 +95,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final View titleView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_item_toolbar_title, null); TextView textView = (TextView) titleView.findViewById(R.id.title); - textView.setText(R.string.impassable_road); + textView.setText(!hideImpassableRoads ? R.string.impassable_road : R.string.avoid_pt_types); Toolbar toolbar = (Toolbar) titleView.findViewById(R.id.toolbar); toolbar.setNavigationIcon(getContentIcon(R.drawable.ic_arrow_back)); @@ -293,7 +293,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr if (parameter != null) { boolean checked = entry.getValue(); OsmandSettings.CommonPreference preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean()); - preference.set(checked); + preference.setModeValue(app.getRoutingHelper().getAppMode(), checked); } } @@ -317,13 +317,13 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr } @NonNull - private HashMap generateStylesMap(OsmandApplication app) { + private HashMap getRoutingParametersMap(OsmandApplication app) { HashMap res = new HashMap<>(); List avoidParameters = routingOptionsHelper.getAvoidRoutingPrefsForAppMode(app.getRoutingHelper().getAppMode()); for (GeneralRouter.RoutingParameter parameter : avoidParameters) { OsmandSettings.CommonPreference preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean()); - res.put(parameter.getId(), preference.get()); + res.put(parameter.getId(), preference.getModeValue(app.getRoutingHelper().getAppMode())); } return res; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 7d282f9f43..a763d11b1b 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -774,7 +774,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener if (mapActivity == null || mainView == null) { return; } - OsmandApplication app = mapActivity.getMyApplication(); + final OsmandApplication app = mapActivity.getMyApplication(); RoutingHelper routingHelper = app.getRoutingHelper(); final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); final OsmandSettings settings = app.getSettings(); @@ -1019,7 +1019,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener for (int i = 0; i < avoidParameters.size(); i++) { RoutingParameter p = avoidParameters.get(i); CommonPreference preference = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean()); - if (preference != null && preference.get()) { + if (preference != null && preference.getModeValue(app.getRoutingHelper().getAppMode())) { avoidedParameters.add(p); } } @@ -1029,7 +1029,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener @Override public void onClick(View v) { CommonPreference preference = settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean()); - preference.set(false); + preference.setModeValue(app.getRoutingHelper().getAppMode(), false); avoidedParameters.remove(routingParameter); if (avoidedParameters.isEmpty()) { mode.parameters.remove(parameter); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java index 53ed92288b..a2d10852d2 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java @@ -227,7 +227,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { @Override public void onClick(View view) { routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem); - AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(); + AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(true); avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE); avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG); updateMenu(); diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 90289963f8..0742f56ca6 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -308,6 +308,8 @@ public class RoutingHelper { Location locationProjection = currentLocation; if (isPublicTransportMode() && currentLocation != null && finalLocation != null && (targetPointsChanged || transportRoutingHelper.getStartLocation() == null)) { + lastFixedLocation = currentLocation; + lastProjection = locationProjection; transportRoutingHelper.setApplicationMode(mode); transportRoutingHelper.setFinalAndCurrentLocation(finalLocation, new LatLon(currentLocation.getLatitude(), currentLocation.getLongitude()));