abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Keyboard2.java
diff options
context:
space:
mode:
authorJules Aguillon2022-11-11 14:27:02 +0100
committerJules Aguillon2022-11-11 14:27:02 +0100
commitf1ce6abe5a37c9ca57d885ecb9a3218969bc7fdf (patch)
tree543c0a644f0ae8727e47ce408908a5790f7988cc /srcs/juloo.keyboard2/Keyboard2.java
parent29fbb27a8ace95779518a435dcda36cb43ab41ac (diff)
downloadunexpected-keyboard-f1ce6abe5a37c9ca57d885ecb9a3218969bc7fdf.tar.gz
unexpected-keyboard-f1ce6abe5a37c9ca57d885ecb9a3218969bc7fdf.zip
Direct-boot aware preferences
Store preferences in device protected storage, which is available before the device is unlocked. The keyboard was crashing when trying to access the encrypted preferences. The emoji pane uses a separate preferences file, the old data is lost. The SettingsActivity can't easily use the new preferences storage. Instead, it continues to use the "default" preferences store, which is copied back to the protected storage when needed.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2.java')
-rw-r--r--srcs/juloo.keyboard2/Keyboard2.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index 192e54d..7bf9812 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -6,23 +6,22 @@ import android.content.SharedPreferences;
import android.inputmethodservice.InputMethodService;
import android.os.Build.VERSION;
import android.os.IBinder;
-import android.preference.PreferenceManager;
import android.text.InputType;
+import android.util.Log;
+import android.util.LogPrinter;
import android.view.ContextThemeWrapper;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewParent;
-import android.util.Log;
-import android.util.LogPrinter;
import java.util.Arrays;
-import java.util.List;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
public class Keyboard2 extends InputMethodService
@@ -49,11 +48,10 @@ public class Keyboard2 extends InputMethodService
public void onCreate()
{
super.onCreate();
- PreferenceManager.setDefaultValues(this, R.xml.settings, false);
- PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
- Config.initGlobalConfig(this, new KeyEventHandler(this.new Receiver()));
+ SharedPreferences prefs = DirectBootAwarePreferences.get_shared_preferences(this);
+ prefs.registerOnSharedPreferenceChangeListener(this);
+ Config.initGlobalConfig(prefs, getResources(), new KeyEventHandler(this.new Receiver()));
_config = Config.globalConfig();
- _config.refresh(this);
_keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard);
_keyboardView.reset();
_debug_logs = getResources().getBoolean(R.bool.debug_logs);
@@ -205,7 +203,7 @@ public class Keyboard2 extends InputMethodService
private void refreshConfig()
{
int prev_theme = _config.theme;
- _config.refresh(this);
+ _config.refresh(getResources());
refreshSubtypeImm();
// Refreshing the theme config requires re-creating the views
if (prev_theme != _config.theme)