From c9fec4e33a0e6546784cbff82a788fe8f93066aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Tue, 26 Dec 2023 22:07:35 +0000 Subject: [PATCH] Xiaomi: Identify strength training, elliptical and outdoor running --- .../activity/impl/WorkoutSummaryParser.java | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/WorkoutSummaryParser.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/WorkoutSummaryParser.java index bc29628fd..452be44c3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/WorkoutSummaryParser.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/WorkoutSummaryParser.java @@ -89,19 +89,17 @@ public class WorkoutSummaryParser extends XiaomiActivityParser implements Activi @Override public BaseActivitySummary parseBinaryData(final BaseActivitySummary summary) { - final JSONObject summaryData = new JSONObject(); - final ByteBuffer buf = ByteBuffer.wrap(summary.getRawSummaryData()).order(ByteOrder.LITTLE_ENDIAN); final XiaomiActivityFileId fileId = XiaomiActivityFileId.from(buf); switch (fileId.getSubtype()) { case SPORTS_OUTDOOR_RUNNING: - break; + return parseOutdoorRunning(summary, fileId, buf); case SPORTS_FREESTYLE: - break; + return parseFreestyle(summary, fileId, buf); case SPORTS_ELLIPTICAL: - break; + return parseElliptical(summary, fileId, buf); case SPORTS_OUTDOOR_WALKING: return parseOutdoorWalking(summary, fileId, buf); case SPORTS_OUTDOOR_CYCLING: @@ -113,6 +111,30 @@ public class WorkoutSummaryParser extends XiaomiActivityParser implements Activi return null; } + private BaseActivitySummary parseOutdoorRunning(final BaseActivitySummary summary, final XiaomiActivityFileId fileId, final ByteBuffer buf) { + summary.setActivityKind(ActivityKind.TYPE_RUNNING); + + // TODO + + return summary; + } + + private BaseActivitySummary parseFreestyle(final BaseActivitySummary summary, final XiaomiActivityFileId fileId, final ByteBuffer buf) { + summary.setActivityKind(ActivityKind.TYPE_STRENGTH_TRAINING); + + // TODO + + return summary; + } + + private BaseActivitySummary parseElliptical(final BaseActivitySummary summary, final XiaomiActivityFileId fileId, final ByteBuffer buf) { + summary.setActivityKind(ActivityKind.TYPE_ELLIPTICAL_TRAINER); + + // TODO + + return summary; + } + private BaseActivitySummary parseOutdoorWalking(final BaseActivitySummary summary, final XiaomiActivityFileId fileId, final ByteBuffer buf) { final JSONObject summaryData = new JSONObject();