Merge branch 'r3.3'

This commit is contained in:
Victor Shcherb 2019-03-17 16:52:52 +01:00
commit 5b11520f67
4 changed files with 11 additions and 9 deletions

View file

@ -86,7 +86,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
} }
} }
if (routingParametersMap == null) { if (routingParametersMap == null) {
routingParametersMap = generateStylesMap(app); routingParametersMap = getRoutingParametersMap(app);
} }
if (removedImpassableRoads == null) { if (removedImpassableRoads == null) {
removedImpassableRoads = new ArrayList<LatLon>(); removedImpassableRoads = new ArrayList<LatLon>();
@ -95,7 +95,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; 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); 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 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 toolbar = (Toolbar) titleView.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(getContentIcon(R.drawable.ic_arrow_back)); toolbar.setNavigationIcon(getContentIcon(R.drawable.ic_arrow_back));
@ -293,7 +293,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
if (parameter != null) { if (parameter != null) {
boolean checked = entry.getValue(); boolean checked = entry.getValue();
OsmandSettings.CommonPreference<Boolean> preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean()); 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 @NonNull
private HashMap<String, Boolean> generateStylesMap(OsmandApplication app) { private HashMap<String, Boolean> getRoutingParametersMap(OsmandApplication app) {
HashMap<String, Boolean> res = new HashMap<>(); HashMap<String, Boolean> res = new HashMap<>();
List<GeneralRouter.RoutingParameter> avoidParameters = routingOptionsHelper.getAvoidRoutingPrefsForAppMode(app.getRoutingHelper().getAppMode()); List<GeneralRouter.RoutingParameter> avoidParameters = routingOptionsHelper.getAvoidRoutingPrefsForAppMode(app.getRoutingHelper().getAppMode());
for (GeneralRouter.RoutingParameter parameter : avoidParameters) { for (GeneralRouter.RoutingParameter parameter : avoidParameters) {
OsmandSettings.CommonPreference<Boolean> preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean()); 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; return res;

View file

@ -774,7 +774,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (mapActivity == null || mainView == null) { if (mapActivity == null || mainView == null) {
return; return;
} }
OsmandApplication app = mapActivity.getMyApplication(); final OsmandApplication app = mapActivity.getMyApplication();
RoutingHelper routingHelper = app.getRoutingHelper(); RoutingHelper routingHelper = app.getRoutingHelper();
final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
final OsmandSettings settings = app.getSettings(); final OsmandSettings settings = app.getSettings();
@ -1019,7 +1019,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
for (int i = 0; i < avoidParameters.size(); i++) { for (int i = 0; i < avoidParameters.size(); i++) {
RoutingParameter p = avoidParameters.get(i); RoutingParameter p = avoidParameters.get(i);
CommonPreference<Boolean> preference = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean()); 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); avoidedParameters.add(p);
} }
} }
@ -1029,7 +1029,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
@Override @Override
public void onClick(View v) { public void onClick(View v) {
CommonPreference<Boolean> preference = settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean()); CommonPreference<Boolean> preference = settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
preference.set(false); preference.setModeValue(app.getRoutingHelper().getAppMode(), false);
avoidedParameters.remove(routingParameter); avoidedParameters.remove(routingParameter);
if (avoidedParameters.isEmpty()) { if (avoidedParameters.isEmpty()) {
mode.parameters.remove(parameter); mode.parameters.remove(parameter);

View file

@ -227,7 +227,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem); routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(); AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(true);
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE); avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG); avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu(); updateMenu();

View file

@ -308,6 +308,8 @@ public class RoutingHelper {
Location locationProjection = currentLocation; Location locationProjection = currentLocation;
if (isPublicTransportMode() && currentLocation != null && finalLocation != null && if (isPublicTransportMode() && currentLocation != null && finalLocation != null &&
(targetPointsChanged || transportRoutingHelper.getStartLocation() == null)) { (targetPointsChanged || transportRoutingHelper.getStartLocation() == null)) {
lastFixedLocation = currentLocation;
lastProjection = locationProjection;
transportRoutingHelper.setApplicationMode(mode); transportRoutingHelper.setApplicationMode(mode);
transportRoutingHelper.setFinalAndCurrentLocation(finalLocation, transportRoutingHelper.setFinalAndCurrentLocation(finalLocation,
new LatLon(currentLocation.getLatitude(), currentLocation.getLongitude())); new LatLon(currentLocation.getLatitude(), currentLocation.getLongitude()));