Search in sources :

Example 1 with OtherLocalRoutingParameter

use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter 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 OtherLocalRoutingParameter

use of net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter in project Osmand by osmandapp.

the class SelectedTrackToFollowCard method setupNavigateOptionsCard.

private void setupNavigateOptionsCard(ViewGroup cardsContainer, GPXRouteParamsBuilder routeParamsBuilder) {
    int passRouteId = R.string.gpx_option_from_start_point;
    LocalRoutingParameter passWholeRoute = new OtherLocalRoutingParameter(passRouteId, app.getString(passRouteId), routeParamsBuilder.isPassWholeRoute());
    int navigationTypeId = R.string.gpx_option_calculate_first_last_segment;
    LocalRoutingParameter navigationType = new OtherLocalRoutingParameter(navigationTypeId, app.getString(navigationTypeId), routeParamsBuilder.isCalculateOsmAndRouteParts());
    int connectTrackPointsId = R.string.connect_track_points_as;
    LocalRoutingParameter connectTrackPointStraightly = new OtherLocalRoutingParameter(connectTrackPointsId, app.getString(connectTrackPointsId), routeParamsBuilder.shouldConnectPointsStraightly());
    NavigateTrackOptionsCard navigateTrackCard = new NavigateTrackOptionsCard(mapActivity, passWholeRoute, navigationType, connectTrackPointStraightly, routeParamsBuilder.useIntermediateRtePoints());
    navigateTrackCard.setListener(target);
    cardsContainer.addView(navigateTrackCard.build(mapActivity));
}
Also used : OtherLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter) LocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter) OtherLocalRoutingParameter(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter)

Aggregations

LocalRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter)2 OtherLocalRoutingParameter (net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherLocalRoutingParameter)2 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 HorizontalScrollView (android.widget.HorizontalScrollView)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)1 Location (net.osmand.Location)1 LatLon (net.osmand.data.LatLon)1 PointDescription (net.osmand.data.PointDescription)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 MapActivity (net.osmand.plus.activities.MapActivity)1 TargetPointsHelper (net.osmand.plus.helpers.TargetPointsHelper)1 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)1 GPXRouteParamsBuilder (net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder)1 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)1