diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021ActivitySummaryParser.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021ActivitySummaryParser.java index fa07eb562..9dde63c0d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021ActivitySummaryParser.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021ActivitySummaryParser.java @@ -145,5 +145,30 @@ public class Huami2021ActivitySummaryParser extends HuamiActivitySummaryParser { addSummaryData("ascentSeconds", summaryProto.getElevation().getUphillTime(), "seconds"); addSummaryData("descentSeconds", summaryProto.getElevation().getDownhillTime(), "seconds"); } + + if (summaryProto.hasSwimmingData()) { + addSummaryData("laps", summaryProto.getSwimmingData().getLaps(), "laps_unit"); + switch (summaryProto.getSwimmingData().getLaneLengthUnit()) { + case 0: + addSummaryData("laneLength", summaryProto.getSwimmingData().getLaneLength(), "meters"); + break; + case 1: + addSummaryData("laneLength", summaryProto.getSwimmingData().getLaneLength(), "yard"); + break; + } + switch (summaryProto.getSwimmingData().getStyle()) { + case 1: + addSummaryData("swimStyle", "breaststroke"); + break; + case 2: + addSummaryData("swimStyle", "freestyle"); + break; + } + addSummaryData("strokes", summaryProto.getSwimmingData().getStrokes(), "strokes_unit"); + addSummaryData("avgStrokeRate", summaryProto.getSwimmingData().getAvgStrokeRate(), "strokes_minute"); + addSummaryData("maxStrokeRate", summaryProto.getSwimmingData().getMaxStrokeRate(), "strokes_minute"); + addSummaryData("averageStrokeDistance", summaryProto.getSwimmingData().getAvgDps(), "cm"); + addSummaryData("swolfIndex", summaryProto.getSwimmingData().getSwolf(), ""); + } } } 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 4b8f6983e..e511f5efb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryJsonSummary.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivitySummaryJsonSummary.java @@ -153,7 +153,8 @@ public class ActivitySummaryJsonSummary { private JSONObject createActivitySummaryGroups(){ final Map> groupDefinitions = new HashMap>() {{ put("Strokes", Arrays.asList( - "averageStrokeDistance", "averageStrokesPerSecond", "strokes" + "averageStrokeDistance", "averageStrokesPerSecond", "strokes", + "avgStrokeRate", "maxStrokeRate" )); put("Swimming", Arrays.asList( "swolfIndex", "swimStyle" @@ -179,8 +180,8 @@ public class ActivitySummaryJsonSummary { "aerobicTrainingEffect", "anaerobicTrainingEffect", "currentWorkoutLoad", "maximumOxygenUptake" )); - put("Laps", Arrays.asList( - "averageLapPace", "laps" + put("laps", Arrays.asList( + "averageLapPace", "laps", "laneLength" )); }}; diff --git a/app/src/main/proto/huami.proto b/app/src/main/proto/huami.proto index defbffd0b..2666473cc 100644 --- a/app/src/main/proto/huami.proto +++ b/app/src/main/proto/huami.proto @@ -10,6 +10,7 @@ message WorkoutSummary { Distance distance = 4; Steps steps = 11; Time time = 7; + SwimmingData swimmingData = 9; Pace pace = 10; Altitude altitude = 13; HeartRate heartRate = 19; @@ -96,3 +97,15 @@ message TrainingEffect { int32 currentWorkoutLoad = 6; int32 maximumOxygenUptake = 7; // ml/kg/min } + +message SwimmingData { + uint32 style = 1; // 1: breaststroke, 2: freestyle + uint32 laps = 2; + uint32 strokes = 3; + uint32 avgDps = 4; // cm + uint32 swolf = 5; + uint32 avgStrokeRate = 6; // stroke/min + uint32 maxStrokeRate = 7; // stroke/min + uint32 laneLength = 8; + uint32 laneLengthUnit = 9; // 0: meter, 1: yard +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ba1323e1e..574a65259 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1691,9 +1691,13 @@ Min Cadence Average Stroke Distance Average Strokes + Average Stroke Rate + Max Stroke Rate + Total Strokes Average Lap Pace - swolfIndex - swimStyle + SWOLF + Swim Style + Lane Length Laps Ascending Descending @@ -1703,6 +1707,7 @@ m cm + yard ft steps m/s @@ -1710,6 +1715,7 @@ mi/h min/mi str/s + str/min str sec swolf index