diff options
| author | Jules Aguillon | 2022-01-30 23:29:50 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2022-01-30 23:29:50 +0100 |
| commit | 8631dfb723716e3273e92b2dfd02008d733b86a9 (patch) | |
| tree | 9c05a311c2554f11f2184198e40de3fa24807fa9 /srcs/juloo.keyboard2/Keyboard2.java | |
| parent | c9f7f2cfc8c08254d9a2c7edd9d290759c63b9b6 (diff) | |
| download | unexpected-keyboard-8631dfb723716e3273e92b2dfd02008d733b86a9.tar.gz unexpected-keyboard-8631dfb723716e3273e92b2dfd02008d733b86a9.zip | |
Select theme depending on system settings
Automatically choose between the Dark and Light themes.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2.java | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index fa4b494..54fe587 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -57,6 +57,7 @@ public class Keyboard2 extends InputMethodService PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); Config.initGlobalConfig(this, new KeyEventHandler(this.new Receiver())); _config = Config.globalConfig(); + _config.refresh(this); _keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard); _keyboardView.reset(); } @@ -177,17 +178,27 @@ public class Keyboard2 extends InputMethodService } } + private void refreshConfig() + { + int prev_theme = _config.theme; + _config.refresh(this); + refreshSubtypeImm(); + // Refreshing the theme config requires re-creating the views + if (prev_theme != _config.theme) + { + _keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard); + _emojiPane = null; + } + _keyboardView.setKeyboard(getLayout(_currentTextLayout)); + } + @Override public void onStartInputView(EditorInfo info, boolean restarting) { - // Update '_config' before calling 'KeyboardView.setKeyboard' - refreshSubtypeImm(); + refreshConfig(); refreshEditorInfo(info); if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0) _keyboardView.setKeyboard(getLayout(R.xml.numeric)); - else - _keyboardView.setKeyboard(getLayout(_currentTextLayout)); - _keyboardView.reset(); // Layout might need to change due to rotation setInputView(_keyboardView); } @@ -217,16 +228,7 @@ public class Keyboard2 extends InputMethodService @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - int prev_theme = _config.theme; - _config.refresh(this); - refreshSubtypeImm(); - _keyboardView.setKeyboard(getLayout(_currentTextLayout)); - // Refreshing the theme config requires re-creating the views - if (prev_theme != _config.theme) - { - _keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard); - _emojiPane = null; - } + refreshConfig(); } /** Not static */ |
