Fix issues with routing helper

This commit is contained in:
Victor Shcherb 2019-03-17 16:52:44 +01:00
parent 2b36df6b91
commit a301490d11
4 changed files with 11 additions and 9 deletions

View file

@ -86,7 +86,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
}
}
if (routingParametersMap == null) {
routingParametersMap = generateStylesMap(app);
routingParametersMap = getRoutingParametersMap(app);
}
if (removedImpassableRoads == null) {
removedImpassableRoads = new ArrayList<LatLon>();
@ -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<Boolean> 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<String, Boolean> generateStylesMap(OsmandApplication app) {
private HashMap<String, Boolean> getRoutingParametersMap(OsmandApplication app) {
HashMap<String, Boolean> res = new HashMap<>();
List<GeneralRouter.RoutingParameter> avoidParameters = routingOptionsHelper.getAvoidRoutingPrefsForAppMode(app.getRoutingHelper().getAppMode());
for (GeneralRouter.RoutingParameter parameter : avoidParameters) {
OsmandSettings.CommonPreference<Boolean> 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;

View file

@ -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<Boolean> 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<Boolean> 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);

View file

@ -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();

View file

@ -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()));