Fix keyboard not reacting to changed preferences

The callback might not be called if the "default" shared preferences is
different from the shared preferences actually used. This is unexpected
but seems to happen half of the time on Android 12.

Since f1ce6ab, this callback is critical to update the keyboard.
Restarting the application can no longer solve these issues.
This commit is contained in:
Jules Aguillon 2022-12-11 14:55:32 +01:00
parent 8665d002bf
commit 87d21685ca

View File

@ -17,7 +17,7 @@ public class SettingsActivity extends PreferenceActivity
SharedPreferences prefs;
// The preferences can't be read when in direct-boot mode. Avoid crashing
// and don't allow changing the settings.
try { prefs = PreferenceManager.getDefaultSharedPreferences(this); }
try { prefs = getPreferenceManager().getSharedPreferences(); }
catch (Exception _e) { fallbackEncrypted(); return; }
addPreferencesFromResource(R.xml.settings);
prefs.registerOnSharedPreferenceChangeListener(this.new OnPreferencesChange());