diff options
| author | Jules Aguillon | 2026-01-18 17:26:41 +0100 |
|---|---|---|
| committer | GitHub | 2026-01-18 17:26:41 +0100 |
| commit | a848897586223b050e87367b48ed2eebd0870d1d (patch) | |
| tree | 7a4a68886a27ee9bf37815597ceebc38e1d45f29 /srcs/juloo.keyboard2/EditorConfig.java | |
| parent | 4d4c22b4e21505000d92fa3b6c1f400379c51cd4 (diff) | |
| download | unexpected-keyboard-a848897586223b050e87367b48ed2eebd0870d1d.tar.gz unexpected-keyboard-a848897586223b050e87367b48ed2eebd0870d1d.zip | |
Refactor: Split DeviceLocales out of Keyboard2 (#1154)
* Refactor: Split DeviceLocales out of Keyboard2
This moves the code from Keyboard2 that handles the active IME subtypes
and the current one.
The goal is to access this information from the dictionary activity
while simplifying the code of Keyboard2.
* Refresh the candidates view when subtype changes
This fixes the status message being inconsistently shown.
* Refactor: Load DeviceLocales less often
Previously, [DeviceLocales.load()] was called everytime the keyboard was
shown on the screen. This operation is moderately costly and only need
to be done when the IME subtype changes.
* EditorConfig: Fix crash on Android 9
Diffstat (limited to 'srcs/juloo.keyboard2/EditorConfig.java')
| -rw-r--r-- | srcs/juloo.keyboard2/EditorConfig.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/srcs/juloo.keyboard2/EditorConfig.java b/srcs/juloo.keyboard2/EditorConfig.java index bdfab3c..2bfbcef 100644 --- a/srcs/juloo.keyboard2/EditorConfig.java +++ b/srcs/juloo.keyboard2/EditorConfig.java @@ -1,9 +1,11 @@ package juloo.keyboard2; import android.content.res.Resources; +import android.os.Build.VERSION; import android.text.InputType; import android.text.TextUtils; import android.view.inputmethod.EditorInfo; +import juloo.keyboard2.CandidatesView; public final class EditorConfig { @@ -27,10 +29,14 @@ public final class EditorConfig public boolean caps_initially_updated = false; /** CurrentlyTypedWord. */ - public CharSequence initial_text_before_cursor = null; + public CharSequence initial_text_before_cursor = null; // Might be [null]. public int initial_sel_start; public int initial_sel_end; + /** Suggestions. */ + // Doesn't override [_config.suggestions_enabled]. + public boolean should_show_candidates_view; + public EditorConfig() {} public void refresh(EditorInfo info, Resources res) @@ -72,9 +78,12 @@ public final class EditorConfig caps_initially_enabled = (info.initialCapsMode != 0); caps_initially_updated = caps_should_update_state(info); /* CurrentlyTypedWord */ - initial_text_before_cursor = info.getInitialTextBeforeCursor(10, 0); + if (VERSION.SDK_INT >= 30) + initial_text_before_cursor = info.getInitialTextBeforeCursor(10, 0); initial_sel_start = info.initialSelStart; initial_sel_end = info.initialSelEnd; + /* Suggestions */ + should_show_candidates_view = CandidatesView.should_show(info); } String actionLabel_of_imeAction(int action, Resources res) |
