From c62a418961b354b6d04672dcc501ae0eb7f0a550 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 28 Dec 2021 21:16:51 +0800 Subject: [PATCH] Add climbing activity & Add seperate res for hiking and climbing --- .../devices/huami/HuamiActivitySummaryParser.java | 2 +- .../gadgetbridge/model/ActivityKind.java | 13 +++++++++++-- .../devices/huami/HuamiSportsActivityType.java | 5 +++++ .../operations/FetchSportsDetailsOperation.java | 3 +++ app/src/main/res/drawable/ic_activity_climbing.xml | 10 ++++++++++ app/src/main/res/drawable/ic_activity_hiking.xml | 10 ++++++++++ app/src/main/res/values/strings.xml | 1 + 7 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/ic_activity_climbing.xml create mode 100644 app/src/main/res/drawable/ic_activity_hiking.xml diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiActivitySummaryParser.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiActivitySummaryParser.java index cd6ad2629..8d3946293 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiActivitySummaryParser.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiActivitySummaryParser.java @@ -181,7 +181,7 @@ public class HuamiActivitySummaryParser implements ActivitySummaryParser { averageStride = buffer.getShort(); maxHR = buffer.getShort(); - if (activityKind == ActivityKind.TYPE_CYCLING || activityKind == ActivityKind.TYPE_RUNNING || activityKind == ActivityKind.TYPE_HIKING) { + if (activityKind == ActivityKind.TYPE_CYCLING || activityKind == ActivityKind.TYPE_RUNNING || activityKind == ActivityKind.TYPE_HIKING || activityKind == ActivityKind.TYPE_CLIMBING) { // this had nonsense data with treadmill on bip s, need to test it with running // for cycling it seems to work... hmm... // 28 bytes 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 5c6295c8b..6838eecaf 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/ActivityKind.java @@ -52,8 +52,9 @@ public class ActivityKind { public static final int TYPE_BADMINTON = 0x00100000; public static final int TYPE_STRENGTH_TRAINING = 0x00200000; public static final int TYPE_HIKING = 0x00400000; + public static final int TYPE_CLIMBING = 0x00800000; - private static final int TYPES_COUNT = 25; + private static final int TYPES_COUNT = 26; 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; @@ -82,6 +83,9 @@ public class ActivityKind { if ((types & ActivityKind.TYPE_HIKING) != 0) { result[i++] = provider.toRawActivityKind(TYPE_HIKING); } + if ((types & ActivityKind.TYPE_CLIMBING) != 0) { + result[i++] = provider.toRawActivityKind(TYPE_CLIMBING); + } if ((types & ActivityKind.TYPE_SWIMMING) != 0) { result[i++] = provider.toRawActivityKind(TYPE_SWIMMING); } @@ -149,6 +153,8 @@ public class ActivityKind { return context.getString(R.string.activity_type_walking); case TYPE_HIKING: return context.getString(R.string.activity_type_hiking); + case TYPE_CLIMBING: + return context.getString(R.string.activity_type_climbing); case TYPE_SWIMMING: return context.getString(R.string.activity_type_swimming); case TYPE_CYCLING: @@ -199,8 +205,11 @@ public class ActivityKind { case TYPE_RUNNING: return R.drawable.ic_activity_running; case TYPE_WALKING: - case TYPE_HIKING: return R.drawable.ic_activity_walking; + case TYPE_HIKING: + return R.drawable.ic_activity_hiking; + case TYPE_CLIMBING: + return R.drawable.ic_activity_climbing; case TYPE_CYCLING: return R.drawable.ic_activity_biking; case TYPE_TREADMILL: 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 e98d2820d..d429376b5 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 @@ -29,6 +29,7 @@ public enum HuamiSportsActivityType { IndoorCycling(8), EllipticalTrainer(9), OutdoorHiking(15), + Climbing(10), Soccer(0x12), JumpRope(0x15), RowingMachine(0x17), @@ -52,6 +53,8 @@ public enum HuamiSportsActivityType { return ActivityKind.TYPE_RUNNING; case OutdoorHiking: return ActivityKind.TYPE_HIKING; + case Climbing: + return ActivityKind.TYPE_CLIMBING; case Treadmill: return ActivityKind.TYPE_TREADMILL; case Cycling: @@ -105,6 +108,8 @@ public enum HuamiSportsActivityType { return OutdoorRunning; case ActivityKind.TYPE_HIKING: return OutdoorHiking; + case ActivityKind.TYPE_CLIMBING: + return Climbing; case ActivityKind.TYPE_TREADMILL: return Treadmill; case ActivityKind.TYPE_CYCLING: diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java index 7e5728974..3e5313c5b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java @@ -105,6 +105,9 @@ public class FetchSportsDetailsOperation extends AbstractFetchOperation { case ActivityKind.TYPE_HIKING: trackType = getContext().getString(R.string.activity_type_hiking); break; + case ActivityKind.TYPE_CLIMBING: + trackType = getContext().getString(R.string.activity_type_climbing); + break; case ActivityKind.TYPE_SWIMMING: trackType = getContext().getString(R.string.activity_type_swimming); break; diff --git a/app/src/main/res/drawable/ic_activity_climbing.xml b/app/src/main/res/drawable/ic_activity_climbing.xml new file mode 100644 index 000000000..6ea1d5e6e --- /dev/null +++ b/app/src/main/res/drawable/ic_activity_climbing.xml @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_activity_hiking.xml b/app/src/main/res/drawable/ic_activity_hiking.xml new file mode 100644 index 000000000..c77e9d84b --- /dev/null +++ b/app/src/main/res/drawable/ic_activity_hiking.xml @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6a682d3b1..4b77a91f5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -827,6 +827,7 @@ Running Walking Hiking + Climbing Swimming Swimming (Open water) Indoor Cycling