diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/garmin/GarminWorkoutParser.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/garmin/GarminWorkoutParser.java index 57c8ad479..a2576605f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/garmin/GarminWorkoutParser.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/garmin/GarminWorkoutParser.java @@ -193,6 +193,22 @@ public class GarminWorkoutParser implements ActivitySummaryParser { summaryData.add(DESCENT_DISTANCE, session.getTotalDescent(), UNIT_METERS); } + if (session.getEnhancedAvgSpeed() != null) { + if (ActivityKind.isPaceActivity(activityKind)) { + summaryData.add(PACE_AVG_SECONDS_KM, Math.round((60 / (session.getEnhancedAvgSpeed() * 3.6)) * 60), UNIT_SECONDS); + } else { + summaryData.add(SPEED_AVG, Math.round((session.getEnhancedAvgSpeed() * 3600 / 1000) * 100.0) / 100.0, UNIT_KMPH); + } + } + + if (session.getEnhancedMaxSpeed() != null) { + if (ActivityKind.isPaceActivity(activityKind)) { + summaryData.add(PACE_MAX, Math.round((60 / (session.getEnhancedMaxSpeed() * 3.6)) * 60), UNIT_SECONDS); + } else { + summaryData.add(SPEED_MAX, Math.round((session.getEnhancedMaxSpeed() * 3600 / 1000) * 100.0) / 100.0, UNIT_KMPH); + } + } + for (final FitTimeInZone fitTimeInZone : timesInZone) { // Find the first time in zone for the session (assumes single-session) if (fitTimeInZone.getReferenceMessage() != null && fitTimeInZone.getReferenceMessage() == 18) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java index 70cb5c234..f891c79ce 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java @@ -349,4 +349,10 @@ public enum ActivityKind { || activityKind == ActivityKind.REM_SLEEP || activityKind == ActivityKind.AWAKE_SLEEP; } + + public static boolean isPaceActivity(final ActivityKind activityKind) { + return activityKind.name().contains("RUN") || activityKind.name().contains("SWIM") || + activityKind.name().contains("TREADMILL") || activityKind.name().contains("WALK"); + } + } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryJsonSummary.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryJsonSummary.java index b21243812..82fce6e56 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryJsonSummary.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryJsonSummary.java @@ -57,7 +57,7 @@ public class ActivitySummaryJsonSummary { summary.add("baseAltitude", item.getBaseAltitude(), UNIT_METERS); } - if (!summary.has("averageSpeed") && summary.has("distanceMeters") && summary.has("activeSeconds")) { + if (!summary.has("averageKMPaceSeconds") && !summary.has("averageSpeed") && summary.has("distanceMeters") && summary.has("activeSeconds")) { double distance = summary.getNumber("distanceMeters", 0).doubleValue(); double duration = summary.getNumber("activeSeconds", 1).doubleValue(); summary.add("averageSpeed", distance / duration, UNIT_METERS_PER_SECOND);