From d1b4e013d344f7b82e3f747ff0faed4cad6dbe41 Mon Sep 17 00:00:00 2001 From: Severin von Wnuck-Lipinski Date: Mon, 12 Aug 2024 22:55:26 +0200 Subject: [PATCH] Add defaults and fix NPE for Soundcore Motion 300 --- .../motion300/SoundcoreMotion300SettingsCustomizer.java | 8 ++++++-- .../main/res/xml/devicesettings_soundcore_motion300.xml | 2 ++ .../res/xml/devicesettings_soundcore_motion300_audio.xml | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/soundcore/motion300/SoundcoreMotion300SettingsCustomizer.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/soundcore/motion300/SoundcoreMotion300SettingsCustomizer.java index 251fae92c..da94cba17 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/soundcore/motion300/SoundcoreMotion300SettingsCustomizer.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/soundcore/motion300/SoundcoreMotion300SettingsCustomizer.java @@ -50,9 +50,13 @@ public class SoundcoreMotion300SettingsCustomizer implements DeviceSpecificSetti if (!preference.getKey().equals(PREF_SOUNDCORE_EQUALIZER_PRESET)) return; - String preset = ((ListPreference)preference).getEntry().toString(); + CharSequence preset = ((ListPreference)preference).getEntry(); + + if (preset == null) + return; + Preference pref = handler.findPreference(PREF_SOUNDCORE_EQUALIZER_CUSTOM); - boolean customEnabled = preset.equals(handler.getContext().getString(R.string.custom)); + boolean customEnabled = preset.toString().equals(handler.getContext().getString(R.string.custom)); if (pref != null) pref.setEnabled(customEnabled); diff --git a/app/src/main/res/xml/devicesettings_soundcore_motion300.xml b/app/src/main/res/xml/devicesettings_soundcore_motion300.xml index 130bb9ce4..2cae644ce 100644 --- a/app/src/main/res/xml/devicesettings_soundcore_motion300.xml +++ b/app/src/main/res/xml/devicesettings_soundcore_motion300.xml @@ -7,6 +7,7 @@ android:layout="@layout/preference_checkbox" android:title="@string/soundcore_voice_prompts" />