Segment count title

This commit is contained in:
androiddevkotlin 2021-02-15 22:50:40 +02:00
parent 595e2070c1
commit 9d7e317ea1
3 changed files with 12 additions and 4 deletions

View file

@ -721,13 +721,11 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
@Override
public void onSegmentSelect(GPXFile gpxFile, int selectedSegment) {
selectTrackToFollow(gpxFile);
if (selectedSegment != -1) {
GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
if (paramsBuilder != null) {
paramsBuilder.setSelectedSegment(selectedSegment);
app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
app.getRoutingHelper().onSettingsChanged(true);
}
}
updateSelectionMode(false);
}

View file

@ -1675,6 +1675,13 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
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.getResources().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);

View file

@ -21,7 +21,7 @@ import java.io.File;
public class TrackEditCard extends BaseCard {
private GPXFile gpxFile;
private final GPXFile gpxFile;
public TrackEditCard(MapActivity mapActivity, GPXFile gpxFile) {
super(mapActivity);
@ -63,12 +63,15 @@ public class TrackEditCard extends BaseCard {
if (Algorithms.isEmpty(fileName)) {
fileName = app.getString(R.string.shared_string_gpx_track);
}
GPXInfo gpxInfo = new GPXInfo(gpxFile.path, file != null ? file.lastModified() : 0, file != null ? file.length() : 0);
GpxDataItem dataItem = getDataItem(gpxInfo);
String title = GpxUiHelper.getGpxTitle(Algorithms.getFileWithoutDirs(fileName));
GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute();
if (gpxFile.getNonEmptySegmentsCount() > 1 && routeParams != null && routeParams.getSelectedSegment() != -1) {
title = title + " segment " + (routeParams.getSelectedSegment() + 1);
int selectedSegmentCount = routeParams.getSelectedSegment() + 1;
int totalSegmentCount = routeParams.getFile().getNonEmptyTrkSegments(false).size();
title = app.getResources().getString(R.string.of, selectedSegmentCount, totalSegmentCount) + ", " + title;
}
GpxUiHelper.updateGpxInfoView(view, title, gpxInfo, dataItem, false, app);