use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter in project Osmand by osmandapp.
the class MapRouteInfoMenu method updateStartPointView.
private void updateStartPointView() {
MapActivity mapActivity = getMapActivity();
final View mainView = getMainView();
if (mapActivity == null || mainView == null) {
return;
}
setupFromText(mainView);
View fromLayout = mainView.findViewById(R.id.FromLayout);
fromLayout.setOnClickListener(v -> {
MapActivity mapActv = getMapActivity();
if (mapActv != null) {
AddPointBottomSheetDialog.showInstance(mapActv, PointType.START);
}
});
FrameLayout fromButton = mainView.findViewById(R.id.from_button);
boolean isFollowTrack = mapActivity.getMyApplication().getRoutingHelper().getCurrentGPXRoute() != null;
if (isFollowTrack) {
fromButton.setVisibility(View.GONE);
} else {
fromButton.setVisibility(View.VISIBLE);
}
LinearLayout fromButtonContainer = mainView.findViewById(R.id.from_button_container);
setupButtonBackground(fromButton, fromButtonContainer);
ImageView swapDirectionView = mainView.findViewById(R.id.from_button_image_view);
setupButtonIcon(swapDirectionView, R.drawable.ic_action_change_navigation_points);
fromButton.setOnClickListener(view -> {
MapActivity mapActv = getMapActivity();
if (mapActv != null) {
OsmandApplication app = mapActv.getMyApplication();
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
TargetPoint startPoint = targetPointsHelper.getPointToStart();
TargetPoint endPoint = targetPointsHelper.getPointToNavigate();
Location loc = app.getLocationProvider().getLastKnownLocation();
if (loc == null && startPoint == null && endPoint == null) {
app.showShortToastMessage(R.string.add_start_and_end_points);
} else if (endPoint == null) {
app.showShortToastMessage(R.string.mark_final_location_first);
} else {
GPXRouteParamsBuilder gpxParams = app.getRoutingHelper().getCurrentGPXRoute();
if (gpxParams != null) {
boolean reverse = !gpxParams.isReverse();
LocalRoutingParameter parameter = new OtherLocalRoutingParameter(R.string.gpx_option_reverse_route, app.getString(R.string.gpx_option_reverse_route), reverse);
app.getRoutingOptionsHelper().applyRoutingParameter(parameter, reverse);
} else {
if (startPoint == null && loc != null) {
startPoint = TargetPoint.createStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()), new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION, mapActv.getString(R.string.shared_string_my_location)));
}
if (startPoint != null) {
int intermediateSize = targetPointsHelper.getIntermediatePoints().size();
if (intermediateSize > 1) {
WaypointDialogHelper.reverseAllPoints(app, mapActv, mapActv.getDashboard().getWaypointDialogHelper());
} else {
WaypointDialogHelper.switchStartAndFinish(mapActv.getMyApplication(), mapActv, mapActv.getDashboard().getWaypointDialogHelper(), true);
}
} else {
app.showShortToastMessage(R.string.route_add_start_point);
}
}
}
}
});
updateFromIcon(mainView);
final View textView = mainView.findViewById(R.id.from_button_description);
if (!swapButtonCollapsing && !swapButtonCollapsed && fromButton.getVisibility() == View.VISIBLE && textView.getVisibility() == View.VISIBLE) {
swapButtonCollapsing = true;
collapseButtonAnimated(R.id.from_button, R.id.from_button_description, success -> {
swapButtonCollapsing = false;
swapButtonCollapsed = success;
});
} else if (swapButtonCollapsed) {
textView.setVisibility(View.GONE);
}
}
use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter in project Osmand by osmandapp.
the class RoutePreferencesMenu method updateParameters.
private void updateParameters() {
// ApplicationMode am = settings.APPLICATION_MODE.get();
ApplicationMode am = routingHelper.getAppMode();
listAdapter.setNotifyOnChange(false);
listAdapter.clear();
for (LocalRoutingParameter r : routingOptionsHelper.getAllRoutingParameters(am)) {
listAdapter.add(r);
}
listAdapter.notifyDataSetChanged();
}
use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter in project Osmand by osmandapp.
the class MapRouteInfoMenu method createAvoidRoadsRoutingParameterButton.
private void createAvoidRoadsRoutingParameterButton(MapActivity mapActivity, final LocalRoutingParameter parameter, final RouteMenuAppModes mode, LinearLayout optionsContainer) {
OsmandApplication app = mapActivity.getMyApplication();
final LinearLayout item = createToolbarOptionView(false, null, -1, -1, null);
if (item != null) {
item.findViewById(R.id.route_option_container).setVisibility(View.GONE);
Map<LatLon, AvoidRoadInfo> impassableRoads = new HashMap<>();
if (parameter instanceof AvoidRoadsRoutingParameter) {
impassableRoads = app.getAvoidSpecificRoads().getImpassableRoads();
}
final List<RoutingParameter> avoidedParameters = getAvoidedParameters(app);
createImpassableRoadsItems(mapActivity, impassableRoads, parameter, mode, item);
createAvoidParametersItems(mapActivity, avoidedParameters, parameter, mode, item);
if (avoidedParameters.size() > 0 || impassableRoads.size() > 0) {
optionsContainer.addView(item, getContainerButtonLayoutParams(mapActivity, true));
}
}
}
use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter in project Osmand by osmandapp.
the class MapRouteInfoMenu method createAvoidParametersItems.
private void createAvoidParametersItems(MapActivity mapActivity, final List<RoutingParameter> avoidedParameters, final LocalRoutingParameter parameter, final RouteMenuAppModes mode, final LinearLayout item) {
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
for (int i = 0; i < avoidedParameters.size(); i++) {
final RoutingParameter routingParameter = avoidedParameters.get(i);
final View container = createToolbarSubOptionView(false, AndroidUtils.getRoutingStringPropertyName(app, routingParameter.getId(), routingParameter.getName()), R.drawable.ic_action_remove_dark, i == avoidedParameters.size() - 1, v -> {
OsmandApplication app = getApp();
if (app == null) {
return;
}
CommonPreference<Boolean> preference = settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
preference.setModeValue(app.getRoutingHelper().getAppMode(), false);
avoidedParameters.remove(routingParameter);
app.getRoutingHelper().onSettingsChanged(true);
if (app.getAvoidSpecificRoads().getImpassableRoads().isEmpty() && avoidedParameters.isEmpty()) {
mode.parameters.remove(parameter);
}
if (mode.parameters.size() > 2) {
item.removeView(v);
} else {
updateOptionsButtons();
}
});
if (container != null) {
item.addView(container, getContainerButtonLayoutParams(mapActivity, false));
}
}
}
use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter in project Osmand by osmandapp.
the class RouteOptionsBottomSheet method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
items.add(new TitleItem(app.getString(R.string.shared_string_settings), ColorUtilities.getActiveColorId(nightMode)));
OsmAndAppCustomization customization = app.getAppCustomization();
List<LocalRoutingParameter> list = getRoutingParameters(applicationMode);
for (final LocalRoutingParameter optionsItem : list) {
if (!dialogMode.isAvailableParameter(optionsItem) || !customization.isFeatureEnabled(optionsItem.getKey())) {
continue;
}
if (optionsItem instanceof DividerItem) {
if (isDividerRequired()) {
items.add(new DividerStartItem(app));
}
} else if (optionsItem instanceof MuteSoundRoutingParameter) {
items.add(createMuteSoundItem(optionsItem));
} else if (optionsItem instanceof ShowAlongTheRouteItem) {
items.add(createShowAlongTheRouteItem(optionsItem));
} else if (optionsItem instanceof RouteSimulationItem) {
items.add(createRouteSimulationItem(optionsItem));
} else if (optionsItem instanceof AvoidPTTypesRoutingParameter) {
items.add(createAvoidPTTypesItem(optionsItem));
} else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
items.add(createAvoidRoadsItem(optionsItem));
} else if (optionsItem instanceof GpxLocalRoutingParameter) {
items.add(createGpxRoutingItem(optionsItem));
} else if (optionsItem instanceof TimeConditionalRoutingItem) {
items.add(createTimeConditionalRoutingItem(optionsItem));
} else if (optionsItem instanceof OtherSettingsRoutingParameter) {
items.add(createOtherSettingsRoutingItem(optionsItem));
} else if (optionsItem instanceof CustomizeRouteLineRoutingParameter) {
items.add(createCustomizeRouteLineRoutingItem(optionsItem));
} else if (USE_HEIGHT_OBSTACLES.equals(optionsItem.getKey()) && hasReliefParameters()) {
items.add(inflateElevationParameter(optionsItem));
} else {
inflateRoutingParameter(optionsItem);
}
}
}
Aggregations