abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/EmojiGridView.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/EmojiGridView.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/EmojiGridView.java')
-rw-r--r--srcs/juloo.keyboard2/EmojiGridView.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/srcs/juloo.keyboard2/EmojiGridView.java b/srcs/juloo.keyboard2/EmojiGridView.java
index 224099c..581200c 100644
--- a/srcs/juloo.keyboard2/EmojiGridView.java
+++ b/srcs/juloo.keyboard2/EmojiGridView.java
@@ -3,7 +3,6 @@ package juloo.keyboard2;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Typeface;
-import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
@@ -84,9 +83,8 @@ public class EmojiGridView extends GridView
private void saveLastUsed()
{
- SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(getContext()).edit();
+ SharedPreferences.Editor edit = emojiSharedPreferences().edit();
HashSet<String> set = new HashSet<String>();
-
for (Emoji emoji : _lastUsed.keySet())
set.add(String.valueOf(_lastUsed.get(emoji)) + "-" + emoji.name());
edit.putStringSet(LAST_USE_PREF, set);
@@ -95,9 +93,8 @@ public class EmojiGridView extends GridView
private void loadLastUsed()
{
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
+ SharedPreferences prefs = emojiSharedPreferences();
Set<String> lastUseSet = prefs.getStringSet(LAST_USE_PREF, null);
-
_lastUsed = new HashMap<Emoji, Integer>();
if (lastUseSet != null)
for (String emojiData : lastUseSet)
@@ -114,6 +111,11 @@ public class EmojiGridView extends GridView
}
}
+ SharedPreferences emojiSharedPreferences()
+ {
+ return getContext().getSharedPreferences("emoji_last_use", Context.MODE_PRIVATE);
+ }
+
private static class EmojiView extends TextView
{
public EmojiView(Context context)