From b1b4c81857c6338dde5fceab995b2756dcfb2172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Mon, 23 Dec 2024 17:29:59 +0000 Subject: [PATCH] Redmi Buds 4 Active: Initial support --- .../AbstractRedmiBudsCoordinator.java | 75 +++++++++++++++++++ .../RedmiBuds4ActiveCoordinator.java | 36 +++++++++ .../RedmiBuds5ProCoordinator.java | 55 +------------- .../gadgetbridge/model/DeviceType.java | 2 + app/src/main/res/values/strings.xml | 1 + 5 files changed, 115 insertions(+), 54 deletions(-) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/AbstractRedmiBudsCoordinator.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/RedmiBuds4ActiveCoordinator.java diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/AbstractRedmiBudsCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/AbstractRedmiBudsCoordinator.java new file mode 100644 index 000000000..97e592a97 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/AbstractRedmiBudsCoordinator.java @@ -0,0 +1,75 @@ +/* Copyright (C) 2024 Jonathan Gobbo + + 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.xiaomi.redmibuds5pro; + +import androidx.annotation.NonNull; + +import nodomain.freeyourgadget.gadgetbridge.GBException; +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator; +import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; +import nodomain.freeyourgadget.gadgetbridge.entities.Device; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig; +import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.RedmiBuds5ProDeviceSupport; + +public abstract class AbstractRedmiBudsCoordinator extends AbstractDeviceCoordinator { + @Override + protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException { + + } + + @Override + public String getManufacturer() { + return "Xiaomi"; + } + + @NonNull + @Override + public Class getDeviceSupportClass() { + return RedmiBuds5ProDeviceSupport.class; + } + + @Override + public int getBondingStyle() { + return BONDING_STYLE_NONE; + } + + @Override + public int getBatteryCount() { + return 3; + } + + @Override + public BatteryConfig[] getBatteryConfig(GBDevice device) { + BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_tws_case, R.string.battery_case); + BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_nothing_ear_l, R.string.left_earbud); + BatteryConfig battery3 = new BatteryConfig(2, R.drawable.ic_nothing_ear_r, R.string.right_earbud); + return new BatteryConfig[]{battery1, battery2, battery3}; + } + + @Override + public int getDefaultIconResource() { + return R.drawable.ic_device_nothingear; + } + + @Override + public int getDisabledIconResource() { + return R.drawable.ic_device_nothingear_disabled; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/RedmiBuds4ActiveCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/RedmiBuds4ActiveCoordinator.java new file mode 100644 index 000000000..d83b305b3 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/RedmiBuds4ActiveCoordinator.java @@ -0,0 +1,36 @@ +/* Copyright (C) 2024 Jonathan Gobbo + + 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.xiaomi.redmibuds5pro; + +import java.util.regex.Pattern; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings; +import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; + +public class RedmiBuds4ActiveCoordinator extends AbstractRedmiBudsCoordinator { + @Override + public int getDeviceNameResource() { + return R.string.devicetype_redmi_buds_4_active; + } + + @Override + protected Pattern getSupportedDeviceName() { + return Pattern.compile("Redmi Buds 4 Active"); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/RedmiBuds5ProCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/RedmiBuds5ProCoordinator.java index e9b5fdf43..339b140bf 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/RedmiBuds5ProCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/redmibuds5pro/RedmiBuds5ProCoordinator.java @@ -16,39 +16,14 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro; -import androidx.annotation.NonNull; - import java.util.regex.Pattern; -import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer; -import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator; -import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; -import nodomain.freeyourgadget.gadgetbridge.entities.Device; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.RedmiBuds5ProDeviceSupport; - -public class RedmiBuds5ProCoordinator extends AbstractDeviceCoordinator { - @Override - protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException { - - } - - @Override - public String getManufacturer() { - return "Xiaomi"; - } - - @NonNull - @Override - public Class getDeviceSupportClass() { - return RedmiBuds5ProDeviceSupport.class; - } +public class RedmiBuds5ProCoordinator extends AbstractRedmiBudsCoordinator { @Override public int getDeviceNameResource() { return R.string.devicetype_redmi_buds_5_pro; @@ -59,24 +34,6 @@ public class RedmiBuds5ProCoordinator extends AbstractDeviceCoordinator { return Pattern.compile("Redmi Buds 5 Pro"); } - @Override - public int getBondingStyle() { - return BONDING_STYLE_NONE; - } - - @Override - public int getBatteryCount() { - return 3; - } - - @Override - public BatteryConfig[] getBatteryConfig(GBDevice device) { - BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_tws_case, R.string.battery_case); - BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_nothing_ear_l, R.string.left_earbud); - BatteryConfig battery3 = new BatteryConfig(2, R.drawable.ic_nothing_ear_r, R.string.right_earbud); - return new BatteryConfig[]{battery1, battery2, battery3}; - } - @Override public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) { final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings(); @@ -90,14 +47,4 @@ public class RedmiBuds5ProCoordinator extends AbstractDeviceCoordinator { public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) { return new RedmiBuds5ProSettingsCustomizer(device); } - - @Override - public int getDefaultIconResource() { - return R.drawable.ic_device_nothingear; - } - - @Override - public int getDisabledIconResource() { - return R.drawable.ic_device_nothingear_disabled; - } } 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 4b25f2835..b840e756a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -281,6 +281,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miband9.MiBand9Coordi import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miband9pro.MiBand9ProCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miwatch.MiWatchLiteCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miwatchcolorsport.MiWatchColorSportCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.RedmiBuds4ActiveCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.RedmiBuds5ProCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmismartband2.RedmiSmartBand2Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmismartbandpro.RedmiSmartBandProCoordinator; @@ -356,6 +357,7 @@ public enum DeviceType { MIBAND9PRO(MiBand9ProCoordinator.class), MIWATCHLITE(MiWatchLiteCoordinator.class), MIWATCHCOLORSPORT(MiWatchColorSportCoordinator.class), + REDMIBUDS4ACTIVE(RedmiBuds4ActiveCoordinator.class), REDMIBUDS5PRO(RedmiBuds5ProCoordinator.class), REDMIWATCH3ACTIVE(RedmiWatch3ActiveCoordinator.class), REDMIWATCH3(RedmiWatch3Coordinator.class), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index adf0911fd..ae5ddf6a4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1888,6 +1888,7 @@ Xiaomi Watch Lite Redmi Watch 3 Active Redmi Watch 3 + Redmi Buds 4 Active Redmi Buds 5 Pro Redmi Smart Band 2 Redmi Watch 2