From ce8021ec9b73ed15db6b95b83613703c22563055 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Mon, 7 Sep 2020 21:40:20 +0200 Subject: [PATCH] Huami: Add new activity types found in recent Bip S firmware --- .../gadgetbridge/model/ActivityKind.java | 29 ++++++++++++- .../huami/HuamiSportsActivityType.java | 42 ++++++++++++++++--- app/src/main/res/values/strings.xml | 6 +++ 3 files changed, 71 insertions(+), 6 deletions(-) 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 7023b0611..d3e9c4a04 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java @@ -44,8 +44,14 @@ public class ActivityKind { public static final int TYPE_ELLIPTICAL_TRAINER = 0x00001000; public static final int TYPE_JUMP_ROPING = 0x00002000; public static final int TYPE_YOGA = 0x00004000; + public static final int TYPE_SOCCER = 0x00008000; + public static final int TYPE_ROWING_MACHINE = 0x00010000; + public static final int TYPE_CRICKET = 0x00020000; + public static final int TYPE_BASKETBALL = 0x00040000; + public static final int TYPE_PINGPONG = 0x00080000; + public static final int TYPE_BADMINTON = 0x00100000; - private static final int TYPES_COUNT = 17; + private static final int TYPES_COUNT = 23; public static final int TYPE_SLEEP = TYPE_LIGHT_SLEEP | TYPE_DEEP_SLEEP; public static final int TYPE_ALL = TYPE_ACTIVITY | TYPE_SLEEP | TYPE_NOT_WORN; @@ -135,6 +141,18 @@ public class ActivityKind { return context.getString(R.string.activity_type_jump_roping); case TYPE_YOGA: return context.getString(R.string.activity_type_yoga); + case TYPE_SOCCER: + return context.getString(R.string.activity_type_soccer); + case TYPE_ROWING_MACHINE: + return context.getString(R.string.activity_type_rowing_machine); + case TYPE_CRICKET: + return context.getString(R.string.activity_type_cricket); + case TYPE_BASKETBALL: + return context.getString(R.string.activity_type_basketball); + case TYPE_PINGPONG: + return context.getString(R.string.activity_type_pingpong); + case TYPE_BADMINTON: + return context.getString(R.string.activity_type_badminton); case TYPE_UNKNOWN: default: return context.getString(R.string.activity_type_unknown); @@ -171,6 +189,15 @@ public class ActivityKind { return R.drawable.ic_activity_rope_jump; case TYPE_YOGA: return R.drawable.ic_activity_yoga; + + // TODO: find icons + case TYPE_SOCCER: + case TYPE_ROWING_MACHINE: + case TYPE_CRICKET: + case TYPE_BASKETBALL: + case TYPE_PINGPONG: + case TYPE_BADMINTON: + case TYPE_NOT_WORN: // fall through case TYPE_ACTIVITY: // fall through case TYPE_UNKNOWN: // fall through diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSportsActivityType.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSportsActivityType.java index 806000d14..4850d663e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSportsActivityType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSportsActivityType.java @@ -19,7 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; public enum HuamiSportsActivityType { - Outdoor(1), + OutdoorRunning(1), Treadmill(2), Walking(3), Cycling(4), @@ -28,8 +28,15 @@ public enum HuamiSportsActivityType { OpenWaterSwimming(7), IndoorCycling(8), EllipticalTrainer(9), - JumpRope(21), - Yoga(60); + Soccer(0x12), + JumpRope(0x15), + RowingMachine(0x17), + Yoga(0x3c), + Cricket(0x4e), + Basketball(0x55), + PingPong(0x59), + Badminton(0x5c); + private final int code; @@ -39,7 +46,7 @@ public enum HuamiSportsActivityType { public int toActivityKind() { switch (this) { - case Outdoor: + case OutdoorRunning: return ActivityKind.TYPE_RUNNING; case Treadmill: return ActivityKind.TYPE_TREADMILL; @@ -57,10 +64,22 @@ public enum HuamiSportsActivityType { return ActivityKind.TYPE_INDOOR_CYCLING; case EllipticalTrainer: return ActivityKind.TYPE_ELLIPTICAL_TRAINER; + case Soccer: + return ActivityKind.TYPE_SOCCER; case JumpRope: return ActivityKind.TYPE_JUMP_ROPING; + case RowingMachine: + return ActivityKind.TYPE_ROWING_MACHINE; case Yoga: return ActivityKind.TYPE_YOGA; + case Cricket: + return ActivityKind.TYPE_CRICKET; + case Basketball: + return ActivityKind.TYPE_BASKETBALL; + case PingPong: + return ActivityKind.TYPE_PINGPONG; + case Badminton: + return ActivityKind.TYPE_BADMINTON; } throw new RuntimeException("Not mapped activity kind for: " + this); } @@ -77,7 +96,7 @@ public enum HuamiSportsActivityType { public static HuamiSportsActivityType fromActivityKind(int activityKind) { switch (activityKind) { case ActivityKind.TYPE_RUNNING: - return Outdoor; + return OutdoorRunning; case ActivityKind.TYPE_TREADMILL: return Treadmill; case ActivityKind.TYPE_CYCLING: @@ -94,10 +113,23 @@ public enum HuamiSportsActivityType { return IndoorCycling; case ActivityKind.TYPE_ELLIPTICAL_TRAINER: return EllipticalTrainer; + case ActivityKind.TYPE_SOCCER: + return Soccer; case ActivityKind.TYPE_JUMP_ROPING: return JumpRope; + case ActivityKind.TYPE_ROWING_MACHINE: + return RowingMachine; case ActivityKind.TYPE_YOGA: return Yoga; + case ActivityKind.TYPE_CRICKET: + return Cricket; + case ActivityKind.TYPE_BASKETBALL: + return Basketball; + case ActivityKind.TYPE_PINGPONG: + return PingPong; + case ActivityKind.TYPE_BADMINTON: + return Badminton; + } throw new RuntimeException("No matching activity activityKind: " + activityKind); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2609e2028..17c5caa23 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -703,6 +703,12 @@ Elliptical Trainer Jumping Rope Yoga + Soccer + Rowing Machine + Cricket + Basketball + Ping Pong + Badminton Unknown activity Sport Activities Sport Activity Detail