From 175f4bf60ccd8b6f1ad623a05d51f58972efe25e Mon Sep 17 00:00:00 2001 From: Vitaliy Tomin Date: Mon, 14 Oct 2024 09:42:06 +0800 Subject: [PATCH] huawei: Add new gadget Huawei Watch D2 --- .../devices/huawei/HuaweiConstants.java | 1 + .../HuaweiWatchD2Coordinator.java | 46 +++++++++++++++++++ .../gadgetbridge/model/DeviceType.java | 2 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 50 insertions(+) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchd2/HuaweiWatchD2Coordinator.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 31d7b0472..fc52fd879 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,7 @@ public final class HuaweiConstants { public static final String HU_BAND7_NAME = "huawei band 7-"; public static final String HU_BAND8_NAME = "huawei band 8-"; public static final String HU_BAND9_NAME = "huawei band 9-"; + public static final String HU_WATCHD2_NAME = "huawei watch d2-"; public static final String HU_WATCHGT3_NAME = "huawei watch gt 3-"; public static final String HU_WATCHGT3SE_NAME = "huawei watch gt 3 se-"; public static final String HU_WATCHGT3PRO_NAME = "huawei watch gt 3 pro-"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchd2/HuaweiWatchD2Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchd2/HuaweiWatchD2Coordinator.java new file mode 100644 index 000000000..911bb7fcb --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchd2/HuaweiWatchD2Coordinator.java @@ -0,0 +1,46 @@ +/* Copyright (C) 2024 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.huaweiwatchd2; + +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 HuaweiWatchD2Coordinator extends HuaweiBRCoordinator { + @Override + public DeviceType getDeviceType() { + return DeviceType.HUAWEIWATCHD2; + } + + @Override + protected Pattern getSupportedDeviceName() { + return Pattern.compile("(" + HuaweiConstants.HU_WATCHD2_NAME + ").*", Pattern.CASE_INSENSITIVE); + } + + @Override + public int getDeviceNameResource() { + return R.string.devicetype_huawei_watchd2; + } + + @Override + public boolean supportsUnicodeEmojis() { + return true; + } +} 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 fabcbdd46..2e1cc28b6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -179,6 +179,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweibandaw70.Huawei 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.huaweiwatchd2.HuaweiWatchD2Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatchfit.HuaweiWatchFitCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatchfit2.HuaweiWatchFit2Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatchfit3.HuaweiWatchFit3Coordinator; @@ -504,6 +505,7 @@ public enum DeviceType { HONORMAGICWATCH2(HonorMagicWatch2Coordinator.class), HONORWATCHGS3(HonorWatchGS3Coordinator.class), HONORWATCHGSPRO(HonorWatchGSProCoordinator.class), + HUAWEIWATCHD2(HuaweiWatchD2Coordinator.class), HUAWEIWATCHGT3(HuaweiWatchGT3Coordinator.class), HUAWEIWATCHGT4(HuaweiWatchGT4Coordinator.class), HUAWEIWATCHGT5(HuaweiWatchGT5Coordinator.class), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 888e50d88..c88d2f92d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1844,6 +1844,7 @@ Huawei Watch GT 2 (Pro) Huawei Watch GT 2e Huawei Talk Band B6 + Huawei Watch D2 Huawei Watch GT 3 (Pro) Huawei Watch GT 4 Huawei Watch GT 5 (Pro)