mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 09:01:55 +01:00
Sony Headphones: Allow overriding supported features
This commit is contained in:
parent
7f439f2a03
commit
be9bf8f214
@ -486,6 +486,9 @@ public class DeviceSettingsPreferenceConst {
|
|||||||
public static final String PREF_SONY_ADAPTIVE_VOLUME_CONTROL = "pref_adaptive_volume_control";
|
public static final String PREF_SONY_ADAPTIVE_VOLUME_CONTROL = "pref_adaptive_volume_control";
|
||||||
public static final String PREF_SONY_WIDE_AREA_TAP = "pref_wide_area_tap";
|
public static final String PREF_SONY_WIDE_AREA_TAP = "pref_wide_area_tap";
|
||||||
|
|
||||||
|
public static final String PREF_OVERRIDE_FEATURES_ENABLED = "override_features_enabled";
|
||||||
|
public static final String PREF_OVERRIDE_FEATURES_LIST = "override_features_list";
|
||||||
|
|
||||||
public static final String PREF_MOONDROP_EQUALIZER_PRESET = "pref_moondrop_equalizer_preset";
|
public static final String PREF_MOONDROP_EQUALIZER_PRESET = "pref_moondrop_equalizer_preset";
|
||||||
public static final String PREF_MOONDROP_TOUCH_PLAY_PAUSE_EARBUD = "pref_moondrop_touch_play_pause_earbud";
|
public static final String PREF_MOONDROP_TOUCH_PLAY_PAUSE_EARBUD = "pref_moondrop_touch_play_pause_earbud";
|
||||||
public static final String PREF_MOONDROP_TOUCH_PLAY_PAUSE_TRIGGER = "pref_moondrop_touch_play_pause_trigger";
|
public static final String PREF_MOONDROP_TOUCH_PLAY_PAUSE_TRIGGER = "pref_moondrop_touch_play_pause_trigger";
|
||||||
|
@ -1382,7 +1382,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
|||||||
coordinator.getSupportedDeviceSpecificConnectionSettings()
|
coordinator.getSupportedDeviceSpecificConnectionSettings()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (coordinator.getBatteryCount() > 0) {
|
if (coordinator.getBatteryCount(device) > 0) {
|
||||||
deviceSpecificSettings.addRootScreen(
|
deviceSpecificSettings.addRootScreen(
|
||||||
DeviceSpecificSettingsScreen.BATTERY
|
DeviceSpecificSettingsScreen.BATTERY
|
||||||
);
|
);
|
||||||
@ -1398,6 +1398,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
|||||||
|
|
||||||
deviceSpecificSettings.addRootScreen(
|
deviceSpecificSettings.addRootScreen(
|
||||||
DeviceSpecificSettingsScreen.DEVELOPER,
|
DeviceSpecificSettingsScreen.DEVELOPER,
|
||||||
|
R.xml.devicesettings_header_intent_api,
|
||||||
R.xml.devicesettings_settings_third_party_apps
|
R.xml.devicesettings_settings_third_party_apps
|
||||||
);
|
);
|
||||||
if (coordinator.getConnectionType().usesBluetoothLE()) {
|
if (coordinator.getConnectionType().usesBluetoothLE()) {
|
||||||
|
@ -353,15 +353,15 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
|
|||||||
// multiple battery support: at this point we support up to three batteries
|
// multiple battery support: at this point we support up to three batteries
|
||||||
// to support more batteries, the battery UI would need to be extended
|
// to support more batteries, the battery UI would need to be extended
|
||||||
|
|
||||||
holder.batteryStatusBox0.setVisibility(coordinator.getBatteryCount() > 0 ? View.VISIBLE : View.GONE);
|
holder.batteryStatusBox0.setVisibility(coordinator.getBatteryCount(device) > 0 ? View.VISIBLE : View.GONE);
|
||||||
holder.batteryStatusBox1.setVisibility(coordinator.getBatteryCount() > 1 ? View.VISIBLE : View.GONE);
|
holder.batteryStatusBox1.setVisibility(coordinator.getBatteryCount(device) > 1 ? View.VISIBLE : View.GONE);
|
||||||
holder.batteryStatusBox2.setVisibility(coordinator.getBatteryCount() > 2 ? View.VISIBLE : View.GONE);
|
holder.batteryStatusBox2.setVisibility(coordinator.getBatteryCount(device) > 2 ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
LinearLayout[] batteryStatusBoxes = {holder.batteryStatusBox0, holder.batteryStatusBox1, holder.batteryStatusBox2};
|
LinearLayout[] batteryStatusBoxes = {holder.batteryStatusBox0, holder.batteryStatusBox1, holder.batteryStatusBox2};
|
||||||
TextView[] batteryStatusLabels = {holder.batteryStatusLabel0, holder.batteryStatusLabel1, holder.batteryStatusLabel2};
|
TextView[] batteryStatusLabels = {holder.batteryStatusLabel0, holder.batteryStatusLabel1, holder.batteryStatusLabel2};
|
||||||
ImageView[] batteryIcons = {holder.batteryIcon0, holder.batteryIcon1, holder.batteryIcon2};
|
ImageView[] batteryIcons = {holder.batteryIcon0, holder.batteryIcon1, holder.batteryIcon2};
|
||||||
|
|
||||||
for (int batteryIndex = 0; batteryIndex < coordinator.getBatteryCount(); batteryIndex++) {
|
for (int batteryIndex = 0; batteryIndex < coordinator.getBatteryCount(device); batteryIndex++) {
|
||||||
|
|
||||||
int batteryLevel = device.getBatteryLevel(batteryIndex);
|
int batteryLevel = device.getBatteryLevel(batteryIndex);
|
||||||
float batteryVoltage = device.getBatteryVoltage(batteryIndex);
|
float batteryVoltage = device.getBatteryVoltage(batteryIndex);
|
||||||
@ -823,7 +823,7 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
|
|||||||
}
|
}
|
||||||
|
|
||||||
holder.powerOff.setVisibility(View.GONE);
|
holder.powerOff.setVisibility(View.GONE);
|
||||||
if (device.isInitialized() && coordinator.supportsPowerOff()) {
|
if (device.isInitialized() && coordinator.supportsPowerOff(device)) {
|
||||||
holder.powerOff.setVisibility(View.VISIBLE);
|
holder.powerOff.setVisibility(View.VISIBLE);
|
||||||
holder.powerOff.setOnClickListener(new View.OnClickListener() {
|
holder.powerOff.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -798,14 +798,14 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 1;
|
return 1;
|
||||||
} //multiple battery support, default is 1, maximum is 3, 0 will disable the battery in UI
|
} //multiple battery support, default is 1, maximum is 3, 0 will disable the battery in UI
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
|
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
|
||||||
final BatteryConfig[] batteryConfigs = new BatteryConfig[getBatteryCount()];
|
final BatteryConfig[] batteryConfigs = new BatteryConfig[getBatteryCount(device)];
|
||||||
for (int i = 0; i < getBatteryCount(); i++) {
|
for (int i = 0; i < getBatteryCount(device); i++) {
|
||||||
batteryConfigs[i] = new BatteryConfig(i);
|
batteryConfigs[i] = new BatteryConfig(i);
|
||||||
}
|
}
|
||||||
return batteryConfigs;
|
return batteryConfigs;
|
||||||
@ -817,7 +817,7 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsPowerOff() {
|
public boolean supportsPowerOff(final GBDevice device) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,13 +745,13 @@ public interface DeviceCoordinator {
|
|||||||
* 1 is default, 3 is maximum at the moment (as per UI layout)
|
* 1 is default, 3 is maximum at the moment (as per UI layout)
|
||||||
* 0 will disable the battery from the UI
|
* 0 will disable the battery from the UI
|
||||||
*/
|
*/
|
||||||
int getBatteryCount();
|
int getBatteryCount(GBDevice device);
|
||||||
|
|
||||||
BatteryConfig[] getBatteryConfig(GBDevice device);
|
BatteryConfig[] getBatteryConfig(GBDevice device);
|
||||||
|
|
||||||
boolean addBatteryPollingSettings();
|
boolean addBatteryPollingSettings();
|
||||||
|
|
||||||
boolean supportsPowerOff();
|
boolean supportsPowerOff(GBDevice device);
|
||||||
|
|
||||||
PasswordCapabilityImpl.Mode getPasswordCapability();
|
PasswordCapabilityImpl.Mode getPasswordCapability();
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class BandWPSeriesDeviceCoordinator extends AbstractBLEDeviceCoordinator
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ public class BinarySensorCoordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ public abstract class AbstractColmiR0xCoordinator extends AbstractBLEDeviceCoord
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsPowerOff() {
|
public boolean supportsPowerOff(final GBDevice device) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class GalaxyBuds2DeviceCoordinator extends GalaxyBudsGenericCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class GalaxyBuds2ProDeviceCoordinator extends GalaxyBudsGenericCoordinato
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class GalaxyBudsDeviceCoordinator extends GalaxyBudsGenericCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class GalaxyBudsLiveDeviceCoordinator extends GalaxyBudsGenericCoordinato
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class GalaxyBudsProDeviceCoordinator extends GalaxyBudsGenericCoordinator
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public abstract class HuaweiFreebudsCoordinator extends AbstractBLClassicDeviceC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class MiCompositionScaleCoordinator extends AbstractBLEDeviceCoordinator
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class MiSmartScaleCoordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class MoondropSpaceTravelCoordinator extends AbstractBLClassicDeviceCoord
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public abstract class AbstractEarCoordinator extends AbstractBLClassicDeviceCoor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public abstract class OppoHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||||
@ -47,7 +48,7 @@ public class Roidmi1Coordinator extends RoidmiCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
// Roidmi 1 does not have voltage support
|
// Roidmi 1 does not have voltage support
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class ScannableDeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,34 +17,34 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones;
|
||||||
|
|
||||||
public enum SonyHeadphonesCapabilities {
|
public enum SonyHeadphonesCapabilities {
|
||||||
BatterySingle,
|
AdaptiveVolumeControl,
|
||||||
BatteryDual,
|
|
||||||
BatteryDual2,
|
|
||||||
BatteryCase,
|
|
||||||
PowerOffFromPhone,
|
|
||||||
AmbientSoundControl,
|
AmbientSoundControl,
|
||||||
AmbientSoundControl2,
|
AmbientSoundControl2,
|
||||||
NoNoiseCancelling,
|
AmbientSoundControlButtonMode,
|
||||||
WindNoiseReduction,
|
|
||||||
SpeakToChatEnabled,
|
|
||||||
SpeakToChatConfig,
|
|
||||||
SpeakToChatFocusOnVoice,
|
|
||||||
AncOptimizer,
|
AncOptimizer,
|
||||||
AudioSettingsOnlyOnSbcCodec,
|
AudioSettingsOnlyOnSbcCodec,
|
||||||
AudioUpsampling,
|
AudioUpsampling,
|
||||||
ButtonModesLeftRight,
|
|
||||||
AmbientSoundControlButtonMode,
|
|
||||||
VoiceNotifications,
|
|
||||||
AutomaticPowerOffWhenTakenOff,
|
|
||||||
AutomaticPowerOffByTime,
|
AutomaticPowerOffByTime,
|
||||||
TouchSensorSingle,
|
AutomaticPowerOffWhenTakenOff,
|
||||||
|
BatteryCase,
|
||||||
|
BatteryDual,
|
||||||
|
BatteryDual2,
|
||||||
|
BatterySingle,
|
||||||
|
ButtonModesLeftRight,
|
||||||
EqualizerSimple,
|
EqualizerSimple,
|
||||||
EqualizerWithCustomBands,
|
EqualizerWithCustomBands,
|
||||||
SoundPosition,
|
NoNoiseCancelling,
|
||||||
SurroundMode,
|
|
||||||
QuickAccess,
|
|
||||||
PauseWhenTakenOff,
|
PauseWhenTakenOff,
|
||||||
|
PowerOffFromPhone,
|
||||||
|
QuickAccess,
|
||||||
|
SoundPosition,
|
||||||
|
SpeakToChatConfig,
|
||||||
|
SpeakToChatEnabled,
|
||||||
|
SpeakToChatFocusOnVoice,
|
||||||
|
SurroundMode,
|
||||||
|
TouchSensorSingle,
|
||||||
|
VoiceNotifications,
|
||||||
Volume,
|
Volume,
|
||||||
WideAreaTap,
|
WideAreaTap,
|
||||||
AdaptiveVolumeControl,
|
WindNoiseReduction,
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,12 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsScreen;
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsScreen;
|
||||||
@ -39,6 +42,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
|
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.SonyHeadphonesSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.SonyHeadphonesSupport;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.preferences.DevicePrefs;
|
||||||
|
|
||||||
public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceCoordinator {
|
public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceCoordinator {
|
||||||
@Override
|
@Override
|
||||||
@ -61,31 +65,31 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsPowerOff() {
|
public boolean supportsPowerOff(final GBDevice device) {
|
||||||
return supports(SonyHeadphonesCapabilities.PowerOffFromPhone);
|
return supports(device, SonyHeadphonesCapabilities.PowerOffFromPhone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
if (supports(SonyHeadphonesCapabilities.BatterySingle)) {
|
if (supports(device, SonyHeadphonesCapabilities.BatterySingle)) {
|
||||||
if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) {
|
if (supports(device, SonyHeadphonesCapabilities.BatteryDual) || supports(device, SonyHeadphonesCapabilities.BatteryDual2)) {
|
||||||
throw new IllegalStateException("A device can't have both single and dual battery");
|
throw new IllegalStateException("A device can't have both single and dual battery");
|
||||||
} else if (supports(SonyHeadphonesCapabilities.BatteryCase)) {
|
} else if (supports(device, SonyHeadphonesCapabilities.BatteryCase)) {
|
||||||
throw new IllegalStateException("Devices with single battery + case are not supported by the protocol");
|
throw new IllegalStateException("Devices with single battery + case are not supported by the protocol");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int batteryCount = 0;
|
int batteryCount = 0;
|
||||||
|
|
||||||
if (supports(SonyHeadphonesCapabilities.BatterySingle)) {
|
if (supports(device, SonyHeadphonesCapabilities.BatterySingle)) {
|
||||||
batteryCount += 1;
|
batteryCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supports(SonyHeadphonesCapabilities.BatteryCase)) {
|
if (supports(device, SonyHeadphonesCapabilities.BatteryCase)) {
|
||||||
batteryCount += 1;
|
batteryCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) {
|
if (supports(device, SonyHeadphonesCapabilities.BatteryDual) || supports(device, SonyHeadphonesCapabilities.BatteryDual2)) {
|
||||||
batteryCount += 2;
|
batteryCount += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,15 +100,15 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
|||||||
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
|
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
|
||||||
final List<BatteryConfig> batteries = new ArrayList<>(3);
|
final List<BatteryConfig> batteries = new ArrayList<>(3);
|
||||||
|
|
||||||
if (supports(SonyHeadphonesCapabilities.BatterySingle)) {
|
if (supports(device, SonyHeadphonesCapabilities.BatterySingle)) {
|
||||||
batteries.add(new BatteryConfig(batteries.size(), GBDevice.BATTERY_ICON_DEFAULT, GBDevice.BATTERY_LABEL_DEFAULT, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
batteries.add(new BatteryConfig(batteries.size(), GBDevice.BATTERY_ICON_DEFAULT, GBDevice.BATTERY_LABEL_DEFAULT, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supports(SonyHeadphonesCapabilities.BatteryCase)) {
|
if (supports(device, SonyHeadphonesCapabilities.BatteryCase)) {
|
||||||
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_tws_case, R.string.battery_case, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_tws_case, R.string.battery_case, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) {
|
if (supports(device, SonyHeadphonesCapabilities.BatteryDual) || supports(device, SonyHeadphonesCapabilities.BatteryDual2)) {
|
||||||
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_l, R.string.left_earbud, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_l, R.string.left_earbud, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
||||||
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_r, R.string.right_earbud, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_r, R.string.right_earbud, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
||||||
}
|
}
|
||||||
@ -116,31 +120,31 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
|||||||
public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
|
public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
|
||||||
final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
|
final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
|
||||||
|
|
||||||
if (supports(SonyHeadphonesCapabilities.AmbientSoundControl) || supports(SonyHeadphonesCapabilities.AmbientSoundControl2)) {
|
if (supports(device, SonyHeadphonesCapabilities.AmbientSoundControl) || supports(device, SonyHeadphonesCapabilities.AmbientSoundControl2)) {
|
||||||
if (supports(SonyHeadphonesCapabilities.WindNoiseReduction)) {
|
if (supports(device, SonyHeadphonesCapabilities.WindNoiseReduction)) {
|
||||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control_wind_noise_reduction);
|
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control_wind_noise_reduction);
|
||||||
} else if (supports(SonyHeadphonesCapabilities.NoNoiseCancelling)) {
|
} else if (supports(device, SonyHeadphonesCapabilities.NoNoiseCancelling)) {
|
||||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control_no_noise_cancelling);
|
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control_no_noise_cancelling);
|
||||||
} else {
|
} else {
|
||||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control);
|
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supports(SonyHeadphonesCapabilities.AncOptimizer)) {
|
if (supports(device, SonyHeadphonesCapabilities.AncOptimizer)) {
|
||||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_anc_optimizer);
|
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_anc_optimizer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supports(SonyHeadphonesCapabilities.AdaptiveVolumeControl)) {
|
if (supports(device, SonyHeadphonesCapabilities.AdaptiveVolumeControl)) {
|
||||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_adaptive_volume_control);
|
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_adaptive_volume_control);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supports(SonyHeadphonesCapabilities.SpeakToChatConfig)) {
|
if (supports(device, SonyHeadphonesCapabilities.SpeakToChatConfig)) {
|
||||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_speak_to_chat_with_settings);
|
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_speak_to_chat_with_settings);
|
||||||
} else if (supports(SonyHeadphonesCapabilities.SpeakToChatEnabled)) {
|
} else if (supports(device, SonyHeadphonesCapabilities.SpeakToChatEnabled)) {
|
||||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_speak_to_chat_simple);
|
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_speak_to_chat_simple);
|
||||||
}
|
}
|
||||||
|
|
||||||
addSettingsUnderHeader(deviceSpecificSettings, R.xml.devicesettings_header_other, new LinkedHashMap<SonyHeadphonesCapabilities, Integer>() {{
|
addSettingsUnderHeader(deviceSpecificSettings, device, R.xml.devicesettings_header_other, new LinkedHashMap<SonyHeadphonesCapabilities, Integer>() {{
|
||||||
put(SonyHeadphonesCapabilities.AudioSettingsOnlyOnSbcCodec, R.xml.devicesettings_sony_warning_wh1000xm3);
|
put(SonyHeadphonesCapabilities.AudioSettingsOnlyOnSbcCodec, R.xml.devicesettings_sony_warning_wh1000xm3);
|
||||||
put(SonyHeadphonesCapabilities.EqualizerSimple, R.xml.devicesettings_sony_headphones_equalizer);
|
put(SonyHeadphonesCapabilities.EqualizerSimple, R.xml.devicesettings_sony_headphones_equalizer);
|
||||||
put(SonyHeadphonesCapabilities.EqualizerWithCustomBands, R.xml.devicesettings_sony_headphones_equalizer_with_custom_bands);
|
put(SonyHeadphonesCapabilities.EqualizerWithCustomBands, R.xml.devicesettings_sony_headphones_equalizer_with_custom_bands);
|
||||||
@ -153,7 +157,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
|||||||
final List<Integer> callsAndNotif = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CALLS_AND_NOTIFICATIONS);
|
final List<Integer> callsAndNotif = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CALLS_AND_NOTIFICATIONS);
|
||||||
callsAndNotif.add(R.xml.devicesettings_headphones);
|
callsAndNotif.add(R.xml.devicesettings_headphones);
|
||||||
|
|
||||||
addSettingsUnderHeader(deviceSpecificSettings, R.xml.devicesettings_header_system, new LinkedHashMap<SonyHeadphonesCapabilities, Integer>() {{
|
addSettingsUnderHeader(deviceSpecificSettings, device, R.xml.devicesettings_header_system, new LinkedHashMap<SonyHeadphonesCapabilities, Integer>() {{
|
||||||
put(SonyHeadphonesCapabilities.WideAreaTap, R.xml.devicesettings_sony_headphones_wide_area_tap);
|
put(SonyHeadphonesCapabilities.WideAreaTap, R.xml.devicesettings_sony_headphones_wide_area_tap);
|
||||||
put(SonyHeadphonesCapabilities.ButtonModesLeftRight, R.xml.devicesettings_sony_headphones_button_modes_left_right);
|
put(SonyHeadphonesCapabilities.ButtonModesLeftRight, R.xml.devicesettings_sony_headphones_button_modes_left_right);
|
||||||
put(SonyHeadphonesCapabilities.AmbientSoundControlButtonMode, R.xml.devicesettings_sony_headphones_ambient_sound_control_button_modes);
|
put(SonyHeadphonesCapabilities.AmbientSoundControlButtonMode, R.xml.devicesettings_sony_headphones_ambient_sound_control_button_modes);
|
||||||
@ -165,20 +169,30 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
|||||||
put(SonyHeadphonesCapabilities.VoiceNotifications, R.xml.devicesettings_sony_headphones_notifications_voice_guide);
|
put(SonyHeadphonesCapabilities.VoiceNotifications, R.xml.devicesettings_sony_headphones_notifications_voice_guide);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_header_developer);
|
final List<Integer> developer = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DEVELOPER);
|
||||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_protocol_version);
|
developer.add(R.xml.devicesettings_override_features);
|
||||||
|
developer.add(R.xml.devicesettings_sony_headphones_protocol_version);
|
||||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_device_info);
|
developer.add(R.xml.devicesettings_sony_headphones_device_info);
|
||||||
|
|
||||||
return deviceSpecificSettings;
|
return deviceSpecificSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Collections.emptyList();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supports(final SonyHeadphonesCapabilities capability) {
|
public Set<SonyHeadphonesCapabilities> getCapabilities(final GBDevice device) {
|
||||||
return getCapabilities().contains(capability);
|
DevicePrefs devicePrefs = GBApplication.getDevicePrefs(device);
|
||||||
|
final boolean overrideFeatures = devicePrefs.getBoolean(DeviceSettingsPreferenceConst.PREF_OVERRIDE_FEATURES_ENABLED, false);
|
||||||
|
if (overrideFeatures) {
|
||||||
|
final Set<String> stringList = devicePrefs.getStringSet(DeviceSettingsPreferenceConst.PREF_OVERRIDE_FEATURES_LIST, Collections.emptySet());
|
||||||
|
return stringList.stream().map(SonyHeadphonesCapabilities::valueOf).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
return getCapabilities();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean supports(final GBDevice device, final SonyHeadphonesCapabilities capability) {
|
||||||
|
return getCapabilities(device).contains(capability);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,11 +203,12 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
|||||||
* @param capabilities the map of capability to preference screen
|
* @param capabilities the map of capability to preference screen
|
||||||
*/
|
*/
|
||||||
private void addSettingsUnderHeader(final DeviceSpecificSettings deviceSpecificSettings,
|
private void addSettingsUnderHeader(final DeviceSpecificSettings deviceSpecificSettings,
|
||||||
|
final GBDevice device,
|
||||||
final int header,
|
final int header,
|
||||||
final Map<SonyHeadphonesCapabilities, Integer> capabilities) {
|
final Map<SonyHeadphonesCapabilities, Integer> capabilities) {
|
||||||
final Set<SonyHeadphonesCapabilities> supportedCapabilities = new HashSet<>(capabilities.keySet());
|
final Set<SonyHeadphonesCapabilities> supportedCapabilities = new HashSet<>(capabilities.keySet());
|
||||||
for (SonyHeadphonesCapabilities capability : capabilities.keySet()) {
|
for (SonyHeadphonesCapabilities capability : capabilities.keySet()) {
|
||||||
if (!supports(capability)) {
|
if (!supports(device, capability)) {
|
||||||
supportedCapabilities.remove(capability);
|
supportedCapabilities.remove(capability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,7 +221,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
|||||||
deviceSpecificSettings.addRootScreen(header);
|
deviceSpecificSettings.addRootScreen(header);
|
||||||
|
|
||||||
for (Map.Entry<SonyHeadphonesCapabilities, Integer> capabilitiesSetting : capabilities.entrySet()) {
|
for (Map.Entry<SonyHeadphonesCapabilities, Integer> capabilitiesSetting : capabilities.entrySet()) {
|
||||||
if (supports(capabilitiesSetting.getKey())) {
|
if (supports(device, capabilitiesSetting.getKey())) {
|
||||||
deviceSpecificSettings.addRootScreen(capabilitiesSetting.getValue());
|
deviceSpecificSettings.addRootScreen(capabilitiesSetting.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones;
|
||||||
|
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_OVERRIDE_FEATURES_LIST;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AMBIENT_SOUND_CONTROL;
|
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AMBIENT_SOUND_CONTROL;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AMBIENT_SOUND_LEVEL;
|
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AMBIENT_SOUND_LEVEL;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_CODEC;
|
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_CODEC;
|
||||||
@ -40,8 +41,10 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.preference.EditTextPreference;
|
import androidx.preference.EditTextPreference;
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
|
import androidx.preference.MultiSelectListPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
@ -75,7 +78,7 @@ public class SonyHeadphonesSettingsCustomizer implements DeviceSpecificSettingsC
|
|||||||
// Disable equalizer, sound position and surround mode if not in SBC codec, for WH-1000XM3
|
// Disable equalizer, sound position and surround mode if not in SBC codec, for WH-1000XM3
|
||||||
// TODO: Should the coordinator be responsible for this compatibility check?
|
// TODO: Should the coordinator be responsible for this compatibility check?
|
||||||
if (preference.getKey().equals(PREF_SONY_AUDIO_CODEC) && device.getType().equals(DeviceType.SONY_WH_1000XM3)) {
|
if (preference.getKey().equals(PREF_SONY_AUDIO_CODEC) && device.getType().equals(DeviceType.SONY_WH_1000XM3)) {
|
||||||
final boolean isSbcCodec = ((EditTextPreference) preference).getText().equalsIgnoreCase("sbc");
|
final boolean isSbcCodec = "sbc".equalsIgnoreCase(((EditTextPreference) preference).getText());
|
||||||
|
|
||||||
final List<Preference> prefsToDisable = Arrays.asList(
|
final List<Preference> prefsToDisable = Arrays.asList(
|
||||||
handler.findPreference(PREF_SONY_EQUALIZER),
|
handler.findPreference(PREF_SONY_EQUALIZER),
|
||||||
@ -146,54 +149,81 @@ public class SonyHeadphonesSettingsCustomizer implements DeviceSpecificSettingsC
|
|||||||
final Preference ancOptimizer = handler.findPreference("pref_sony_anc_optimizer");
|
final Preference ancOptimizer = handler.findPreference("pref_sony_anc_optimizer");
|
||||||
|
|
||||||
if (ancOptimizer != null) {
|
if (ancOptimizer != null) {
|
||||||
ancOptimizer.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
ancOptimizer.setOnPreferenceClickListener(preference -> {
|
||||||
@Override
|
if (ancOptimizerProgressDialog != null) {
|
||||||
public boolean onPreferenceClick(final Preference preference) {
|
// Already optimizing
|
||||||
if (ancOptimizerProgressDialog != null) {
|
|
||||||
// Already optimizing
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Context context = preference.getContext();
|
|
||||||
|
|
||||||
new MaterialAlertDialogBuilder(context)
|
|
||||||
.setTitle(R.string.sony_anc_optimize_confirmation_title)
|
|
||||||
.setMessage(R.string.sony_anc_optimize_confirmation_description)
|
|
||||||
.setIcon(R.drawable.ic_hearing)
|
|
||||||
.setPositiveButton(R.string.start, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(final DialogInterface dialog, final int whichButton) {
|
|
||||||
handler.notifyPreferenceChanged(PREF_SONY_NOISE_OPTIMIZER_START);
|
|
||||||
|
|
||||||
ancOptimizerProgressDialog = new ProgressDialog(context);
|
|
||||||
ancOptimizerProgressDialog.setCancelable(false);
|
|
||||||
ancOptimizerProgressDialog.setMessage(context.getString(R.string.sony_anc_optimizer_status_starting));
|
|
||||||
ancOptimizerProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
|
||||||
ancOptimizerProgressDialog.setProgress(0);
|
|
||||||
ancOptimizerProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.Cancel), new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final DialogInterface dialog, final int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
ancOptimizerProgressDialog = null;
|
|
||||||
handler.notifyPreferenceChanged(PREF_SONY_NOISE_OPTIMIZER_CANCEL);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ancOptimizerProgressDialog.show();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.show();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Context context = preference.getContext();
|
||||||
|
|
||||||
|
new MaterialAlertDialogBuilder(context)
|
||||||
|
.setTitle(R.string.sony_anc_optimize_confirmation_title)
|
||||||
|
.setMessage(R.string.sony_anc_optimize_confirmation_description)
|
||||||
|
.setIcon(R.drawable.ic_hearing)
|
||||||
|
.setPositiveButton(R.string.start, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(final DialogInterface dialog, final int whichButton) {
|
||||||
|
handler.notifyPreferenceChanged(PREF_SONY_NOISE_OPTIMIZER_START);
|
||||||
|
|
||||||
|
ancOptimizerProgressDialog = new ProgressDialog(context);
|
||||||
|
ancOptimizerProgressDialog.setCancelable(false);
|
||||||
|
ancOptimizerProgressDialog.setMessage(context.getString(R.string.sony_anc_optimizer_status_starting));
|
||||||
|
ancOptimizerProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||||
|
ancOptimizerProgressDialog.setProgress(0);
|
||||||
|
ancOptimizerProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.Cancel), (dialog1, which) -> {
|
||||||
|
dialog1.dismiss();
|
||||||
|
ancOptimizerProgressDialog = null;
|
||||||
|
handler.notifyPreferenceChanged(PREF_SONY_NOISE_OPTIMIZER_CANCEL);
|
||||||
|
});
|
||||||
|
|
||||||
|
ancOptimizerProgressDialog.show();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.show();
|
||||||
|
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide unsupported preferences
|
// Hide unsupported preferences
|
||||||
final Preference speakToChatFocusVoice = handler.findPreference(PREF_SONY_SPEAK_TO_CHAT_FOCUS_ON_VOICE);
|
final Preference speakToChatFocusVoice = handler.findPreference(PREF_SONY_SPEAK_TO_CHAT_FOCUS_ON_VOICE);
|
||||||
if (speakToChatFocusVoice != null && !coordinator.supports(SonyHeadphonesCapabilities.SpeakToChatFocusOnVoice)) {
|
if (speakToChatFocusVoice != null && !coordinator.supports(device, SonyHeadphonesCapabilities.SpeakToChatFocusOnVoice)) {
|
||||||
speakToChatFocusVoice.setVisible(false);
|
speakToChatFocusVoice.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override features
|
||||||
|
final MultiSelectListPreference overrideFeaturesList = handler.findPreference(PREF_OVERRIDE_FEATURES_LIST);
|
||||||
|
if (overrideFeaturesList != null) {
|
||||||
|
final Set<SonyHeadphonesCapabilities> defaultCapabilities = coordinator.getCapabilities();
|
||||||
|
|
||||||
|
// Populate the preference directly from the enum
|
||||||
|
final CharSequence[] entries = new CharSequence[SonyHeadphonesCapabilities.values().length];
|
||||||
|
final CharSequence[] values = new CharSequence[SonyHeadphonesCapabilities.values().length];
|
||||||
|
int i = 0;
|
||||||
|
for (SonyHeadphonesCapabilities capability : SonyHeadphonesCapabilities.values()) {
|
||||||
|
// Defaults first
|
||||||
|
if (defaultCapabilities.contains(capability)) {
|
||||||
|
entries[i] = "*" + capability.name();
|
||||||
|
values[i] = capability.name();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (SonyHeadphonesCapabilities capability : SonyHeadphonesCapabilities.values()) {
|
||||||
|
if (!defaultCapabilities.contains(capability)) {
|
||||||
|
entries[i] = capability.name();
|
||||||
|
values[i] = capability.name();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
overrideFeaturesList.setEntries(entries);
|
||||||
|
overrideFeaturesList.setEntryValues(values);
|
||||||
|
|
||||||
|
overrideFeaturesList.setOnPreferenceClickListener(preference -> {
|
||||||
|
device.sendDeviceUpdateIntent(handler.getContext());
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -32,8 +33,8 @@ public class SonyLinkBudsCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatteryDual,
|
SonyHeadphonesCapabilities.BatteryDual,
|
||||||
SonyHeadphonesCapabilities.BatteryCase,
|
SonyHeadphonesCapabilities.BatteryCase,
|
||||||
SonyHeadphonesCapabilities.SpeakToChatEnabled,
|
SonyHeadphonesCapabilities.SpeakToChatEnabled,
|
||||||
@ -48,7 +49,7 @@ public class SonyLinkBudsCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.VoiceNotifications
|
SonyHeadphonesCapabilities.VoiceNotifications
|
||||||
// TODO spacial sound optimization
|
// TODO spacial sound optimization
|
||||||
// TODO factory reset
|
// TODO factory reset
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -31,8 +32,8 @@ public class SonyLinkBudsSCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatteryDual,
|
SonyHeadphonesCapabilities.BatteryDual,
|
||||||
SonyHeadphonesCapabilities.BatteryCase,
|
SonyHeadphonesCapabilities.BatteryCase,
|
||||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||||
@ -47,7 +48,7 @@ public class SonyLinkBudsSCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.SpeakToChatConfig,
|
SonyHeadphonesCapabilities.SpeakToChatConfig,
|
||||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||||
SonyHeadphonesCapabilities.EqualizerWithCustomBands
|
SonyHeadphonesCapabilities.EqualizerWithCustomBands
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,19 +16,16 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
|
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
|
||||||
|
|
||||||
public class SonyWF1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
public class SonyWF1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
||||||
@Override
|
@Override
|
||||||
@ -46,8 +43,8 @@ public class SonyWF1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatteryDual,
|
SonyHeadphonesCapabilities.BatteryDual,
|
||||||
SonyHeadphonesCapabilities.BatteryCase,
|
SonyHeadphonesCapabilities.BatteryCase,
|
||||||
SonyHeadphonesCapabilities.PowerOffFromPhone,
|
SonyHeadphonesCapabilities.PowerOffFromPhone,
|
||||||
@ -59,7 +56,7 @@ public class SonyWF1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
||||||
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff,
|
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff,
|
||||||
SonyHeadphonesCapabilities.VoiceNotifications
|
SonyHeadphonesCapabilities.VoiceNotifications
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -42,8 +43,8 @@ public class SonyWF1000XM4Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatteryDual,
|
SonyHeadphonesCapabilities.BatteryDual,
|
||||||
SonyHeadphonesCapabilities.BatteryCase,
|
SonyHeadphonesCapabilities.BatteryCase,
|
||||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||||
@ -53,7 +54,7 @@ public class SonyWF1000XM4Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.ButtonModesLeftRight,
|
SonyHeadphonesCapabilities.ButtonModesLeftRight,
|
||||||
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
||||||
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff
|
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,19 +16,16 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
|
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
|
||||||
|
|
||||||
public class SonyWF1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
public class SonyWF1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
||||||
@Override
|
@Override
|
||||||
@ -46,8 +43,8 @@ public class SonyWF1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatteryDual,
|
SonyHeadphonesCapabilities.BatteryDual,
|
||||||
SonyHeadphonesCapabilities.BatteryCase,
|
SonyHeadphonesCapabilities.BatteryCase,
|
||||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||||
@ -57,7 +54,7 @@ public class SonyWF1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.ButtonModesLeftRight,
|
SonyHeadphonesCapabilities.ButtonModesLeftRight,
|
||||||
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
||||||
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff
|
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -31,15 +32,15 @@ public class SonyWFC500Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatteryDual2,
|
SonyHeadphonesCapabilities.BatteryDual2,
|
||||||
SonyHeadphonesCapabilities.EqualizerSimple,
|
SonyHeadphonesCapabilities.EqualizerSimple,
|
||||||
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
||||||
SonyHeadphonesCapabilities.AudioUpsampling,
|
SonyHeadphonesCapabilities.AudioUpsampling,
|
||||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||||
SonyHeadphonesCapabilities.PowerOffFromPhone
|
SonyHeadphonesCapabilities.PowerOffFromPhone
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -32,8 +33,8 @@ public class SonyWFC510Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatteryDual2,
|
SonyHeadphonesCapabilities.BatteryDual2,
|
||||||
SonyHeadphonesCapabilities.BatteryCase,
|
SonyHeadphonesCapabilities.BatteryCase,
|
||||||
SonyHeadphonesCapabilities.AmbientSoundControl2,
|
SonyHeadphonesCapabilities.AmbientSoundControl2,
|
||||||
@ -43,7 +44,7 @@ public class SonyWFC510Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.AudioUpsampling,
|
SonyHeadphonesCapabilities.AudioUpsampling,
|
||||||
SonyHeadphonesCapabilities.ButtonModesLeftRight,
|
SonyHeadphonesCapabilities.ButtonModesLeftRight,
|
||||||
SonyHeadphonesCapabilities.PowerOffFromPhone
|
SonyHeadphonesCapabilities.PowerOffFromPhone
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -32,8 +33,8 @@ public class SonyWFC700NCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatteryDual2,
|
SonyHeadphonesCapabilities.BatteryDual2,
|
||||||
SonyHeadphonesCapabilities.BatteryCase,
|
SonyHeadphonesCapabilities.BatteryCase,
|
||||||
SonyHeadphonesCapabilities.AmbientSoundControl2,
|
SonyHeadphonesCapabilities.AmbientSoundControl2,
|
||||||
@ -46,7 +47,7 @@ public class SonyWFC700NCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
// AutoOff is supported, but current Payload is incorrect.
|
// AutoOff is supported, but current Payload is incorrect.
|
||||||
// Available options in Sony App: 15min, 30min, 1h, 3h, off
|
// Available options in Sony App: 15min, 30min, 1h, 3h, off
|
||||||
// TODO: SonyHeadphonesCapabilities.AutomaticPowerOffByTime
|
// TODO: SonyHeadphonesCapabilities.AutomaticPowerOffByTime
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,10 +16,9 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -44,8 +43,8 @@ public class SonyWFSP800NCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatteryDual,
|
SonyHeadphonesCapabilities.BatteryDual,
|
||||||
SonyHeadphonesCapabilities.BatteryCase,
|
SonyHeadphonesCapabilities.BatteryCase,
|
||||||
SonyHeadphonesCapabilities.PowerOffFromPhone,
|
SonyHeadphonesCapabilities.PowerOffFromPhone,
|
||||||
@ -56,7 +55,7 @@ public class SonyWFSP800NCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff,
|
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff,
|
||||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||||
SonyHeadphonesCapabilities.Volume
|
SonyHeadphonesCapabilities.Volume
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,17 +16,14 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
|
||||||
|
|
||||||
public class SonyWH1000XM2Coordinator extends SonyHeadphonesCoordinator {
|
public class SonyWH1000XM2Coordinator extends SonyHeadphonesCoordinator {
|
||||||
@Override
|
@Override
|
||||||
@ -40,8 +37,8 @@ public class SonyWH1000XM2Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatterySingle,
|
SonyHeadphonesCapabilities.BatterySingle,
|
||||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||||
SonyHeadphonesCapabilities.WindNoiseReduction,
|
SonyHeadphonesCapabilities.WindNoiseReduction,
|
||||||
@ -51,6 +48,6 @@ public class SonyWH1000XM2Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.SoundPosition,
|
SonyHeadphonesCapabilities.SoundPosition,
|
||||||
SonyHeadphonesCapabilities.SurroundMode,
|
SonyHeadphonesCapabilities.SurroundMode,
|
||||||
SonyHeadphonesCapabilities.AudioUpsampling
|
SonyHeadphonesCapabilities.AudioUpsampling
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,17 +16,14 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
|
||||||
|
|
||||||
public class SonyWH1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
public class SonyWH1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
||||||
@Override
|
@Override
|
||||||
@ -39,8 +36,8 @@ public class SonyWH1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatterySingle,
|
SonyHeadphonesCapabilities.BatterySingle,
|
||||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||||
SonyHeadphonesCapabilities.WindNoiseReduction,
|
SonyHeadphonesCapabilities.WindNoiseReduction,
|
||||||
@ -54,6 +51,6 @@ public class SonyWH1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.AutomaticPowerOffByTime,
|
SonyHeadphonesCapabilities.AutomaticPowerOffByTime,
|
||||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||||
SonyHeadphonesCapabilities.Volume
|
SonyHeadphonesCapabilities.Volume
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -36,8 +37,8 @@ public class SonyWH1000XM4Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
// TODO: Function of [CUSTOM] button
|
// TODO: Function of [CUSTOM] button
|
||||||
// TODO R.xml.devicesettings_connect_two_devices,
|
// TODO R.xml.devicesettings_connect_two_devices,
|
||||||
SonyHeadphonesCapabilities.BatterySingle,
|
SonyHeadphonesCapabilities.BatterySingle,
|
||||||
@ -53,6 +54,6 @@ public class SonyWH1000XM4Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
||||||
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff,
|
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff,
|
||||||
SonyHeadphonesCapabilities.VoiceNotifications
|
SonyHeadphonesCapabilities.VoiceNotifications
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -36,8 +37,8 @@ public class SonyWH1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
// TODO R.xml.devicesettings_connect_two_devices,
|
// TODO R.xml.devicesettings_connect_two_devices,
|
||||||
// TODO automatic ANC depending on state (might need phone?)
|
// TODO automatic ANC depending on state (might need phone?)
|
||||||
SonyHeadphonesCapabilities.BatterySingle,
|
SonyHeadphonesCapabilities.BatterySingle,
|
||||||
@ -54,6 +55,6 @@ public class SonyWH1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
||||||
SonyHeadphonesCapabilities.QuickAccess,
|
SonyHeadphonesCapabilities.QuickAccess,
|
||||||
SonyHeadphonesCapabilities.PauseWhenTakenOff
|
SonyHeadphonesCapabilities.PauseWhenTakenOff
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -31,15 +32,15 @@ public class SonyWIC100Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatterySingle,
|
SonyHeadphonesCapabilities.BatterySingle,
|
||||||
SonyHeadphonesCapabilities.EqualizerSimple,
|
SonyHeadphonesCapabilities.EqualizerSimple,
|
||||||
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
||||||
SonyHeadphonesCapabilities.AudioUpsampling,
|
SonyHeadphonesCapabilities.AudioUpsampling,
|
||||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||||
SonyHeadphonesCapabilities.PowerOffFromPhone
|
SonyHeadphonesCapabilities.PowerOffFromPhone
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,17 +16,14 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
|
||||||
|
|
||||||
public class SonyWISP600NCoordinator extends SonyHeadphonesCoordinator {
|
public class SonyWISP600NCoordinator extends SonyHeadphonesCoordinator {
|
||||||
@Override
|
@Override
|
||||||
@ -39,8 +36,8 @@ public class SonyWISP600NCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
SonyHeadphonesCapabilities.BatterySingle,
|
SonyHeadphonesCapabilities.BatterySingle,
|
||||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||||
SonyHeadphonesCapabilities.WindNoiseReduction,
|
SonyHeadphonesCapabilities.WindNoiseReduction,
|
||||||
@ -51,6 +48,6 @@ public class SonyWISP600NCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.AutomaticPowerOffByTime,
|
SonyHeadphonesCapabilities.AutomaticPowerOffByTime,
|
||||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||||
SonyHeadphonesCapabilities.Volume
|
SonyHeadphonesCapabilities.Volume
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class SoundcoreLiberty3ProCoordinator extends AbstractDeviceCoordinator {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class SoundcoreLiberty4NCCoordinator extends AbstractDeviceCoordinator {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,12 +54,12 @@ public class SoundcoreMotion300Coordinator extends AbstractBLClassicDeviceCoordi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsPowerOff() {
|
public boolean supportsPowerOff(final GBDevice device) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class SuperCarsCoordinator extends AbstractDeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,19 +552,19 @@ public class TestDeviceCoordinator extends AbstractDeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return supports(getTestDevice(), TestFeature.BATTERIES_MULTIPLE) ? 3 : 1;
|
return supports(getTestDevice(), TestFeature.BATTERIES_MULTIPLE) ? 3 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
|
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
|
||||||
if (getBatteryCount() == 1) {
|
if (getBatteryCount(device) == 1) {
|
||||||
return super.getBatteryConfig(device);
|
return super.getBatteryConfig(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
final BatteryConfig[] ret = new BatteryConfig[getBatteryCount()];
|
final BatteryConfig[] ret = new BatteryConfig[getBatteryCount(device)];
|
||||||
|
|
||||||
for (int i = 0; i < getBatteryCount(); i++) {
|
for (int i = 0; i < getBatteryCount(device); i++) {
|
||||||
ret[i] = new BatteryConfig(i, R.drawable.ic_battery_full, R.string.battery);
|
ret[i] = new BatteryConfig(i, R.drawable.ic_battery_full, R.string.battery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,7 +572,7 @@ public class TestDeviceCoordinator extends AbstractDeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsPowerOff() {
|
public boolean supportsPowerOff(final GBDevice device) {
|
||||||
return supports(getTestDevice(), TestFeature.POWER_OFF);
|
return supports(getTestDevice(), TestFeature.POWER_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public class UM25Coordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public abstract class AbstractRedmiBudsCoordinator extends AbstractDeviceCoordin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryCount() {
|
public int getBatteryCount(final GBDevice device) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.pro
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
||||||
@ -142,4 +143,8 @@ public abstract class AbstractSonyProtocolImpl {
|
|||||||
public abstract Request setVolume(final int volume);
|
public abstract Request setVolume(final int volume);
|
||||||
|
|
||||||
public abstract List<? extends GBDeviceEvent> handlePayload(final MessageType messageType, final byte[] payload);
|
public abstract List<? extends GBDeviceEvent> handlePayload(final MessageType messageType, final byte[] payload);
|
||||||
|
|
||||||
|
protected boolean supports(final SonyHeadphonesCapabilities capability) {
|
||||||
|
return getCoordinator().supports(device, capability);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDevi
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
||||||
@ -627,8 +626,6 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<? extends GBDeviceEvent> handleInitResponse(final byte[] payload) {
|
public List<? extends GBDeviceEvent> handleInitResponse(final byte[] payload) {
|
||||||
final SonyHeadphonesCoordinator coordinator = getCoordinator();
|
|
||||||
|
|
||||||
// Populate the init requests
|
// Populate the init requests
|
||||||
final List<Request> capabilityRequests = new ArrayList<>();
|
final List<Request> capabilityRequests = new ArrayList<>();
|
||||||
|
|
||||||
@ -664,7 +661,7 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
for (Map.Entry<SonyHeadphonesCapabilities, Request> capabilityEntry : capabilityRequestMap.entrySet()) {
|
for (Map.Entry<SonyHeadphonesCapabilities, Request> capabilityEntry : capabilityRequestMap.entrySet()) {
|
||||||
if (coordinator.supports(capabilityEntry.getKey())) {
|
if (supports(capabilityEntry.getKey())) {
|
||||||
capabilityRequests.add(capabilityEntry.getValue());
|
capabilityRequests.add(capabilityEntry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -945,7 +942,7 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
|
|||||||
// Dual Battery (L / R)
|
// Dual Battery (L / R)
|
||||||
LOG.debug("Battery Level: {}: L: {}, R: {}", batteryType, payload[2], payload[4]);
|
LOG.debug("Battery Level: {}: L: {}, R: {}", batteryType, payload[2], payload[4]);
|
||||||
|
|
||||||
boolean hasCaseBattery = getCoordinator().supports(SonyHeadphonesCapabilities.BatteryCase);
|
boolean hasCaseBattery = supports(SonyHeadphonesCapabilities.BatteryCase);
|
||||||
|
|
||||||
if (payload[2] != 0) {
|
if (payload[2] != 0) {
|
||||||
final GBDeviceEventBatteryInfo gbDeviceEventBatteryInfoLeft = new GBDeviceEventBatteryInfo();
|
final GBDeviceEventBatteryInfo gbDeviceEventBatteryInfoLeft = new GBDeviceEventBatteryInfo();
|
||||||
@ -1277,9 +1274,7 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean supportsWindNoiseCancelling() {
|
protected boolean supportsWindNoiseCancelling() {
|
||||||
final SonyHeadphonesCoordinator coordinator = getCoordinator();
|
return supports(SonyHeadphonesCapabilities.WindNoiseReduction);
|
||||||
|
|
||||||
return coordinator.supports(SonyHeadphonesCapabilities.WindNoiseReduction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BatteryType decodeBatteryType(final byte b) {
|
protected BatteryType decodeBatteryType(final byte b) {
|
||||||
|
@ -69,7 +69,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
|
|||||||
PayloadTypeV1.AMBIENT_SOUND_CONTROL_GET.getMessageType(),
|
PayloadTypeV1.AMBIENT_SOUND_CONTROL_GET.getMessageType(),
|
||||||
new byte[]{
|
new byte[]{
|
||||||
PayloadTypeV1.AMBIENT_SOUND_CONTROL_GET.getCode(),
|
PayloadTypeV1.AMBIENT_SOUND_CONTROL_GET.getCode(),
|
||||||
(byte) (supportsWindNoiseCancelling() || getCoordinator().supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x17 : 0x15)
|
(byte) (supportsWindNoiseCancelling() || supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x17 : 0x15)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
|
|||||||
final ByteBuffer buf = ByteBuffer.allocate(supportsWindNoiseCancelling() ? 8 : 7);
|
final ByteBuffer buf = ByteBuffer.allocate(supportsWindNoiseCancelling() ? 8 : 7);
|
||||||
|
|
||||||
buf.put(PayloadTypeV1.AMBIENT_SOUND_CONTROL_SET.getCode());
|
buf.put(PayloadTypeV1.AMBIENT_SOUND_CONTROL_SET.getCode());
|
||||||
buf.put((byte) (supportsWindNoiseCancelling() || getCoordinator().supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x17 : 0x15));
|
buf.put((byte) (supportsWindNoiseCancelling() || supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x17 : 0x15));
|
||||||
buf.put((byte) 0x01); // 0x00 while dragging the slider?
|
buf.put((byte) 0x01); // 0x00 while dragging the slider?
|
||||||
|
|
||||||
if (AmbientSoundControl.Mode.OFF.equals(ambientSoundControl.getMode())) {
|
if (AmbientSoundControl.Mode.OFF.equals(ambientSoundControl.getMode())) {
|
||||||
@ -352,7 +352,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
|
|||||||
PayloadTypeV2.AMBIENT_SOUND_CONTROL_BUTTON_MODE_SET.getCode(),
|
PayloadTypeV2.AMBIENT_SOUND_CONTROL_BUTTON_MODE_SET.getCode(),
|
||||||
(byte) 0x03,
|
(byte) 0x03,
|
||||||
(byte) 0x01,
|
(byte) 0x01,
|
||||||
(byte) (getCoordinator().supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x00 : 0x35),
|
(byte) (supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x00 : 0x35),
|
||||||
(byte) 0x01,
|
(byte) 0x01,
|
||||||
(byte) 0x00,
|
(byte) 0x00,
|
||||||
ambientSoundControlButtonMode.getCode()
|
ambientSoundControlButtonMode.getCode()
|
||||||
@ -1081,7 +1081,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
|
|||||||
case OFF:
|
case OFF:
|
||||||
return (byte) 0xff;
|
return (byte) 0xff;
|
||||||
case AMBIENT_SOUND_CONTROL:
|
case AMBIENT_SOUND_CONTROL:
|
||||||
return (byte) (supportsWindNoiseCancelling() || getCoordinator().supports(SonyHeadphonesCapabilities.NoNoiseCancelling) ? 0x35 : 0x00); // Seems to be the only one that differs?
|
return (byte) (supportsWindNoiseCancelling() || supports(SonyHeadphonesCapabilities.NoNoiseCancelling) ? 0x35 : 0x00); // Seems to be the only one that differs?
|
||||||
case PLAYBACK_CONTROL:
|
case PLAYBACK_CONTROL:
|
||||||
return (byte) 0x20;
|
return (byte) 0x20;
|
||||||
case VOLUME_CONTROL:
|
case VOLUME_CONTROL:
|
||||||
|
@ -3277,6 +3277,8 @@
|
|||||||
<string name="pref_force_connection_type_bt_classic_value" translatable="false">BT_CLASSIC</string>
|
<string name="pref_force_connection_type_bt_classic_value" translatable="false">BT_CLASSIC</string>
|
||||||
<string name="activity_info">Activity info</string>
|
<string name="activity_info">Activity info</string>
|
||||||
<string name="warning_missing_notification_permission">Could not post ongoing notification due to missing permission</string>
|
<string name="warning_missing_notification_permission">Could not post ongoing notification due to missing permission</string>
|
||||||
|
<string name="pref_override_features_title">Override supported features</string>
|
||||||
|
<string name="pref_override_features_summary">Enable/disable specific device features. This can cause issues and/or make your device work incorrectly</string>
|
||||||
<string name="pref_test_features_title">Features</string>
|
<string name="pref_test_features_title">Features</string>
|
||||||
<string name="pref_test_features_summary">Enabled features for this test device</string>
|
<string name="pref_test_features_summary">Enabled features for this test device</string>
|
||||||
<string name="pref_developer_add_test_activities_title">Add test activities</string>
|
<string name="pref_developer_add_test_activities_title">Add test activities</string>
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="pref_header_intent_api"
|
||||||
|
android:title="@string/pref_header_intent_api" />
|
||||||
|
</androidx.preference.PreferenceScreen>
|
20
app/src/main/res/xml/devicesettings_override_features.xml
Normal file
20
app/src/main/res/xml/devicesettings_override_features.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:icon="@drawable/ic_developer_mode"
|
||||||
|
android:key="override_features_enabled"
|
||||||
|
android:summary="@string/pref_override_features_summary"
|
||||||
|
android:title="@string/pref_override_features_title" />
|
||||||
|
|
||||||
|
<!-- the values should be populated by the DeviceSpecificSettingsCustomizer -->
|
||||||
|
<MultiSelectListPreference
|
||||||
|
android:defaultValue="@array/empty_array"
|
||||||
|
android:dependency="override_features_enabled"
|
||||||
|
android:entries="@array/empty_array"
|
||||||
|
android:entryValues="@array/empty_array"
|
||||||
|
android:icon="@drawable/ic_developer_mode"
|
||||||
|
android:key="override_features_list"
|
||||||
|
android:summary="@string/pref_test_features_summary"
|
||||||
|
android:title="@string/pref_test_features_title" />
|
||||||
|
</androidx.preference.PreferenceScreen>
|
@ -16,10 +16,8 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||||
@ -30,9 +28,8 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
|||||||
public class MockSonyCoordinator extends SonyHeadphonesCoordinator {
|
public class MockSonyCoordinator extends SonyHeadphonesCoordinator {
|
||||||
private final DeviceType deviceType = DeviceType.SONY_WH_1000XM3;
|
private final DeviceType deviceType = DeviceType.SONY_WH_1000XM3;
|
||||||
|
|
||||||
private final List<SonyHeadphonesCapabilities> capabilities = new ArrayList<>();
|
private final Set<SonyHeadphonesCapabilities> capabilities = new LinkedHashSet<>();
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supports(final GBDeviceCandidate candidate) {
|
public boolean supports(final GBDeviceCandidate candidate) {
|
||||||
return true;
|
return true;
|
||||||
@ -47,7 +44,7 @@ public class MockSonyCoordinator extends SonyHeadphonesCoordinator {
|
|||||||
capabilities.add(capability);
|
capabilities.add(capability);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||||
return capabilities;
|
return capabilities;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user