mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 02:25:50 +01:00
Sony WH-1000XM3: Disable equalizer, surround and sound position while in SBC codec
This commit is contained in:
parent
1de2c32705
commit
83c42ebef8
@ -123,6 +123,7 @@ public class DeviceSettingsPreferenceConst {
|
||||
public static final String PREF_SONY_AMBIENT_SOUND_LEVEL = "pref_sony_ambient_sound_level";
|
||||
public static final String PREF_SONY_SOUND_POSITION = "pref_sony_sound_position";
|
||||
public static final String PREF_SONY_SURROUND_MODE = "pref_sony_surround_mode";
|
||||
public static final String PREF_SONY_EQUALIZER = "pref_sony_equalizer";
|
||||
public static final String PREF_SONY_EQUALIZER_MODE = "pref_sony_equalizer_mode";
|
||||
public static final String PREF_SONY_AUDIO_UPSAMPLING = "pref_sony_audio_upsampling";
|
||||
public static final String PREF_SONY_EQUALIZER_BAND_400 = "pref_sony_equalizer_band_400";
|
||||
|
@ -18,11 +18,21 @@ package nodomain.freeyourgadget.gadgetbridge.activities.devicesettings;
|
||||
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
/**
|
||||
* A device-specific preference handler, that allows for concrete implementations to customize the preferences in
|
||||
* the {@link DeviceSpecificSettingsFragment}.
|
||||
*/
|
||||
public interface DeviceSpecificSettingsCustomizer extends Parcelable {
|
||||
/**
|
||||
* Called when a {@link Preference} changes, not caused by user input (so the preference change listener is not called).
|
||||
*
|
||||
* @param preference the {@link Preference} preference that changed
|
||||
* @param handler the {@link DeviceSpecificSettingsHandler}
|
||||
*/
|
||||
void onPreferenceChange(final Preference preference, final DeviceSpecificSettingsHandler handler);
|
||||
|
||||
/**
|
||||
* Customize the settings on the {@link DeviceSpecificSettingsFragment}.
|
||||
*
|
||||
|
@ -869,7 +869,7 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
|
||||
|
||||
final Preference preference = findPreference(key);
|
||||
if (preference == null) {
|
||||
LOG.warn("Preference {} not found, ignoring", key);
|
||||
LOG.warn("Preference {} not found", key);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -883,11 +883,18 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp
|
||||
} else if (preference instanceof ListPreference) {
|
||||
final ListPreference listPreference = (ListPreference) preference;
|
||||
listPreference.setValue(prefs.getString(key, listPreference.getValue()));
|
||||
} else if (preference instanceof EditTextPreference) {
|
||||
final EditTextPreference editTextPreference = (EditTextPreference) preference;
|
||||
editTextPreference.setText(prefs.getString(key, editTextPreference.getText()));
|
||||
} else if (preference instanceof PreferenceScreen) {
|
||||
// Ignoring
|
||||
} else {
|
||||
LOG.warn("Unknown preference class {}, ignoring", preference.getClass());
|
||||
}
|
||||
|
||||
if (deviceSpecificSettingsCustomizer != null) {
|
||||
deviceSpecificSettingsCustomizer.onPreferenceChange(preference, DeviceSpecificSettingsFragment.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractDeviceCoordinato
|
||||
|
||||
@Override
|
||||
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) {
|
||||
return new SonyHeadphonesSettingsCustomizer();
|
||||
return new SonyHeadphonesSettingsCustomizer(device);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,20 +18,70 @@ package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones;
|
||||
|
||||
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_AUDIO_CODEC;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BAND_1000;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BAND_16000;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BAND_2500;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BAND_400;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BAND_6300;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BASS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_MODE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_FOCUS_VOICE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_SOUND_POSITION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_SURROUND_MODE;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.preference.EditTextPreference;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
|
||||
public class SonyHeadphonesSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
|
||||
final GBDevice device;
|
||||
|
||||
public SonyHeadphonesSettingsCustomizer(final GBDevice device) {
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreferenceChange(final Preference preference, final DeviceSpecificSettingsHandler handler) {
|
||||
// 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?
|
||||
if (preference.getKey().equals(PREF_SONY_AUDIO_CODEC) && device.getType().equals(DeviceType.SONY_WH_1000XM3)) {
|
||||
final boolean isSbcCodec = ((EditTextPreference) preference).getText().equalsIgnoreCase("sbc");
|
||||
|
||||
final List<Preference> prefsToDisable = Arrays.asList(
|
||||
handler.findPreference(PREF_SONY_EQUALIZER),
|
||||
handler.findPreference(PREF_SONY_EQUALIZER_MODE),
|
||||
handler.findPreference(PREF_SONY_EQUALIZER_BAND_400),
|
||||
handler.findPreference(PREF_SONY_EQUALIZER_BAND_1000),
|
||||
handler.findPreference(PREF_SONY_EQUALIZER_BAND_2500),
|
||||
handler.findPreference(PREF_SONY_EQUALIZER_BAND_6300),
|
||||
handler.findPreference(PREF_SONY_EQUALIZER_BAND_16000),
|
||||
handler.findPreference(PREF_SONY_EQUALIZER_BASS),
|
||||
handler.findPreference(PREF_SONY_SOUND_POSITION),
|
||||
handler.findPreference(PREF_SONY_SURROUND_MODE)
|
||||
);
|
||||
|
||||
for (Preference pref : prefsToDisable) {
|
||||
if (pref != null) {
|
||||
pref.setEnabled(isSbcCodec);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customizeSettings(final DeviceSpecificSettingsHandler handler) {
|
||||
// Only enable the focus on voice check and voice level slider if the ambient sound control mode is ambient sound
|
||||
@ -59,7 +109,8 @@ public class SonyHeadphonesSettingsCustomizer implements DeviceSpecificSettingsC
|
||||
public static final Creator<SonyHeadphonesSettingsCustomizer> CREATOR = new Creator<SonyHeadphonesSettingsCustomizer>() {
|
||||
@Override
|
||||
public SonyHeadphonesSettingsCustomizer createFromParcel(final Parcel in) {
|
||||
return new SonyHeadphonesSettingsCustomizer();
|
||||
final GBDevice device = in.readParcelable(SonyHeadphonesSettingsCustomizer.class.getClassLoader());
|
||||
return new SonyHeadphonesSettingsCustomizer(device);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -75,6 +126,6 @@ public class SonyHeadphonesSettingsCustomizer implements DeviceSpecificSettingsC
|
||||
|
||||
@Override
|
||||
public void writeToParcel(final Parcel dest, final int flags) {
|
||||
// Nothing to do
|
||||
dest.writeParcelable(device, 0);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,8 @@ public class SonyWFSP800NCoordinator extends SonyHeadphonesCoordinator {
|
||||
R.xml.devicesettings_sony_headphones_button_modes_left_right,
|
||||
R.xml.devicesettings_sony_headphones_pause_when_taken_off,
|
||||
R.xml.devicesettings_automatic_power_off_when_taken_off,
|
||||
R.xml.devicesettings_sony_headphones_notifications_voice_guide
|
||||
R.xml.devicesettings_sony_headphones_notifications_voice_guide,
|
||||
R.xml.devicesettings_sony_headphones_device_info
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ public class SonyWH1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
||||
@Override
|
||||
public int[] getSupportedDeviceSpecificSettings(final GBDevice device) {
|
||||
return new int[]{
|
||||
R.xml.devicesettings_sony_warning_wh1000xm3,
|
||||
R.xml.devicesettings_sony_headphones_ambient_sound_control_wind_noise_reduction,
|
||||
R.xml.devicesettings_header_other,
|
||||
R.xml.devicesettings_sony_warning_wh1000xm3,
|
||||
R.xml.devicesettings_sony_headphones_equalizer,
|
||||
R.xml.devicesettings_sony_headphones_sound_position,
|
||||
R.xml.devicesettings_sony_headphones_surround_mode,
|
||||
@ -53,7 +53,8 @@ public class SonyWH1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
||||
R.xml.devicesettings_header_system,
|
||||
R.xml.devicesettings_sony_headphones_touch_sensor_single,
|
||||
R.xml.devicesettings_automatic_power_off_by_time,
|
||||
R.xml.devicesettings_sony_headphones_notifications_voice_guide
|
||||
R.xml.devicesettings_sony_headphones_notifications_voice_guide,
|
||||
R.xml.devicesettings_sony_headphones_device_info
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,8 @@ public class SonyWH1000XM4Coordinator extends SonyHeadphonesCoordinator {
|
||||
R.xml.devicesettings_sony_headphones_touch_sensor_single,
|
||||
R.xml.devicesettings_sony_headphones_pause_when_taken_off,
|
||||
R.xml.devicesettings_automatic_power_off_when_taken_off,
|
||||
R.xml.devicesettings_sony_headphones_notifications_voice_guide
|
||||
R.xml.devicesettings_sony_headphones_notifications_voice_guide,
|
||||
R.xml.devicesettings_sony_headphones_device_info
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1383,7 +1383,9 @@
|
||||
<string name="battery_case">Battery case</string>
|
||||
<string name="left_earbud">Left earbud</string>
|
||||
<string name="right_earbud">Right earbud</string>
|
||||
<string name="audio_codec">Audio Codec</string>
|
||||
<string name="pref_header_sony_ambient_sound_control">Ambient Sound Control</string>
|
||||
<string name="pref_header_sony_device_info">Device Information</string>
|
||||
<string name="sony_ambient_sound">Mode</string>
|
||||
<string name="sony_ambient_sound_off">Off</string>
|
||||
<string name="sony_ambient_sound_noise_cancelling">Noise Cancelling</string>
|
||||
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:key="pref_key_header_sony_device_info"
|
||||
android:title="@string/pref_header_sony_device_info">
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="\?"
|
||||
android:enabled="false"
|
||||
android:icon="@drawable/ic_music_note"
|
||||
android:key="pref_sony_audio_codec"
|
||||
android:shouldDisableView="false"
|
||||
android:title="@string/audio_codec"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</androidx.preference.PreferenceScreen>
|
@ -3,7 +3,7 @@
|
||||
|
||||
<PreferenceScreen
|
||||
android:icon="@drawable/ic_graphic_eq"
|
||||
android:key="pref_key_equalizer"
|
||||
android:key="pref_sony_equalizer"
|
||||
android:persistent="false"
|
||||
android:title="@string/pref_header_equalizer">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user