mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-25 00:57:33 +01:00
Sony WH-1000XM3: Disable device preferences conditionally
This commit is contained in:
parent
0c32f42ae3
commit
8416cb4e71
@ -60,7 +60,8 @@ public class DeviceSettingsActivity extends AbstractGBActivity implements
|
||||
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_device_card_activity_card_preferences);
|
||||
}
|
||||
|
||||
fragment = DeviceSpecificSettingsFragment.newInstance(device.getAddress(), supportedSettings, supportedLanguages);
|
||||
final DeviceSpecificSettingsCustomizer deviceSpecificSettingsCustomizer = coordinator.getDeviceSpecificSettingsCustomizer(device);
|
||||
fragment = DeviceSpecificSettingsFragment.newInstance(device.getAddress(), supportedSettings, supportedLanguages, deviceSpecificSettingsCustomizer);
|
||||
}
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
@ -85,7 +86,8 @@ public class DeviceSettingsActivity extends AbstractGBActivity implements
|
||||
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_device_card_activity_card_preferences);
|
||||
}
|
||||
|
||||
PreferenceFragmentCompat fragment = DeviceSpecificSettingsFragment.newInstance(device.getAddress(), supportedSettings, supportedLanguages);
|
||||
final DeviceSpecificSettingsCustomizer deviceSpecificSettingsCustomizer = coordinator.getDeviceSpecificSettingsCustomizer(device);
|
||||
PreferenceFragmentCompat fragment = DeviceSpecificSettingsFragment.newInstance(device.getAddress(), supportedSettings, supportedLanguages, deviceSpecificSettingsCustomizer);
|
||||
Bundle args = fragment.getArguments();
|
||||
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
|
||||
fragment.setArguments(args);
|
||||
|
@ -118,6 +118,9 @@ public class DeviceSettingsPreferenceConst {
|
||||
public static final String PREF_SONY_SURROUND_MODE = "pref_sony_surround_mode";
|
||||
public static final String PREF_SONY_EQUALIZER_MODE = "pref_sony_equalizer_mode";
|
||||
public static final String PREF_SONY_DSEE_HX = "pref_sony_dsee_hx";
|
||||
public static final String PREF_SONY_EQUALIZER_PRESET_MANUAL = "pref_sony_equalizer_preset_manual";
|
||||
public static final String PREF_SONY_EQUALIZER_PRESET_CUSTOM_1 = "pref_sony_equalizer_preset_custom_1";
|
||||
public static final String PREF_SONY_EQUALIZER_PRESET_CUSTOM_2 = "pref_sony_equalizer_preset_custom_2";
|
||||
public static final String PREF_SONY_EQUALIZER_MANUAL_BAND_400 = "pref_sony_equalizer_manual_band_400";
|
||||
public static final String PREF_SONY_EQUALIZER_MANUAL_BAND_1000 = "pref_sony_equalizer_manual_band_1000";
|
||||
public static final String PREF_SONY_EQUALIZER_MANUAL_BAND_2500 = "pref_sony_equalizer_manual_band_2500";
|
||||
|
@ -0,0 +1,30 @@
|
||||
/* Copyright (C) 2021 José Rebelo
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities.devicesettings;
|
||||
|
||||
/**
|
||||
* A device-specific preference handler, that allows for concrete implementations to customize the preferences in
|
||||
* the {@link DeviceSpecificSettingsFragment}.
|
||||
*/
|
||||
public interface DeviceSpecificSettingsCustomizer {
|
||||
/**
|
||||
* Customize the settings on the {@link DeviceSpecificSettingsFragment}.
|
||||
*
|
||||
* @param handler the {@link DeviceSpecificSettingsHandler}
|
||||
*/
|
||||
void customizeSettings(final DeviceSpecificSettingsHandler handler);
|
||||
}
|
@ -191,7 +191,13 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PR
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_NIGHT_MODE_START;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_SWIPE_UNLOCK;
|
||||
|
||||
public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
|
||||
public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat implements DeviceSpecificSettingsHandler {
|
||||
|
||||
private final DeviceSpecificSettingsCustomizer deviceSpecificSettingsCustomizer;
|
||||
|
||||
public DeviceSpecificSettingsFragment(final DeviceSpecificSettingsCustomizer deviceSpecificSettingsCustomizer) {
|
||||
this.deviceSpecificSettingsCustomizer = deviceSpecificSettingsCustomizer;
|
||||
}
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DeviceSpecificSettingsFragment.class);
|
||||
|
||||
@ -816,10 +822,17 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
|
||||
preferenceInControlCenter.setOnPreferenceClickListener(sendIntentRefreshDeviceListListener);
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceSpecificSettingsCustomizer != null) {
|
||||
deviceSpecificSettingsCustomizer.customizeSettings(this);
|
||||
}
|
||||
}
|
||||
|
||||
static DeviceSpecificSettingsFragment newInstance(String settingsFileSuffix, @NonNull int[] supportedSettings, String[] supportedLanguages) {
|
||||
DeviceSpecificSettingsFragment fragment = new DeviceSpecificSettingsFragment();
|
||||
static DeviceSpecificSettingsFragment newInstance(String settingsFileSuffix,
|
||||
@NonNull int[] supportedSettings,
|
||||
String[] supportedLanguages,
|
||||
DeviceSpecificSettingsCustomizer deviceSpecificSettingsCustomizer) {
|
||||
DeviceSpecificSettingsFragment fragment = new DeviceSpecificSettingsFragment(deviceSpecificSettingsCustomizer);
|
||||
fragment.setSettingsFileSuffix(settingsFileSuffix, supportedSettings, supportedLanguages);
|
||||
|
||||
return fragment;
|
||||
@ -851,7 +864,13 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
|
||||
}
|
||||
}
|
||||
|
||||
private void addPreferenceHandlerFor(final String preferenceKey) {
|
||||
@Override
|
||||
public void addPreferenceHandlerFor(final String preferenceKey) {
|
||||
addPreferenceHandlerFor(preferenceKey, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPreferenceHandlerFor(final String preferenceKey, final Preference.OnPreferenceChangeListener extraListener) {
|
||||
Preference pref = findPreference(preferenceKey);
|
||||
if (pref != null) {
|
||||
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@ -862,6 +881,11 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
|
||||
GBApplication.deviceService().onSendConfiguration(preferenceKey);
|
||||
}
|
||||
});
|
||||
|
||||
if (extraListener != null) {
|
||||
return extraListener.onPreferenceChange(preference, newVal);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,49 @@
|
||||
/* Copyright (C) 2021 José Rebelo
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities.devicesettings;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
/**
|
||||
* A device-specific preference handler, that allows for {@link nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator}s to register
|
||||
* their own preferences dynamically.
|
||||
*/
|
||||
public interface DeviceSpecificSettingsHandler {
|
||||
/**
|
||||
* Finds a preference with the given key. Returns null if the preference is not found.
|
||||
*
|
||||
* @param preferenceKey the preference key.
|
||||
* @return the preference, if found.
|
||||
*/
|
||||
<T extends Preference> T findPreference(@NonNull CharSequence preferenceKey);
|
||||
|
||||
/**
|
||||
* Adds a preference handler for a preference key. This handler sends the preference to the device on change.
|
||||
*
|
||||
* @param preferenceKey the preference key.
|
||||
*/
|
||||
void addPreferenceHandlerFor(final String preferenceKey);
|
||||
|
||||
/**
|
||||
* Adds a preference handler for a preference key. On change, this handler calls the provided extra listener, and then sends the preference to the device.
|
||||
*
|
||||
* @param preferenceKey the preference key.
|
||||
* @param extraListener the extra listener.
|
||||
*/
|
||||
void addPreferenceHandlerFor(final String preferenceKey, Preference.OnPreferenceChangeListener extraListener);
|
||||
}
|
@ -37,6 +37,7 @@ import java.util.Collections;
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
||||
@ -242,6 +243,11 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(GBDevice device) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedLanguageSettings(GBDevice device) {
|
||||
return null;
|
||||
|
@ -32,6 +32,7 @@ import java.util.Collection;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
@ -347,6 +348,11 @@ public interface DeviceCoordinator {
|
||||
*/
|
||||
int[] getSupportedDeviceSpecificSettings(GBDevice device);
|
||||
|
||||
/**
|
||||
* Returns the {@link DeviceSpecificSettingsCustomizer}, allowing for the customization of the devices specific settings screen.
|
||||
*/
|
||||
DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(GBDevice device);
|
||||
|
||||
/**
|
||||
* Indicates which device specific language the device supports
|
||||
*/
|
||||
|
@ -24,6 +24,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
@ -38,6 +39,11 @@ public abstract class SonyHeadphonesCoordinator extends AbstractDeviceCoordinato
|
||||
return "Sony";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) {
|
||||
return new SonySettingsCustomizer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
|
||||
}
|
||||
|
@ -0,0 +1,118 @@
|
||||
/* Copyright (C) 2021 José Rebelo
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
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_EQUALIZER_MODE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_PRESET_CUSTOM_1;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_PRESET_CUSTOM_2;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_PRESET_MANUAL;
|
||||
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 androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsHandler;
|
||||
|
||||
public class SonySettingsCustomizer implements DeviceSpecificSettingsCustomizer {
|
||||
@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
|
||||
|
||||
final ListPreference ambientSoundControl = handler.findPreference(PREF_SONY_AMBIENT_SOUND_CONTROL);
|
||||
if (ambientSoundControl != null) {
|
||||
final Preference focusOnVoice = handler.findPreference(PREF_SONY_FOCUS_VOICE);
|
||||
final Preference ambientSoundLevel = handler.findPreference(PREF_SONY_AMBIENT_SOUND_LEVEL);
|
||||
|
||||
final Preference.OnPreferenceChangeListener ambientSoundControlPrefListener = new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
boolean isAmbientSoundEnabled = AmbientSoundControl.AMBIENT_SOUND.name().toLowerCase(Locale.ROOT).equals(newVal);
|
||||
focusOnVoice.setEnabled(isAmbientSoundEnabled);
|
||||
ambientSoundLevel.setEnabled(isAmbientSoundEnabled);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
ambientSoundControlPrefListener.onPreferenceChange(ambientSoundControl, ambientSoundControl.getValue());
|
||||
handler.addPreferenceHandlerFor(PREF_SONY_AMBIENT_SOUND_CONTROL, ambientSoundControlPrefListener);
|
||||
}
|
||||
|
||||
// Make the sound position and surround mode settings mutually exclusive
|
||||
|
||||
final ListPreference soundPositionPref = handler.findPreference(PREF_SONY_SOUND_POSITION);
|
||||
final ListPreference surroundModePref = handler.findPreference(PREF_SONY_SURROUND_MODE);
|
||||
|
||||
if (soundPositionPref != null && surroundModePref != null) {
|
||||
final Preference.OnPreferenceChangeListener soundPositionPrefListener = new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
SoundPosition soundPosition = SoundPosition.valueOf(newVal.toString().toUpperCase(Locale.ROOT));
|
||||
surroundModePref.setEnabled(SoundPosition.OFF.equals(soundPosition));
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
final Preference.OnPreferenceChangeListener surroundModePrefListener = new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
SurroundMode surroundMode = SurroundMode.valueOf(newVal.toString().toUpperCase(Locale.ROOT));
|
||||
soundPositionPref.setEnabled(SurroundMode.OFF.equals(surroundMode));
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
soundPositionPrefListener.onPreferenceChange(soundPositionPref, soundPositionPref.getValue());
|
||||
surroundModePrefListener.onPreferenceChange(surroundModePref, surroundModePref.getValue());
|
||||
handler.addPreferenceHandlerFor(PREF_SONY_SOUND_POSITION, soundPositionPrefListener);
|
||||
handler.addPreferenceHandlerFor(PREF_SONY_SURROUND_MODE, surroundModePrefListener);
|
||||
}
|
||||
|
||||
// Only enable the equalizer preset if the corresponding mode is selected
|
||||
|
||||
final ListPreference equalizerModePref = handler.findPreference(PREF_SONY_EQUALIZER_MODE);
|
||||
|
||||
if (equalizerModePref != null) {
|
||||
handler.addPreferenceHandlerFor(PREF_SONY_EQUALIZER_MODE);
|
||||
|
||||
final Preference presetManual = handler.findPreference(PREF_SONY_EQUALIZER_PRESET_MANUAL);
|
||||
final Preference presetCustom1 = handler.findPreference(PREF_SONY_EQUALIZER_PRESET_CUSTOM_1);
|
||||
final Preference presetCustom2 = handler.findPreference(PREF_SONY_EQUALIZER_PRESET_CUSTOM_2);
|
||||
|
||||
final Preference.OnPreferenceChangeListener equalizerModePrefListener = new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
final EqualizerPreset equalizerPreset = EqualizerPreset.valueOf(newVal.toString().toUpperCase(Locale.ROOT));
|
||||
|
||||
presetManual.setEnabled(EqualizerPreset.MANUAL.equals(equalizerPreset));
|
||||
presetCustom1.setEnabled(EqualizerPreset.CUSTOM_1.equals(equalizerPreset));
|
||||
presetCustom2.setEnabled(EqualizerPreset.CUSTOM_2.equals(equalizerPreset));
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
equalizerModePrefListener.onPreferenceChange(equalizerModePref, equalizerModePref.getValue());
|
||||
handler.addPreferenceHandlerFor(PREF_SONY_EQUALIZER_MODE, equalizerModePrefListener);
|
||||
}
|
||||
}
|
||||
}
|
@ -147,11 +147,7 @@ public abstract class SonyHeadphonesProtocol extends GBDeviceProtocol {
|
||||
int m_band5 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_MANUAL_BAND_16000, 10) - 10;
|
||||
int m_bass = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_MANUAL_CLEAR_BASS, 10) - 10;
|
||||
|
||||
// Set the equalizer preset, since changing the bands will switch it
|
||||
// TODO: This is not updating the UI once the user returns to the previous screen
|
||||
prefs.edit().putString(DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_MODE, EqualizerPreset.MANUAL.toString().toLowerCase()).apply();
|
||||
|
||||
return encodeEqualizerCustomBands(EqualizerPreset.MANUAL, equalizerPreset, new EqualizerCustomBands(Arrays.asList(m_band1, m_band2, m_band3, m_band4, m_band5), m_bass));
|
||||
return encodeEqualizerCustomBands(new EqualizerCustomBands(Arrays.asList(m_band1, m_band2, m_band3, m_band4, m_band5), m_bass));
|
||||
|
||||
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_CUSTOM_1_BAND_400:
|
||||
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_CUSTOM_1_BAND_1000:
|
||||
@ -166,11 +162,7 @@ public abstract class SonyHeadphonesProtocol extends GBDeviceProtocol {
|
||||
int c1_band5 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_CUSTOM_1_BAND_16000, 10) - 10;
|
||||
int c1_bass = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_CUSTOM_1_CLEAR_BASS, 10) - 10;
|
||||
|
||||
// Set the equalizer preset, since changing the bands will switch it
|
||||
// TODO: This is not updating the UI once the user returns to the previous screen
|
||||
prefs.edit().putString(DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_MODE, EqualizerPreset.CUSTOM_1.toString().toLowerCase()).apply();
|
||||
|
||||
return encodeEqualizerCustomBands(EqualizerPreset.CUSTOM_1, equalizerPreset, new EqualizerCustomBands(Arrays.asList(c1_band1, c1_band2, c1_band3, c1_band4, c1_band5), c1_bass));
|
||||
return encodeEqualizerCustomBands(new EqualizerCustomBands(Arrays.asList(c1_band1, c1_band2, c1_band3, c1_band4, c1_band5), c1_bass));
|
||||
|
||||
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_CUSTOM_2_BAND_400:
|
||||
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_CUSTOM_2_BAND_1000:
|
||||
@ -185,11 +177,7 @@ public abstract class SonyHeadphonesProtocol extends GBDeviceProtocol {
|
||||
int c2_band5 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_CUSTOM_2_BAND_16000, 10) - 10;
|
||||
int c2_bass = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_CUSTOM_2_CLEAR_BASS, 10) - 10;
|
||||
|
||||
// Set the equalizer preset, since changing the bands will switch it
|
||||
// TODO: This is not updating the UI once the user returns to the previous screen
|
||||
prefs.edit().putString(DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_MODE, EqualizerPreset.CUSTOM_2.toString().toLowerCase()).apply();
|
||||
|
||||
return encodeEqualizerCustomBands(EqualizerPreset.CUSTOM_2, equalizerPreset, new EqualizerCustomBands(Arrays.asList(c2_band1, c2_band2, c2_band3, c2_band4, c2_band5), c2_bass));
|
||||
return encodeEqualizerCustomBands(new EqualizerCustomBands(Arrays.asList(c2_band1, c2_band2, c2_band3, c2_band4, c2_band5), c2_bass));
|
||||
|
||||
case DeviceSettingsPreferenceConst.PREF_SONY_DSEE_HX:
|
||||
return encodeDSEEHX(prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_SONY_DSEE_HX, false));
|
||||
@ -292,23 +280,6 @@ public abstract class SonyHeadphonesProtocol extends GBDeviceProtocol {
|
||||
);
|
||||
}
|
||||
|
||||
private byte[] encodeEqualizerCustomBands(EqualizerPreset preset, EqualizerPreset previousPreset, EqualizerCustomBands equalizer) {
|
||||
ByteArrayOutputStream cmdStream = new ByteArrayOutputStream(16);
|
||||
|
||||
try {
|
||||
if (preset != previousPreset) {
|
||||
// If we're not on the preset that is being changed, we need to swap to it
|
||||
cmdStream.write(encodeEqualizerPreset(preset));
|
||||
}
|
||||
|
||||
cmdStream.write(encodeEqualizerCustomBands(equalizer));
|
||||
} catch (IOException e) {
|
||||
LOG.error("This should never happen", e);
|
||||
}
|
||||
|
||||
return cmdStream.toByteArray();
|
||||
}
|
||||
|
||||
private byte[] encodeEqualizerCustomBands(EqualizerCustomBands equalizer) {
|
||||
final ByteBuffer buf = ByteBuffer.allocate(10);
|
||||
|
||||
|
@ -1187,7 +1187,6 @@
|
||||
<string name="sony_surround_mode_club">Discoteca</string>
|
||||
<string name="sony_surround_mode_outdoor_stage">Palco exterior</string>
|
||||
<string name="sony_surround_mode_concert_hall">Sala de concertos</string>
|
||||
<string name="sony_surround_position_mutually_exclusive">Aviso: As preferencias de posição de som / modo surround são mutuamente exclusivas.</string>
|
||||
<string name="sony_warn_sbc_codec">Aviso: As preferencias de equalizador, modo surround e posição do som só funcionam com o codec de audio SBC.</string>
|
||||
<string name="sony_equalizer">Equalizador</string>
|
||||
<string name="sony_equalizer_preset_off">Desligado</string>
|
||||
|
@ -1353,7 +1353,6 @@
|
||||
<string name="sony_surround_mode_club">Club</string>
|
||||
<string name="sony_surround_mode_outdoor_stage">Outdoor Stage</string>
|
||||
<string name="sony_surround_mode_concert_hall">Concert Hall</string>
|
||||
<string name="sony_surround_position_mutually_exclusive">Warning: The sound position / surround mode settings are mutually exclusive.</string>
|
||||
<string name="sony_warn_sbc_codec">Warning: The equalizer, audio position and surround settings only work for the SBC audio codec.</string>
|
||||
<string name="sony_equalizer">Equalizer</string>
|
||||
<string name="sony_equalizer_preset_off">Off</string>
|
||||
|
@ -4,11 +4,6 @@
|
||||
android:key="pref_key_other"
|
||||
android:title="@string/pref_header_other">
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_warning"
|
||||
android:key="pref_sony_warning_position_surround"
|
||||
android:summary="@string/sony_surround_position_mutually_exclusive" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="off"
|
||||
android:entries="@array/sony_sound_position_names"
|
||||
|
Loading…
x
Reference in New Issue
Block a user