Search in sources :

Example 1 with LocalRoutingParameter

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);
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder) OtherLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) TextView(android.widget.TextView) OtherLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter) LatLon(net.osmand.data.LatLon) FrameLayout(android.widget.FrameLayout) PointDescription(net.osmand.data.PointDescription) ImageView(android.widget.ImageView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) TargetPointsHelper(net.osmand.plus.helpers.TargetPointsHelper) LinearLayout(android.widget.LinearLayout) MapActivity(net.osmand.plus.activities.MapActivity) Location(net.osmand.Location)

Example 2 with LocalRoutingParameter

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();
}
Also used : ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) GpxLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter)

Example 3 with LocalRoutingParameter

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));
        }
    }
}
Also used : LatLon(net.osmand.data.LatLon) OsmandApplication(net.osmand.plus.OsmandApplication) AvoidRoadsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter) OtherLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter) MuteSoundRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter) AvoidPTTypesRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter) RoutingParameter(net.osmand.router.GeneralRouter.RoutingParameter) HashMap(java.util.HashMap) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) LinearLayout(android.widget.LinearLayout) AvoidRoadsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter)

Example 4 with LocalRoutingParameter

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));
        }
    }
}
Also used : AvoidRoadsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter) OtherLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter) MuteSoundRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter) AvoidPTTypesRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter) RoutingParameter(net.osmand.router.GeneralRouter.RoutingParameter) OsmandApplication(net.osmand.plus.OsmandApplication) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) TextView(android.widget.TextView) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) FavouritePoint(net.osmand.data.FavouritePoint) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)

Example 5 with LocalRoutingParameter

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);
        }
    }
}
Also used : OtherSettingsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRoutingParameter) MuteSoundRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter) AvoidPTTypesRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter) TimeConditionalRoutingItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.TimeConditionalRoutingItem) RouteSimulationItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.RouteSimulationItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) GpxLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter) AvoidRoadsRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter) GpxLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter) DividerStartItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerStartItem) CustomizeRouteLineRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.CustomizeRouteLineRoutingParameter) OsmAndAppCustomization(net.osmand.plus.settings.backend.OsmAndAppCustomization) ShowAlongTheRouteItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.ShowAlongTheRouteItem) DividerItem(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DividerItem)

Aggregations

LocalRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter)10 OtherLocalRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter)6 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 OsmandApplication (net.osmand.plus.OsmandApplication)4 AvoidPTTypesRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter)4 AvoidRoadsRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter)4 GpxLocalRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.GpxLocalRoutingParameter)4 MuteSoundRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter)4 HorizontalScrollView (android.widget.HorizontalScrollView)3 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)3 LatLon (net.osmand.data.LatLon)3 MapActivity (net.osmand.plus.activities.MapActivity)3 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)3 LocalRoutingParameterGroup (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameterGroup)3 GPXRouteParamsBuilder (net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder)3 LinearLayout (android.widget.LinearLayout)2 TargetPointsHelper (net.osmand.plus.helpers.TargetPointsHelper)2 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)2