mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Garmin: add support for installing .FIT location and segment files
The uploaded location file creates new waypoints on the device by updating the LCTNS.FIT / Location.fit file.
This commit is contained in:
+22
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2024 José Rebelo
|
||||
/* Copyright (C) 2024-2026 José Rebelo, Thomas Kuehne
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
@@ -42,6 +42,8 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.FileType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.FitFile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.exception.FitParseException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages.FitCourse;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages.FitLocation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages.FitSegmentId;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.messages.FitWorkout;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.UriHelper;
|
||||
@@ -190,6 +192,25 @@ public class GarminFitFileInstallHandler implements InstallHandler {
|
||||
.map(FitWorkout::getName)
|
||||
.orElse(filename);
|
||||
break;
|
||||
case LOCATION:
|
||||
kindName = mContext.getString(R.string.kind_waypoints);
|
||||
supported = coordinator.supports(device, GarminCapability.EXPLORE_SYNC)
|
||||
|| coordinator.supports(device, GarminCapability.WAYPOINT_TRANSFER);
|
||||
long count = fitFile.getRecords().stream()
|
||||
.filter(r -> r instanceof FitLocation)
|
||||
.count();
|
||||
name = mContext.getString(R.string.waypoint_count, count);
|
||||
break;
|
||||
case SEGMENTS:
|
||||
kindName = mContext.getString(R.string.kind_segments);
|
||||
supported = coordinator.supports(device, GarminCapability.SEGMENTS);
|
||||
name = fitFile.getRecords().stream()
|
||||
.filter(r -> r instanceof FitSegmentId)
|
||||
.map(r -> (FitSegmentId) r)
|
||||
.findFirst()
|
||||
.map(FitSegmentId::getName)
|
||||
.orElse(filename);
|
||||
break;
|
||||
default:
|
||||
LOG.warn("Unsupported fit file type: {}", fileType);
|
||||
kindName = mContext.getString(R.string.menuitem_unknown_app, fileType.name());
|
||||
|
||||
@@ -2536,6 +2536,9 @@
|
||||
<string name="qhybrid_offset_timezone">offset timezone by</string>
|
||||
<string name="qhybrid_changes_delay_prompt">change might take some seconds…</string>
|
||||
<string name="qhybrid_offset_time_by">offset time by</string>
|
||||
<string name="kind_waypoints">Waypoints</string>
|
||||
<string name="kind_segments">Segments</string>
|
||||
<string name="waypoint_count">%d waypoints</string>
|
||||
<string name="hr_widget_heart_rate">Heart rate</string>
|
||||
<string name="hr_widget_steps">Steps</string>
|
||||
<string name="hr_widget_date">Date</string>
|
||||
|
||||
Reference in New Issue
Block a user