From d807909b259f437bc8281a740d51079473938707 Mon Sep 17 00:00:00 2001 From: "Martin.JM" Date: Sun, 24 Nov 2024 21:10:01 +0100 Subject: [PATCH] Huawei: Add calories support These devices provide calories instead of kcal, which are rounded per-sample, resulting in a slight difference from what is shown on the device itself. --- .../freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java | 2 +- .../gadgetbridge/devices/huawei/HuaweiBRCoordinator.java | 5 +++++ .../gadgetbridge/devices/huawei/HuaweiLECoordinator.java | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java b/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java index 66af8f3ae..18cb1641c 100644 --- a/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java +++ b/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java @@ -1363,7 +1363,7 @@ public class GBDaoGenerator { activitySample.addIntProperty("calories").notNull().codeBeforeGetter( "@Override\n" + " public int getActiveCalories() {\n" + - " return getCalories();\n" + + " return getCalories() == HuaweiActivitySample.NOT_MEASURED ? HuaweiActivitySample.NOT_MEASURED : Math.round(getCalories() / 1000f);\n" + " }\n" ); activitySample.addIntProperty("distance").notNull().codeBeforeGetter( diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiBRCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiBRCoordinator.java index 6a49b498c..447e9a1b2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiBRCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiBRCoordinator.java @@ -163,6 +163,11 @@ public abstract class HuaweiBRCoordinator extends AbstractBLClassicDeviceCoordin return true; } + @Override + public boolean supportsActiveCalories() { + return true; + } + @Override public boolean supportsActivityTracking() { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiLECoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiLECoordinator.java index a9b7ad201..13d06cc23 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiLECoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiLECoordinator.java @@ -172,6 +172,11 @@ public abstract class HuaweiLECoordinator extends AbstractBLEDeviceCoordinator i return true; } + @Override + public boolean supportsActiveCalories() { + return true; + } + @Override public boolean supportsActivityTracking() { return true;