Search in sources :

Example 6 with GPXRouteParamsBuilder

use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.

the class RoutePreferencesMenu method updateSpinnerItems.

private void updateSpinnerItems(final TextView gpxSpinner) {
    GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute();
    gpxSpinner.setText(rp == null ? mapActivity.getString(R.string.shared_string_none) : new File(rp.getFile().path).getName());
}
Also used : GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder) File(java.io.File)

Example 7 with GPXRouteParamsBuilder

use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.

the class RoutePreferencesMenu method showOptionsMenu.

private void showOptionsMenu(final TextView gpxSpinner) {
    GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute();
    final PopupMenu optionsMenu = new PopupMenu(gpxSpinner.getContext(), gpxSpinner);
    MenuItem item = optionsMenu.getMenu().add(mapActivity.getString(R.string.shared_string_none));
    item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (mapActivity.getRoutingHelper().getCurrentGPXRoute() != null) {
                mapActivity.getRoutingHelper().setGpxParams(null);
                settings.FOLLOW_THE_GPX_ROUTE.set(null);
                mapActivity.getRoutingHelper().onSettingsChanged(true);
            }
            updateParameters();
            return true;
        }
    });
    item = optionsMenu.getMenu().add(mapActivity.getString(R.string.select_gpx));
    item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            openGPXFileSelection(gpxSpinner);
            return true;
        }
    });
    if (rp != null) {
        item = optionsMenu.getMenu().add(new File(rp.getFile().path).getName());
        item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                // nothing to change
                return true;
            }
        });
    }
    optionsMenu.show();
}
Also used : GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder) MenuItem(android.view.MenuItem) ContextMenuItem(net.osmand.plus.ContextMenuItem) File(java.io.File) PopupMenu(androidx.appcompat.widget.PopupMenu)

Example 8 with GPXRouteParamsBuilder

use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.

the class FollowTrackFragment method onSegmentSelect.

@Override
public void onSegmentSelect(@NonNull GPXFile gpxFile, int selectedSegment) {
    app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
    selectTrackToFollow(gpxFile);
    GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
    if (paramsBuilder != null) {
        paramsBuilder.setSelectedSegment(selectedSegment);
        app.getRoutingHelper().onSettingsChanged(true);
    }
    updateSelectionMode(false);
}
Also used : GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder)

Example 9 with GPXRouteParamsBuilder

use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.

the class MapRouteInfoMenu method isFinishPointFromTrack.

private boolean isFinishPointFromTrack() {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        OsmandApplication app = mapActivity.getMyApplication();
        GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute();
        if (routeParams != null) {
            TargetPoint target = app.getTargetPointsHelper().getPointToNavigate();
            if (target != null) {
                List<Location> points = routeParams.getPoints(app);
                if (!Algorithms.isEmpty(points)) {
                    Location loc = points.get(points.size() - 1);
                    LatLon latLon = new LatLon(loc.getLatitude(), loc.getLongitude());
                    LatLon targetLatLon = new LatLon(target.getLatitude(), target.getLongitude());
                    return latLon.equals(targetLatLon);
                }
            }
        }
    }
    return false;
}
Also used : LatLon(net.osmand.data.LatLon) OsmandApplication(net.osmand.plus.OsmandApplication) GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) MapActivity(net.osmand.plus.activities.MapActivity) Location(net.osmand.Location)

Example 10 with GPXRouteParamsBuilder

use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.

the class MapRouteInfoMenu method setupViaText.

private void setupViaText(View view) {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        OsmandApplication app = mapActivity.getMyApplication();
        TextView title = view.findViewById(R.id.ViaView);
        TextView description = view.findViewById(R.id.ViaSubView);
        TextView buttonDescription = view.findViewById(R.id.via_button_description);
        String via = generateViaDescription();
        GPXRouteParamsBuilder routeParamsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
        if (routeParamsBuilder != null) {
            GPXFile gpxFile = routeParamsBuilder.getFile();
            String fileName = null;
            if (!Algorithms.isEmpty(gpxFile.path)) {
                fileName = new File(gpxFile.path).getName();
            } else if (!Algorithms.isEmpty(gpxFile.tracks)) {
                fileName = gpxFile.tracks.get(0).name;
            }
            if (Algorithms.isEmpty(fileName)) {
                fileName = app.getString(R.string.shared_string_gpx_track);
            }
            GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute();
            if (gpxFile.getNonEmptySegmentsCount() > 1 && routeParams != null && routeParams.getSelectedSegment() != -1) {
                int selectedSegmentCount = routeParams.getSelectedSegment() + 1;
                int totalSegmentCount = routeParams.getFile().getNonEmptyTrkSegments(false).size();
                fileName = app.getString(R.string.of, selectedSegmentCount, totalSegmentCount) + ", " + fileName;
            }
            title.setText(GpxUiHelper.getGpxTitle(fileName));
            description.setText(R.string.follow_track);
            buttonDescription.setText(R.string.shared_string_add);
        } else {
            title.setText(via);
            buttonDescription.setText(R.string.shared_string_edit);
            description.setText(app.getString(R.string.intermediate_destinations) + " (" + app.getTargetPointsHelper().getIntermediatePoints().size() + ")");
        }
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder) TextView(android.widget.TextView) GPXFile(net.osmand.GPXUtilities.GPXFile) GPXFile(net.osmand.GPXUtilities.GPXFile) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) File(java.io.File) FavouritePoint(net.osmand.data.FavouritePoint) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

GPXRouteParamsBuilder (net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder)22 OsmandApplication (net.osmand.plus.OsmandApplication)10 File (java.io.File)8 ImageView (android.widget.ImageView)7 TextView (android.widget.TextView)7 MapActivity (net.osmand.plus.activities.MapActivity)7 View (android.view.View)6 GPXFile (net.osmand.GPXUtilities.GPXFile)6 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)6 Location (net.osmand.Location)5 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)4 LinearLayout (android.widget.LinearLayout)3 AlertDialog (androidx.appcompat.app.AlertDialog)3 LatLon (net.osmand.data.LatLon)3 TargetPointsHelper (net.osmand.plus.helpers.TargetPointsHelper)3 RoutingHelper (net.osmand.plus.routing.RoutingHelper)3 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)3 FrameLayout (android.widget.FrameLayout)2 HorizontalScrollView (android.widget.HorizontalScrollView)2 ArrayList (java.util.ArrayList)2