From 48e1bc1a8a231d14b7a8260a8a5df1d3607f074e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Thu, 14 Dec 2023 21:53:27 +0000 Subject: [PATCH] ColaCao 2021 / 2023: Initial support Reports in #3455 and #2955 mention that everything works, except HR, which crashes the devices (they do not have an HR sensor), so we just disable HR support. --- README.md | 3 + .../fitpro/FitProDeviceCoordinator.java | 2 - .../fitpro/colacao/ColaCao21Coordinator.java | 56 +++++++++++++++++++ .../fitpro/colacao/ColaCao23Coordinator.java | 56 +++++++++++++++++++ .../gadgetbridge/model/DeviceType.java | 4 ++ app/src/main/res/values/strings.xml | 2 + 6 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/colacao/ColaCao21Coordinator.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/colacao/ColaCao23Coordinator.java diff --git a/README.md b/README.md index 3df8506be..f0d4d6156 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,9 @@ vendor's servers. - Casio GBD-100 - Casio GBD-200 - Casio GBD-H1000 +- ColaCao (FitPro devices) + - ColaCao 2023 + - ColaCao 2021 - [Femometer Vinca II](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Femometer-Vinca-II) - [FitPro](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/FitPro) - Fossil diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/FitProDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/FitProDeviceCoordinator.java index 16ee11baa..be5123667 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/FitProDeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/FitProDeviceCoordinator.java @@ -40,9 +40,7 @@ import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.entities.Device; import nodomain.freeyourgadget.gadgetbridge.entities.FitProActivitySampleDao; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.fitpro.FitProDeviceSupport; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/colacao/ColaCao21Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/colacao/ColaCao21Coordinator.java new file mode 100644 index 000000000..5428b7b1c --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/colacao/ColaCao21Coordinator.java @@ -0,0 +1,56 @@ +/* Copyright (C) 2016-2023 Petr Vaněk, José Rebelo + + 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.fitpro.colacao; + +import androidx.annotation.DrawableRes; + +import java.util.regex.Pattern; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.fitpro.FitProDeviceCoordinator; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; + +public class ColaCao21Coordinator extends FitProDeviceCoordinator { + @Override + protected Pattern getSupportedDeviceName() { + return Pattern.compile("ColaCao21"); + } + + @Override + public boolean supportsHeartRateMeasurement(final GBDevice device) { + // HR requests crash the device + return false; + } + + @Override + @DrawableRes + public int getDefaultIconResource() { + return R.drawable.ic_device_amazfit_bip; + } + + @Override + @DrawableRes + public int getDisabledIconResource() { + return R.drawable.ic_device_amazfit_bip_disabled; + } + + @Override + public int getDeviceNameResource() { + return R.string.devicetype_colacao21; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/colacao/ColaCao23Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/colacao/ColaCao23Coordinator.java new file mode 100644 index 000000000..cf735ec98 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/fitpro/colacao/ColaCao23Coordinator.java @@ -0,0 +1,56 @@ +/* Copyright (C) 2016-2023 Petr Vaněk, José Rebelo + + 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.fitpro.colacao; + +import androidx.annotation.DrawableRes; + +import java.util.regex.Pattern; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.fitpro.FitProDeviceCoordinator; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; + +public class ColaCao23Coordinator extends FitProDeviceCoordinator { + @Override + protected Pattern getSupportedDeviceName() { + return Pattern.compile("ColaCao23"); + } + + @Override + public boolean supportsHeartRateMeasurement(final GBDevice device) { + // HR requests crash the device + return false; + } + + @Override + @DrawableRes + public int getDefaultIconResource() { + return R.drawable.ic_device_amazfit_bip; + } + + @Override + @DrawableRes + public int getDisabledIconResource() { + return R.drawable.ic_device_amazfit_bip_disabled; + } + + @Override + public int getDeviceNameResource() { + return R.string.devicetype_colacao23; + } +} 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 598bef4bd..4a9bdf251 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -34,6 +34,8 @@ import nodomain.freeyourgadget.gadgetbridge.devices.divoom.PixooCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.domyos.DomyosT540Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.femometer.FemometerVinca2DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.fitpro.FitProDeviceCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.fitpro.colacao.ColaCao21Coordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.fitpro.colacao.ColaCao23Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.flipper.zero.FlipperZeroCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBuds2DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBuds2ProDeviceCoordinator; @@ -257,6 +259,8 @@ public enum DeviceType { BOHEMIC_SMART_BRACELET(BohemicSmartBraceletDeviceCoordinator.class), SMAQ2OSS(SMAQ2OSSCoordinator.class), FITPRO(FitProDeviceCoordinator.class), + COLACAO21(ColaCao21Coordinator.class), + COLACAO23(ColaCao23Coordinator.class), ITAG(ITagCoordinator.class), NUTMINI(NutCoordinator.class), VIVOMOVE_HR(VivomoveHrCoordinator.class), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 31c2ebd81..c0857fced 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1404,6 +1404,8 @@ Wasp-os SMA-Q2 OSS FitPro + ColaCao 2021 + ColaCao 2023 Domyos T540 Sony WH-1000XM2 Sony WH-1000XM3