use of nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v1.params.NoiseCancellingOptimizerStatus in project Gadgetbridge by Freeyourgadget.
the class SonyHeadphonesSettingsCustomizer method onPreferenceChange.
@Override
public void onPreferenceChange(final Preference preference, final DeviceSpecificSettingsHandler handler) {
// 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);
}
}
}
// Handle ANC Optimizer status
if (preference.getKey().equals(PREF_SONY_NOISE_OPTIMIZER_STATUS)) {
final EditTextPreference optimizerStatusPreference = (EditTextPreference) preference;
final NoiseCancellingOptimizerStatus optimizerStatus = NoiseCancellingOptimizerStatus.valueOf(optimizerStatusPreference.getText().toUpperCase(Locale.ROOT));
if (ancOptimizerProgressDialog != null) {
switch(optimizerStatus) {
case FINISHED:
case NOT_RUNNING:
ancOptimizerProgressDialog.dismiss();
ancOptimizerProgressDialog = null;
break;
default:
ancOptimizerProgressDialog.setMessage(optimizerStatus.i18n(preference.getContext()));
}
}
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v1.params.NoiseCancellingOptimizerStatus in project Gadgetbridge by Freeyourgadget.
the class SonyProtocolImplV1 method handleNoiseCancellingOptimizerStatus.
public List<? extends GBDeviceEvent> handleNoiseCancellingOptimizerStatus(final byte[] payload) {
if (payload.length != 4) {
LOG.warn("Unexpected payload length {}", payload.length);
return Collections.emptyList();
}
final NoiseCancellingOptimizerStatus status = NoiseCancellingOptimizerStatus.fromCode(payload[3]);
if (status == null) {
LOG.warn("Unable to determine noise cancelling opptimizer status from {}", GB.hexdump(payload));
return Collections.emptyList();
}
LOG.info("Noise Cancelling Optimizer status: {}", status);
final GBDeviceEventUpdatePreferences event = new GBDeviceEventUpdatePreferences().withPreference(PREF_SONY_NOISE_OPTIMIZER_STATUS, status.name().toLowerCase(Locale.ROOT));
return Collections.singletonList(event);
}
Aggregations