Get activity title from uploaded file, if it is present #7

Merged
kabupatix merged 4 commits from 8-use-activity-name-from-file into main 2026-04-13 10:12:38 +02:00
2 changed files with 8 additions and 3 deletions
Showing only changes of commit 3002427e38 - Show all commits

View file

@ -26,6 +26,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static net.javahippie.fitpub.util.ParsedActivityData.MAX_TITLE_LENGTH;
/**
* Parser for GPX (GPS Exchange Format) files.
* Extracts GPS coordinates, activity metrics from track points.
@ -280,9 +282,9 @@ public class GpxParser {
String title = getElementText(track, "name");
if (title != null) {
String shortenedTitle = title;
if (title.length() > 255) {
log.debug("Activity title was shortened to 255 characters: {}", title);
shortenedTitle = title.substring(0, 255);
if (title.length() > MAX_TITLE_LENGTH) {
log.debug("Activity title was shortened to {} characters: {}", MAX_TITLE_LENGTH, title);
shortenedTitle = title.substring(0, MAX_TITLE_LENGTH);
}
parsedData.setTitle(shortenedTitle);
}

View file

@ -20,6 +20,9 @@ import java.util.List;
*/
@Data
public class ParsedActivityData {
static final int MAX_TITLE_LENGTH = 255;
private List<TrackPointData> trackPoints = new ArrayList<>();
private LocalDateTime startTime;
private LocalDateTime endTime;