From fb2c9158e4b8f4bb89d64b83d8daa6739f3bf350 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Fri, 22 Jan 2021 22:14:11 +0100 Subject: [PATCH] Huami: Add "Strength Training" activity type Used on at least the Amazfit Bip U --- .../gadgetbridge/model/ActivityKind.java | 27 +++++++++++++++++-- .../huami/HuamiSportsActivityType.java | 5 ++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 31 insertions(+), 2 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 e443b6cc6..de50eb27f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java @@ -50,8 +50,9 @@ public class ActivityKind { public static final int TYPE_BASKETBALL = 0x00040000; public static final int TYPE_PINGPONG = 0x00080000; public static final int TYPE_BADMINTON = 0x00100000; + public static final int TYPE_STRENGTH_TRAINING = 0x00200000; - private static final int TYPES_COUNT = 23; + private static final int TYPES_COUNT = 24; 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; @@ -104,6 +105,25 @@ public class ActivityKind { if ((types & ActivityKind.TYPE_YOGA) != 0) { result[i++] = provider.toRawActivityKind(TYPE_YOGA); } + if ((types & ActivityKind.TYPE_ROWING_MACHINE) != 0) { + result[i++] = provider.toRawActivityKind(TYPE_ROWING_MACHINE); + } + if ((types & ActivityKind.TYPE_CRICKET) != 0) { + result[i++] = provider.toRawActivityKind(TYPE_CRICKET); + } + if ((types & ActivityKind.TYPE_BASKETBALL) != 0) { + result[i++] = provider.toRawActivityKind(TYPE_BASKETBALL); + } + if ((types & ActivityKind.TYPE_PINGPONG) != 0) { + result[i++] = provider.toRawActivityKind(TYPE_PINGPONG); + } + if ((types & ActivityKind.TYPE_BADMINTON) != 0) { + result[i++] = provider.toRawActivityKind(TYPE_BADMINTON); + } + if ((types & ActivityKind.TYPE_STRENGTH_TRAINING) != 0) { + result[i++] = provider.toRawActivityKind(TYPE_STRENGTH_TRAINING); + } + return Arrays.copyOf(result, i); } @@ -153,6 +173,8 @@ public class ActivityKind { return context.getString(R.string.activity_type_pingpong); case TYPE_BADMINTON: return context.getString(R.string.activity_type_badminton); + case TYPE_STRENGTH_TRAINING: + return context.getString(R.string.activity_type_strength_training); case TYPE_UNKNOWN: default: return context.getString(R.string.activity_type_unknown); @@ -189,7 +211,6 @@ public class ActivityKind { return R.drawable.ic_activity_rope_jump; case TYPE_YOGA: return R.drawable.ic_activity_yoga; - case TYPE_SOCCER: return R.drawable.ic_activity_soccer; case TYPE_ROWING_MACHINE: @@ -202,6 +223,8 @@ public class ActivityKind { return R.drawable.ic_activity_pingpong; case TYPE_BADMINTON: return R.drawable.ic_activity_badmington; + case TYPE_STRENGTH_TRAINING: + return R.drawable.ic_activity_unknown_small; //FIXME: find icon case TYPE_NOT_WORN: // fall through case TYPE_ACTIVITY: // 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 cb460b49b..271e6cb19 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 @@ -31,6 +31,7 @@ public enum HuamiSportsActivityType { Soccer(0x12), JumpRope(0x15), RowingMachine(0x17), + StrengthTraining(0x34), Yoga(0x3c), Cricket(0x4e), Basketball(0x55), @@ -80,6 +81,8 @@ public enum HuamiSportsActivityType { return ActivityKind.TYPE_PINGPONG; case Badminton: return ActivityKind.TYPE_BADMINTON; + case StrengthTraining: + return ActivityKind.TYPE_STRENGTH_TRAINING; } throw new RuntimeException("Not mapped activity kind for: " + this); } @@ -129,6 +132,8 @@ public enum HuamiSportsActivityType { return PingPong; case ActivityKind.TYPE_BADMINTON: return Badminton; + case ActivityKind.TYPE_STRENGTH_TRAINING: + return StrengthTraining; } 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 161c33790..5eb668dd1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -760,6 +760,7 @@ Basketball Ping Pong Badminton + Strength Training Unknown activity Sport Activities Sport Activity Detail