diff options
| author | Jules Aguillon | 2021-12-28 17:53:58 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2021-12-28 17:53:58 +0100 |
| commit | 93704cca0ace3bff31dea5d3841ba185ad89398a (patch) | |
| tree | d2e69c5191f347cd8de9d7b2cbdd4493e2c13a4c /srcs/juloo.keyboard2 | |
| parent | 15ce200ce3f9d19f1a1f1fb43f176bf511f14271 (diff) | |
| download | unexpected-keyboard-93704cca0ace3bff31dea5d3841ba185ad89398a.tar.gz unexpected-keyboard-93704cca0ace3bff31dea5d3841ba185ad89398a.zip | |
Reference the "special key font" in the Theme object
Remove the last cast of the context.
Diffstat (limited to 'srcs/juloo.keyboard2')
| -rw-r--r-- | srcs/juloo.keyboard2/EmojiKeyButton.java | 2 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2.java | 7 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Theme.java | 17 |
3 files changed, 15 insertions, 11 deletions
diff --git a/srcs/juloo.keyboard2/EmojiKeyButton.java b/srcs/juloo.keyboard2/EmojiKeyButton.java index 6f662b4..51ff14f 100644 --- a/srcs/juloo.keyboard2/EmojiKeyButton.java +++ b/srcs/juloo.keyboard2/EmojiKeyButton.java @@ -17,7 +17,7 @@ public class EmojiKeyButton extends Button _key = KeyValue.getKeyByName(attrs.getAttributeValue(null, "key")); setText(_key.symbol); if ((_key.flags & KeyValue.FLAG_KEY_FONT) != 0) - setTypeface(((Keyboard2)context).getSpecialKeyFont()); + setTypeface(Theme.getSpecialKeyFont(context)); } public void onClick(View v) diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 0eb2a23..17c9d4e 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -31,7 +31,6 @@ public class Keyboard2 extends InputMethodService private Keyboard2View _keyboardView; private int _currentTextLayout; private ViewGroup _emojiPane = null; - private Typeface _specialKeyFont = null; private Config _config; @@ -52,7 +51,6 @@ public class Keyboard2 extends InputMethodService public void onCreate() { super.onCreate(); - _specialKeyFont = Typeface.createFromAsset(getAssets(), "fonts/keys.ttf"); PreferenceManager.setDefaultValues(this, R.xml.settings, false); PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); Config.initGlobalConfig(this, new KeyEventHandler(this.new Receiver())); @@ -61,11 +59,6 @@ public class Keyboard2 extends InputMethodService _keyboardView.reset(); } - public Typeface getSpecialKeyFont() - { - return (_specialKeyFont); - } - private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm) { String pkg = getPackageName(); diff --git a/srcs/juloo.keyboard2/Theme.java b/srcs/juloo.keyboard2/Theme.java index 60c9b88..af2f3d7 100644 --- a/srcs/juloo.keyboard2/Theme.java +++ b/srcs/juloo.keyboard2/Theme.java @@ -35,9 +35,9 @@ public class Theme keyDownBgPaint.setColor(res.getColor(R.color.key_down_bg)); _keyLabelPaint = initLabelPaint(Paint.Align.CENTER, null); _keySubLabelPaint = initLabelPaint(Paint.Align.LEFT, null); - Typeface specialKeysFont = ((Keyboard2)context).getSpecialKeyFont(); - _specialKeyLabelPaint = initLabelPaint(Paint.Align.CENTER, specialKeysFont); - _specialKeySubLabelPaint = initLabelPaint(Paint.Align.LEFT, specialKeysFont); + Typeface specialKeyFont = getSpecialKeyFont(context); + _specialKeyLabelPaint = initLabelPaint(Paint.Align.CENTER, specialKeyFont); + _specialKeySubLabelPaint = initLabelPaint(Paint.Align.LEFT, specialKeyFont); } public Paint labelPaint(boolean special_font) @@ -61,4 +61,15 @@ public class Theme paint.setTypeface(font); return (paint); } + + private static Typeface _specialKeyFont = null; + + static public Typeface getSpecialKeyFont(Context context) + { + if (_specialKeyFont == null) + { + _specialKeyFont = Typeface.createFromAsset(context.getAssets(), "fonts/keys.ttf"); + } + return _specialKeyFont; + } } |
