From ae1cb4e893386d476263143febcb54d730613fea Mon Sep 17 00:00:00 2001 From: Vitaliy Tomin Date: Thu, 18 Jul 2024 23:03:21 +0800 Subject: [PATCH] [Huawei] Add Huawei Watch 3 gadget --- .../devices/huawei/HuaweiConstants.java | 2 + .../huaweiwatch3/HuaweiWatch3Coordinator.java | 41 +++++++++++++++++++ .../gadgetbridge/model/DeviceType.java | 2 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 46 insertions(+) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatch3/HuaweiWatch3Coordinator.java diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiConstants.java index c822b9808..12925f694 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/HuaweiConstants.java @@ -65,6 +65,8 @@ public final class HuaweiConstants { public static final String HU_BAND9_NAME = "huawei band 9-"; public static final String HU_WATCHGT3_NAME = "huawei watch gt 3-"; public static final String HU_WATCHGT3PRO_NAME = "huawei watch gt 3 pro-"; + public static final String HU_WATCH3_NAME = "huawei watch 3-"; + public static final String HU_WATCH3PRO_NAME = "huawei watch 3 pro-"; public static final String HU_WATCHGT4_NAME = "huawei watch gt 4-"; public static final String HU_WATCHFIT_NAME = "huawei watch fit-"; public static final String HU_WATCHFIT2_NAME = "huawei watch fit 2-"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatch3/HuaweiWatch3Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatch3/HuaweiWatch3Coordinator.java new file mode 100644 index 000000000..b79c34b65 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatch3/HuaweiWatch3Coordinator.java @@ -0,0 +1,41 @@ +/* Copyright (C) 2024 Damien Gaignon, Martin.JM, Vitalii Tomin + + This file is part of Gadgetbridge. + + Gadgetbridge is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Gadgetbridge is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . */ +package nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatch3; + +import java.util.regex.Pattern; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiBRCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; + +public class HuaweiWatch3Coordinator extends HuaweiBRCoordinator { + @Override + public DeviceType getDeviceType() { + return DeviceType.HUAWEIWATCH3; + } + + @Override + protected Pattern getSupportedDeviceName() { + return Pattern.compile("(" + HuaweiConstants.HU_WATCH3_NAME + "|" + HuaweiConstants.HU_WATCH3PRO_NAME + ").*", Pattern.CASE_INSENSITIVE); + } + + @Override + public int getDeviceNameResource() { + return R.string.devicetype_huawei_watch3; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java index 406c3157f..af0544ddd 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -155,6 +155,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiband8.HuaweiBan import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiband9.HuaweiBand9Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweibandaw70.HuaweiBandAw70Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweitalkbandb6.HuaweiTalkBandB6Coordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatch3.HuaweiWatch3Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatch4pro.HuaweiWatch4ProCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatchfit.HuaweiWatchFitCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatchfit2.HuaweiWatchFit2Coordinator; @@ -446,6 +447,7 @@ public enum DeviceType { HUAWEIWATCHFIT2(HuaweiWatchFit2Coordinator.class), HUAWEIWATCHFIT3(HuaweiWatchFit3Coordinator.class), HUAWEIWATCHULTIMATE(HuaweiWatchUltimateCoordinator.class), + HUAWEIWATCH3(HuaweiWatch3Coordinator.class), HUAWEIWATCH4PRO(HuaweiWatch4ProCoordinator.class), VESC(VescCoordinator.class), BINARY_SENSOR(BinarySensorCoordinator.class), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 82e68c0d6..2df68c398 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1615,6 +1615,7 @@ Huawei Watch Fit 2 Huawei Watch Fit 3 Huawei Watch Ultimate + Huawei Watch 3 (Pro) Huawei Watch 4 Pro Femometer Vinca II Xiaomi Watch Lite