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 fa8e833d1..7e9ce39fc 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 @@ -63,6 +63,7 @@ public final class HuaweiConstants { public static final String HU_BAND8_NAME = "huawei band 8-"; 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_WATCHFIT_NAME = "huawei watch fit-"; public static final String PREF_HUAWEI_ADDRESS = "huawei_address"; public static final String PREF_HUAWEI_WORKMODE = "workmode"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchfit/HuaweiWatchFitCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchfit/HuaweiWatchFitCoordinator.java new file mode 100644 index 000000000..559cdc7ea --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huawei/huaweiwatchfit/HuaweiWatchFitCoordinator.java @@ -0,0 +1,76 @@ +/* Copyright (C) 2024 Damien Gaignon, Martin.JM + + 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.huaweiwatchfit; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.regex.Pattern; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.TimeSampleProvider; +import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants; +import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiLECoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiSpo2SampleProvider; +import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.model.Spo2Sample; + +public class HuaweiWatchFitCoordinator extends HuaweiLECoordinator { + private static final Logger LOG = LoggerFactory.getLogger(HuaweiWatchFitCoordinator.class); + + @Override + public DeviceType getDeviceType() { + return DeviceType.HUAWEIWATCHFIT; + } + + @Override + protected Pattern getSupportedDeviceName() { + return Pattern.compile(HuaweiConstants.HU_WATCHFIT_NAME + ".*", Pattern.CASE_INSENSITIVE); + } + + @Override + public boolean supportsHeartRateMeasurement(GBDevice device) { + return true; + } + + @Override + public boolean supportsSpo2() { + return true; + } + + @Override + public TimeSampleProvider getSpo2SampleProvider(GBDevice device, DaoSession session) { + return new HuaweiSpo2SampleProvider(device, session); + } + + @Override + public int[] getSupportedDeviceSpecificSettings(GBDevice device) { + return getHuaweiCoordinator().genericHuaweiSupportedDeviceSpecificSettings(new int[]{ + R.xml.devicesettings_heartrate_automatic_enable, + R.xml.devicesettings_spo_automatic_enable, + R.xml.devicesettings_find_phone, + R.xml.devicesettings_disable_find_phone_with_dnd, + }); + } + + @Override + public int getDeviceNameResource() { + return R.string.devicetype_huawei_watchfit; + } +} 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 41e91fb6e..ca378051c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -117,6 +117,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiband7.HuaweiBan import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiband8.HuaweiBand8Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweibandaw70.HuaweiBandAw70Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweitalkbandb6.HuaweiTalkBandB6Coordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatchfit.HuaweiWatchFitCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatchgt.HuaweiWatchGTCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatchgt2.HuaweiWatchGT2Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.huaweiwatchgt2e.HuaweiWatchGT2eCoordinator; @@ -350,6 +351,7 @@ public enum DeviceType { HONORMAGICWATCH2(HonorMagicWatch2Coordinator.class), HUAWEIWATCHGT3(HuaweiWatchGT3Coordinator.class), HUAWEIBAND8(HuaweiBand8Coordinator.class), + HUAWEIWATCHFIT(HuaweiWatchFitCoordinator.class), VESC(VescCoordinator.class), BINARY_SENSOR(BinarySensorCoordinator.class), FLIPPER_ZERO(FlipperZeroCoordinator.class), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 456ff9d08..2e78acda7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1535,6 +1535,7 @@ Huawei Watch GT 2e Huawei Talk Band B6 Huawei Watch GT 3 (Pro) + Huawei Watch Fit Femometer Vinca II Xiaomi Watch Lite Redmi Watch 3 Active