diff --git a/README.md b/README.md index 1bba56510..dde85f8ae 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,8 @@ vendor's servers. - [Galaxy Buds](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Galaxy-Buds#user-content-galaxy-buds) - [Galaxy Buds Live](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Galaxy-Buds#user-content-galaxy-buds-live) - [Galaxy Buds Pro](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Galaxy-Buds#galaxy-buds-pro) + - [Galaxy Buds2](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Galaxy-Buds#galaxy-buds2) + - [Galaxy Buds2 Pro](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Galaxy-Buds#galaxy-buds2-pro) - [HPlus Devices (e.g. ZeBand)](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/HPlus) - ID115 diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBuds2ProDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBuds2ProDeviceCoordinator.java new file mode 100644 index 000000000..6acae4500 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBuds2ProDeviceCoordinator.java @@ -0,0 +1,56 @@ +package nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds; + +import androidx.annotation.NonNull; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; +import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; + +public class GalaxyBuds2ProDeviceCoordinator extends GalaxyBudsGenericCoordinator { + + @NonNull + @Override + public DeviceType getSupportedType(GBDeviceCandidate candidate) { + + String name = candidate.getName(); + + if (name != null && ( + name.startsWith("Galaxy Buds2 Pro") + )) { + return DeviceType.GALAXY_BUDS2_PRO; + } + return DeviceType.UNKNOWN; + } + + @Override + public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) { + return new GalaxyBudsSettingsCustomizer(device); + } + @Override + public DeviceType getDeviceType() { + return DeviceType.GALAXY_BUDS2_PRO; + } + + @Override + public int getBatteryCount() { + return 3; + } + + @Override + public BatteryConfig[] getBatteryConfig() { + BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_buds_pro_case, R.string.battery_case); + BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_buds_pro_left, R.string.left_earbud); + BatteryConfig battery3 = new BatteryConfig(2, R.drawable.ic_buds_pro_right, R.string.right_earbud); + return new BatteryConfig[]{battery1, battery2, battery3}; + } + + @Override + public int[] getSupportedDeviceSpecificSettings(GBDevice device) { + return new int[]{ + R.xml.devicesettings_galaxy_buds_2_pro, + }; + } +} \ No newline at end of file diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBudsSettingsCustomizer.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBudsSettingsCustomizer.java index 8c5a1b01a..fb56a7ec3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBudsSettingsCustomizer.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBudsSettingsCustomizer.java @@ -77,19 +77,21 @@ public class GalaxyBudsSettingsCustomizer implements DeviceSpecificSettingsCusto if (pref_galaxy_buds_pro_noise_control != null) { - switch (pref_galaxy_buds_pro_noise_control_value) { - case "0": - pref_galaxy_buds_pro_anc_level.setEnabled(false); - pref_galaxy_buds_ambient_volume.setEnabled(false); - break; - case "1": - pref_galaxy_buds_pro_anc_level.setEnabled(true); - pref_galaxy_buds_ambient_volume.setEnabled(false); - break; - case "2": - pref_galaxy_buds_pro_anc_level.setEnabled(false); - pref_galaxy_buds_ambient_volume.setEnabled(true); - break; + if (pref_galaxy_buds_pro_anc_level != null && pref_galaxy_buds_ambient_volume != null) { + switch (pref_galaxy_buds_pro_noise_control_value) { + case "0": + pref_galaxy_buds_pro_anc_level.setEnabled(false); + pref_galaxy_buds_ambient_volume.setEnabled(false); + break; + case "1": + pref_galaxy_buds_pro_anc_level.setEnabled(true); + pref_galaxy_buds_ambient_volume.setEnabled(false); + break; + case "2": + pref_galaxy_buds_pro_anc_level.setEnabled(false); + pref_galaxy_buds_ambient_volume.setEnabled(true); + break; + } } pref_galaxy_buds_pro_noise_control.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @@ -98,16 +100,22 @@ public class GalaxyBudsSettingsCustomizer implements DeviceSpecificSettingsCusto handler.notifyPreferenceChanged(PREF_GALAXY_BUDS_PRO_NOISE_CONTROL); switch (newVal.toString()) { case "0": - pref_galaxy_buds_pro_anc_level.setEnabled(false); - pref_galaxy_buds_ambient_volume.setEnabled(false); + if (pref_galaxy_buds_pro_anc_level != null) + pref_galaxy_buds_pro_anc_level.setEnabled(false); + if (pref_galaxy_buds_ambient_volume != null) + pref_galaxy_buds_ambient_volume.setEnabled(false); break; case "1": - pref_galaxy_buds_pro_anc_level.setEnabled(true); - pref_galaxy_buds_ambient_volume.setEnabled(false); + if (pref_galaxy_buds_pro_anc_level != null) + pref_galaxy_buds_pro_anc_level.setEnabled(true); + if (pref_galaxy_buds_ambient_volume != null) + pref_galaxy_buds_ambient_volume.setEnabled(false); break; case "2": - pref_galaxy_buds_pro_anc_level.setEnabled(false); - pref_galaxy_buds_ambient_volume.setEnabled(true); + if (pref_galaxy_buds_pro_anc_level != null) + pref_galaxy_buds_pro_anc_level.setEnabled(false); + if (pref_galaxy_buds_ambient_volume != null) + pref_galaxy_buds_ambient_volume.setEnabled(true); break; } 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 573a9d03b..1772a03f2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -115,6 +115,7 @@ public enum DeviceType { GALAXY_BUDS_LIVE(419, R.drawable.ic_device_galaxy_buds_live, R.drawable.ic_device_galaxy_buds_live_disabled, R.string.devicetype_galaxybuds_live), GALAXY_BUDS(420, R.drawable.ic_device_galaxy_buds, R.drawable.ic_device_galaxy_buds_disabled, R.string.devicetype_galaxybuds), GALAXY_BUDS2(421, R.drawable.ic_device_galaxy_buds_pro, R.drawable.ic_device_galaxy_buds_pro_disabled, R.string.devicetype_galaxybuds_2), + GALAXY_BUDS2_PRO(422, R.drawable.ic_device_galaxy_buds_pro, R.drawable.ic_device_galaxy_buds_pro_disabled, R.string.devicetype_galaxybuds_2_pro), SONY_WH_1000XM3(430, R.drawable.ic_device_sony_overhead, R.drawable.ic_device_sony_overhead_disabled, R.string.devicetype_sony_wh_1000xm3), SONY_WF_SP800N(431, R.drawable.ic_device_sony_wf_800n, R.drawable.ic_device_sony_wf_800n_disabled, R.string.devicetype_sony_wf_sp800n), SONY_WH_1000XM4(432, R.drawable.ic_device_sony_overhead, R.drawable.ic_device_sony_overhead_disabled, R.string.devicetype_sony_wh_1000xm4), diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java index 37c8d9b82..1e71b773e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java @@ -333,6 +333,7 @@ public class DeviceSupportFactory { return new ServiceDeviceSupport(new GalaxyBudsDeviceSupport()); case GALAXY_BUDS_PRO: case GALAXY_BUDS2: + case GALAXY_BUDS2_PRO: return new ServiceDeviceSupport(new GalaxyBudsDeviceSupport(), ServiceDeviceSupport.Flags.BUSY_CHECKING); case SONY_WH_1000XM3: return new ServiceDeviceSupport(new SonyHeadphonesSupport()); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsIOThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsIOThread.java index 59886ca8f..5c37a8e8e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsIOThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsIOThread.java @@ -31,13 +31,7 @@ public class GalaxyBudsIOThread extends BtClassicIoThread { if (gbDevice.getType().equals(DeviceType.GALAXY_BUDS)) { return galaxyBudsProtocol.UUID_GALAXY_BUDS_DEVICE_CTRL; } - if (gbDevice.getType().equals(DeviceType.GALAXY_BUDS_LIVE) - || gbDevice.getType().equals(DeviceType.GALAXY_BUDS_PRO) - || gbDevice.getType().equals(DeviceType.GALAXY_BUDS2)) { - return galaxyBudsProtocol.UUID_GALAXY_BUDS_LIVE_DEVICE_CTRL; - } - return galaxyBudsProtocol.UUID_GALAXY_BUDS_DEVICE_CTRL; - + return galaxyBudsProtocol.UUID_GALAXY_BUDS_LIVE_DEVICE_CTRL; } public GalaxyBudsIOThread(GBDevice device, Context context, GalaxyBudsProtocol deviceProtocol, diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsProtocol.java index c9d128adb..0643b6210 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsProtocol.java @@ -520,9 +520,11 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { protected GalaxyBudsProtocol(GBDevice device) { super(device); - if (device.getType().equals(DeviceType.GALAXY_BUDS_LIVE) - || device.getType().equals(DeviceType.GALAXY_BUDS_PRO) - || device.getType().equals(DeviceType.GALAXY_BUDS2)) { + DeviceType type = device.getType(); + if (type.equals(DeviceType.GALAXY_BUDS_LIVE) + || type.equals(DeviceType.GALAXY_BUDS_PRO) + || type.equals(DeviceType.GALAXY_BUDS2) + || type.equals(DeviceType.GALAXY_BUDS2_PRO)) { StartOfMessage = SOM_BUDS_PLUS; EndOfMessage = EOM_BUDS_PLUS; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java index c11ea4a0d..d22e0d388 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java @@ -60,6 +60,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.flipper.zero.FlipperZeroCoor import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBudsDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBudsLiveDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBudsProDeviceCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBuds2ProDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.EXRIZUK8Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.HPlusCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.MakibesF68Coordinator; @@ -350,6 +351,7 @@ public class DeviceHelper { result.add(new GalaxyBudsLiveDeviceCoordinator()); result.add(new GalaxyBudsProDeviceCoordinator()); result.add(new GalaxyBuds2DeviceCoordinator()); + result.add(new GalaxyBuds2ProDeviceCoordinator()); result.add(new VescCoordinator()); result.add(new SonyLinkBudsSCoordinator()); result.add(new SonyWH1000XM3Coordinator()); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 518fa52d4..71512f43e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1730,6 +1730,8 @@ Galaxy Buds Galaxy Buds Live Galaxy Buds Pro + Galaxy Buds2 + Galaxy Buds2 Pro Play/pause the music depending if you wear the earbuds In-Ear detection Play calls through your earbuds when they are in your ears @@ -1748,6 +1750,7 @@ Game mode Only if your phone supports game mode Touch Lock + Touch controls Disable touch events Experimental Seamless connection switch @@ -1987,8 +1990,6 @@ Steps Achievements Hourly chime The watch will beep once an hour - Galaxy Buds2 - Touch controls Flipper zero Bluetooth Intent API Allow controlling Bluetooth connection via Intent API diff --git a/app/src/main/res/xml/devicesettings_galaxy_buds_2.xml b/app/src/main/res/xml/devicesettings_galaxy_buds_2.xml index 24d8ce2b2..387741b4b 100644 --- a/app/src/main/res/xml/devicesettings_galaxy_buds_2.xml +++ b/app/src/main/res/xml/devicesettings_galaxy_buds_2.xml @@ -28,6 +28,60 @@ + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/xml/devicesettings_galaxy_buds_2_pro.xml b/app/src/main/res/xml/devicesettings_galaxy_buds_2_pro.xml new file mode 100644 index 000000000..1a74a474c --- /dev/null +++ b/app/src/main/res/xml/devicesettings_galaxy_buds_2_pro.xml @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/devicesettings_galaxy_buds_pro.xml b/app/src/main/res/xml/devicesettings_galaxy_buds_pro.xml index fb5aff023..42ee5b0c3 100644 --- a/app/src/main/res/xml/devicesettings_galaxy_buds_pro.xml +++ b/app/src/main/res/xml/devicesettings_galaxy_buds_pro.xml @@ -38,6 +38,80 @@ + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - -