From 87d21685ca2909a1a08ac22bd8eb2672c3139840 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 11 Dec 2022 14:55:32 +0100 Subject: [PATCH] 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. --- srcs/juloo.keyboard2/SettingsActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcs/juloo.keyboard2/SettingsActivity.java b/srcs/juloo.keyboard2/SettingsActivity.java index 04fe501..6381d55 100644 --- a/srcs/juloo.keyboard2/SettingsActivity.java +++ b/srcs/juloo.keyboard2/SettingsActivity.java @@ -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());