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 cdb35fd2f..9d12e134e 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 @@ -160,6 +160,8 @@ public class GarminWorkoutParser implements ActivitySummaryParser { } else { activityKind = getActivityKind(session.getSport(), session.getSubSport()); } + final ActivityKind.CycleUnit cycleUnit = ActivityKind.getCycleUnit(activityKind); + summary.setActivityKind(activityKind.getCode()); if (session.getTotalElapsedTime() != null) { @@ -178,8 +180,8 @@ public class GarminWorkoutParser implements ActivitySummaryParser { if (session.getAvgSwolf() != null) { summaryData.add(SWOLF_AVG, session.getAvgSwolf(), UNIT_NONE); } - if (session.getTotalSteps() != null) { - summaryData.add(STEPS, session.getTotalSteps(), UNIT_STEPS); + if (session.getTotalCycles() != null) { + summaryData.addTotal(session.getTotalCycles(), cycleUnit); } if (session.getTotalCalories() != null) { summaryData.add(CALORIES_BURNT, session.getTotalCalories(), UNIT_KCAL); @@ -215,10 +217,10 @@ public class GarminWorkoutParser implements ActivitySummaryParser { summaryData.add(STRESS_AVG, session.getAvgStress(), UNIT_NONE); } if (session.getAverageCadence() != null) { - summaryData.add(CADENCE_AVG, session.getAverageCadence(), UNIT_SPM); + summaryData.addCadenceAvg(session.getAverageCadence(), cycleUnit); } if (session.getMaxCadence() != null) { - summaryData.add(CADENCE_MAX, session.getMaxCadence(), UNIT_SPM); + summaryData.addCadenceMax(session.getMaxCadence(), cycleUnit); } if (session.getTotalAscent() != null) { summaryData.add(ASCENT_DISTANCE, session.getTotalAscent(), UNIT_METERS); 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 59b253faf..93987c286 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java @@ -360,4 +360,84 @@ public enum ActivityKind { activityKind.name().contains("TREADMILL") || activityKind.name().contains("WALK"); } + public static CycleUnit getCycleUnit(final ActivityKind activityKind) { + switch (activityKind) { + case BUNGEE_JUMPING: + case JUMP_ROPING: + case JUMPMASTER: + case TRAMPOLINE: + return CycleUnit.JUMPS; + case BIKE_COMMUTE: + case CYCLING: + case E_BIKE: + case HANDCYCLING: + case HANDCYCLING_INDOOR: + case INDOOR_CYCLING: + case OUTDOOR_CYCLING: + case SPINNING: + return CycleUnit.REVOLUTIONS; + case FLEXIBILITY: + case BARBELL: + case BATTLE_ROPE: + case CORE_TRAINING: + case CROSSFIT: + case DUMBBELL: + case FITNESS_EXERCISES: + case FUNCTIONAL_TRAINING: + case PILATES: + case PLANK: + case PULL_UPS: + case PUSH_UPS: + case SIT_UPS: + case SMITH_MACHINE: + case STRENGTH_TRAINING: + case YOGA: + return CycleUnit.REPS; + case ARTISTIC_SWIMMING: + case KAYAKING: + case KITESURFING: + case PADDLING: + case POOL_SWIM: + case RAFTING: + case ROWING: + case ROWING_MACHINE: + case STAND_UP_PADDLEBOARDING: + case SURFING: + case SWIMMING: + case SWIMMING_OPENWATER: + case WAKEBOARDING: + case WATER_SKIING: + case WINDSURFING: + return CycleUnit.STROKES; + case BADMINTON: + case GOLF: + case HOCKEY: + case LACROSSE: + case PICKLEBALL: + case PINGPONG: + case RACKET: + case RACQUETBALL: + case SHUTTLECOCK: + case SQUASH: + case TABLE_TENNIS: + case TENNIS: + case BASEBALL: + case CRICKET: + case SOFTBALL: + return CycleUnit.SWINGS; + } + + return CycleUnit.STEPS; + } + + public enum CycleUnit { + NONE, + UNKNOWN, + STEPS, + STROKES, + JUMPS, + REPS, + REVOLUTIONS, + SWINGS, + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryData.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryData.java index ef39ef9e3..3baa9cc1b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryData.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryData.java @@ -161,4 +161,61 @@ public class ActivitySummaryData { public String toJson() { return GSON.toJson(entries); } + + public void addTotal(final Number value, final ActivityKind.CycleUnit unit) { + switch (unit) { + case STROKES: + add(ActivitySummaryEntries.STROKES, value, ActivitySummaryEntries.UNIT_STROKES); + break; + case JUMPS: + add(ActivitySummaryEntries.JUMPS, value, ActivitySummaryEntries.UNIT_JUMPS); + break; + case REPS: + add(ActivitySummaryEntries.REPETITIONS, value, ActivitySummaryEntries.UNIT_REPS); + break; + case REVOLUTIONS: + add(ActivitySummaryEntries.REVOLUTIONS, value, ActivitySummaryEntries.UNIT_REVS); + break; + default: + add(ActivitySummaryEntries.STEPS, value, ActivitySummaryEntries.UNIT_STEPS); + } + } + + public void addCadenceAvg(final Number value, final ActivityKind.CycleUnit unit) { + switch (unit) { + case STROKES: + add(ActivitySummaryEntries.STROKE_RATE_AVG, value, ActivitySummaryEntries.UNIT_STROKES_PER_MINUTE); + break; + case JUMPS: + add(ActivitySummaryEntries.JUMP_RATE_AVG, value, ActivitySummaryEntries.UNIT_JUMPS_PER_MINUTE); + break; + case REPS: + add(ActivitySummaryEntries.CADENCE_AVG, value, ActivitySummaryEntries.UNIT_REPS_PER_MINUTE); + break; + case REVOLUTIONS: + add(ActivitySummaryEntries.CADENCE_AVG, value, ActivitySummaryEntries.UNIT_REVS_PER_MINUTE); + break; + default: + add(ActivitySummaryEntries.CADENCE_AVG, value, ActivitySummaryEntries.UNIT_SPM); + } + } + + public void addCadenceMax(final Number value, final ActivityKind.CycleUnit unit) { + switch (unit) { + case STROKES: + add(ActivitySummaryEntries.STROKE_RATE_MAX, value, ActivitySummaryEntries.UNIT_STROKES_PER_MINUTE); + break; + case JUMPS: + add(ActivitySummaryEntries.JUMP_RATE_MAX, value, ActivitySummaryEntries.UNIT_JUMPS_PER_MINUTE); + break; + case REPS: + add(ActivitySummaryEntries.CADENCE_MAX, value, ActivitySummaryEntries.UNIT_REPS_PER_MINUTE); + break; + case REVOLUTIONS: + add(ActivitySummaryEntries.CADENCE_MAX, value, ActivitySummaryEntries.UNIT_REVS_PER_MINUTE); + break; + default: + add(ActivitySummaryEntries.CADENCE_MAX, value, ActivitySummaryEntries.UNIT_SPM); + } + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryEntries.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryEntries.java index d38ac8f00..983d0922d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryEntries.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryEntries.java @@ -136,6 +136,8 @@ public class ActivitySummaryEntries { public static final String CYCLING_POWER_MAX = "cyclingPowerMax"; public static final String SETS = "workoutSets"; + public static final String REPETITIONS = "workout_repetitions"; + public static final String REVOLUTIONS = "workout_revolutions"; public static final String UNIT_BPM = "bpm"; public static final String UNIT_BREATHS_PER_MIN = "breaths_per_min"; @@ -163,7 +165,11 @@ public class ActivitySummaryEntries { public static final String UNIT_STROKES_PER_SECOND = "strokes_second"; public static final String UNIT_STROKES_PER_LENGTH = "strokes_per_length"; public static final String UNIT_JUMPS = "jumps_unit"; + public static final String UNIT_REPS = "unit_repetitions"; + public static final String UNIT_REVS = "unit_revolutions"; public static final String UNIT_JUMPS_PER_MINUTE = "jumps_minute"; + public static final String UNIT_REPS_PER_MINUTE = "unit_repetitions_per_minute"; + public static final String UNIT_REVS_PER_MINUTE = "unit_revolutions_per_minute"; public static final String UNIT_YARD = "yard"; public static final String UNIT_DEGREES = "degrees"; public static final String UNIT_STRING = "string"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/GlobalFITMessage.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/GlobalFITMessage.java index 4e0e83158..c41a798cf 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/GlobalFITMessage.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/GlobalFITMessage.java @@ -99,7 +99,7 @@ public class GlobalFITMessage { new FieldDefinitionPrimitive(7, BaseType.UINT32, "total_elapsed_time"), // with pauses new FieldDefinitionPrimitive(8, BaseType.UINT32, "total_timer_time"), // no pauses new FieldDefinitionPrimitive(9, BaseType.UINT32, "total_distance"), - new FieldDefinitionPrimitive(10, BaseType.UINT32, "total_steps"), + new FieldDefinitionPrimitive(10, BaseType.UINT32, "total_cycles"), new FieldDefinitionPrimitive(11, BaseType.UINT16, "total_calories"), new FieldDefinitionPrimitive(16, BaseType.UINT8, "average_heart_rate"), new FieldDefinitionPrimitive(17, BaseType.UINT8, "max_heart_rate"), diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitSession.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitSession.java index f51dc1bde..810d5b661 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitSession.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/fit/messages/FitSession.java @@ -71,7 +71,7 @@ public class FitSession extends RecordData { } @Nullable - public Long getTotalSteps() { + public Long getTotalCycles() { return (Long) getFieldByNumber(10); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index efaff749c..b61bb3d03 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2333,6 +2333,12 @@ str jumps/min jumps + reps + revs + reps/min + revs/min + Repetitions + Revolutions sec milliseconds ms