diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java index 72e25d9df..a84382f81 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java @@ -233,6 +233,7 @@ public class DeviceSettingsPreferenceConst { public static final String PREF_GALAXY_BUDS_PRESSURE_RELIEF = "pref_galaxy_buds_live_pressure_relief"; public static final String PREF_GALAXY_BUDS_AMBIENT_SOUND = "pref_galaxy_buds_ambient_sound"; public static final String PREF_GALAXY_BUDS_PRO_NOISE_CONTROL="pref_galaxy_buds_pro_noise_control"; + public static final String PREF_GALAXY_BUDS_2_NOISE_CONTROL="pref_galaxy_buds_2_noise_control"; public static final String PREF_GALAXY_PRO_DOUBLE_TAP_EDGE ="pref_galaxy_pro_double_tap_edge"; public static final String PREF_GALAXY_BUDS_PRO_IN_EAR_DETECTION ="pref_galaxy_buds_pro_in_ear_detection"; public static final String PREF_GALAXY_BUDS_PRO_VOICE_DETECT ="pref_galaxy_buds_pro_voice_detect"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBuds2DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBuds2DeviceCoordinator.java new file mode 100644 index 000000000..259277049 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBuds2DeviceCoordinator.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 GalaxyBuds2DeviceCoordinator extends GalaxyBudsGenericCoordinator { + + @NonNull + @Override + public DeviceType getSupportedType(GBDeviceCandidate candidate) { + + String name = candidate.getName(); + + if (name != null && ( + name.startsWith("Galaxy Buds2 (") + )) { + return DeviceType.GALAXY_BUDS2; + } + return DeviceType.UNKNOWN; + } + + @Override + public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) { + return new GalaxyBudsSettingsCustomizer(device); + } + @Override + public DeviceType getDeviceType() { + return DeviceType.GALAXY_BUDS2; + } + + @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, + }; + } +} \ 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 29a5d20e7..8c5a1b01a 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 @@ -20,6 +20,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_PRO_ANC_LEVEL; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_PRO_BALANCE; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_PRO_NOISE_CONTROL; +import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_2_NOISE_CONTROL; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_TOUCH_LEFT; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_TOUCH_LEFT_SWITCH; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_TOUCH_RIGHT; @@ -69,6 +70,8 @@ public class GalaxyBudsSettingsCustomizer implements DeviceSpecificSettingsCusto final Preference pref_galaxy_buds_pro_noise_control = handler.findPreference(PREF_GALAXY_BUDS_PRO_NOISE_CONTROL); String pref_galaxy_buds_pro_noise_control_value = prefs.getString(PREF_GALAXY_BUDS_PRO_NOISE_CONTROL, "0"); + final Preference pref_galaxy_buds_2_noise_control = handler.findPreference(PREF_GALAXY_BUDS_2_NOISE_CONTROL); + String pref_galaxy_buds_2_noise_control_value = prefs.getString(PREF_GALAXY_BUDS_2_NOISE_CONTROL, "0"); final Preference pref_galaxy_buds_pro_anc_level = handler.findPreference(PREF_GALAXY_BUDS_PRO_ANC_LEVEL); final Preference pref_galaxy_buds_ambient_volume = handler.findPreference(PREF_GALAXY_BUDS_AMBIENT_VOLUME); @@ -113,6 +116,36 @@ public class GalaxyBudsSettingsCustomizer implements DeviceSpecificSettingsCusto }); } + if (pref_galaxy_buds_2_noise_control != null) { + + switch (pref_galaxy_buds_2_noise_control_value) { + case "0": + case "1": + pref_galaxy_buds_ambient_volume.setEnabled(false); + break; + case "2": + pref_galaxy_buds_ambient_volume.setEnabled(true); + break; + } + + pref_galaxy_buds_2_noise_control.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + handler.notifyPreferenceChanged(PREF_GALAXY_BUDS_2_NOISE_CONTROL); + switch (newVal.toString()) { + case "0": + case "1": + pref_galaxy_buds_ambient_volume.setEnabled(false); + break; + case "2": + pref_galaxy_buds_ambient_volume.setEnabled(true); + break; + } + + return true; + } + }); + } final Preference pref_galaxy_buds_touch_right = handler.findPreference(PREF_GALAXY_BUDS_TOUCH_RIGHT); String pref_galaxy_buds_touch_right_value = prefs.getString(PREF_GALAXY_BUDS_TOUCH_RIGHT, "1"); 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 ab84365fb..dd361922e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -111,6 +111,7 @@ public enum DeviceType { GALAXY_BUDS_PRO(418, R.drawable.ic_device_galaxy_buds_pro, R.drawable.ic_device_galaxy_buds_pro_disabled, R.string.devicetype_galaxybuds_pro), 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), 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 c6d3beda0..6e64af19f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java @@ -322,6 +322,7 @@ public class DeviceSupportFactory { case GALAXY_BUDS_LIVE: return new ServiceDeviceSupport(new GalaxyBudsDeviceSupport()); case GALAXY_BUDS_PRO: + case GALAXY_BUDS2: 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 22dfbb3e7..59886ca8f 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 @@ -32,7 +32,8 @@ public class GalaxyBudsIOThread extends BtClassicIoThread { 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_BUDS_PRO) + || gbDevice.getType().equals(DeviceType.GALAXY_BUDS2)) { return galaxyBudsProtocol.UUID_GALAXY_BUDS_LIVE_DEVICE_CTRL; } return galaxyBudsProtocol.UUID_GALAXY_BUDS_DEVICE_CTRL; 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 cfde9aa50..c9d128adb 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 @@ -107,8 +107,8 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { // "Use ambient sound during calls" private static final byte set_noise_controls_with_one_earbud = (byte) 0x6f; //0x0/0x1 - // "Noise controls with one earbud" in Accessibility menu. I'm not exactly sure what it means, - // my guess is that it allows ANC even if only one earbuds is in-ear + // "Noise controls with one earbud" in Accessibility menu. + // It allows ANC and ambient sound even if only one earbud is in-ear. private static final byte set_balance = (byte) 0x8f; // takes value in 0-32 range, it is used to change left/right balance @@ -361,6 +361,10 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { int noise_controls = Integer.parseInt(prefs.getString(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_PRO_NOISE_CONTROL, "0")); return encodeMessage(set_noise_controls, (byte) noise_controls); + case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_2_NOISE_CONTROL: + int b2_noise_controls = Integer.parseInt(prefs.getString(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_2_NOISE_CONTROL, "0")); + return encodeMessage(set_noise_controls, (byte) b2_noise_controls); + case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_PRO_ANC_LEVEL: int anc_level = Integer.parseInt(prefs.getString(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_PRO_ANC_LEVEL, "0")); return encodeMessage(set_noise_reduction_level, (byte) anc_level); @@ -380,7 +384,7 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { return encodeMessage(set_ambient_mode, enable_ambient); case DeviceSettingsPreferenceConst.PREFS_GALAXY_BUDS_SEAMLESS_CONNECTION: - byte seamless_switch = (byte) (prefs.getBoolean(DeviceSettingsPreferenceConst.PREFS_GALAXY_BUDS_SEAMLESS_CONNECTION, false) ? 0x01 : 0x00); + byte seamless_switch = (byte) (prefs.getBoolean(DeviceSettingsPreferenceConst.PREFS_GALAXY_BUDS_SEAMLESS_CONNECTION, false) ? 0x00 : 0x01); return encodeMessage(set_seamless_connection, seamless_switch); case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_AMBIENT_VOICE_FOCUS: @@ -517,7 +521,8 @@ 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_BUDS_PRO) + || device.getType().equals(DeviceType.GALAXY_BUDS2)) { 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 c1f687bd7..02459c2f5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java @@ -50,6 +50,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.banglejs.BangleJSCoordinator import nodomain.freeyourgadget.gadgetbridge.devices.casio.gb6900.CasioGB6900DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.casio.gbx100.CasioGBX100DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.domyos.DomyosT540Cooridnator; +import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBuds2DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.flipper.zero.FlipperZeroCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBudsDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBudsLiveDeviceCoordinator; @@ -338,6 +339,7 @@ public class DeviceHelper { result.add(new GalaxyBudsDeviceCoordinator()); result.add(new GalaxyBudsLiveDeviceCoordinator()); result.add(new GalaxyBudsProDeviceCoordinator()); + result.add(new GalaxyBuds2DeviceCoordinator()); result.add(new VescCoordinator()); result.add(new SonyWH1000XM3Coordinator()); result.add(new SonyWH1000XM4Coordinator()); diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 21bb021c3..fbd0728c9 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -2491,14 +2491,14 @@ @string/pref_switch_noise_control @string/pref_title_touch_voice_assistant @string/pref_media_volumedown - @string/pref_title_touch_spotify + @string/pref_title_touch_spotify_official_app @string/pref_switch_noise_control @string/pref_title_touch_voice_assistant @string/pref_media_volumeup - @string/pref_title_touch_spotify + @string/pref_title_touch_spotify_official_app diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 548325533..d382d96b9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1735,7 +1735,7 @@ Ambient Sound Customize Ambient Sound Ambient Sound during call - Hear own voice during call + Hear own voice clearly during calls Ambient Mode Ambient Sound Options Active Noise Cancelling @@ -1760,6 +1760,8 @@ Volume Ambient Sound Spotify + Spotify (official app only) + Spotify (Galaxy Wearable app only) Switch Noise Control Noise Control with one earbud Allow noise control when using one earbud only @@ -1773,7 +1775,7 @@ Voice detect Enable Ambient sound and lower playback automatically after voice has been detected Double tap edge - Detect double tap even when not taped on touch pad + Detect double tap even when not tapped on touch pad End after quiet for: 5 seconds 10 seconds @@ -1816,7 +1818,7 @@ Starting… Not Running Measuring wearing condition… - Measuring atmostpheric pressure… + Measuring atmospheric pressure… Analyzing… Finishing… Off @@ -1962,6 +1964,8 @@ 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 new file mode 100644 index 000000000..24d8ce2b2 --- /dev/null +++ b/app/src/main/res/xml/devicesettings_galaxy_buds_2.xml @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +