diff options
| author | Jules Aguillon | 2026-02-19 00:35:14 +0100 |
|---|---|---|
| committer | GitHub | 2026-02-19 00:35:14 +0100 |
| commit | ebf80415d8034d853bd79ba7cfb578db67862529 (patch) | |
| tree | 6c437e8130edace1fb1efc03b7a79dc1e5214b57 /srcs/juloo.keyboard2/EditorConfig.java | |
| parent | 1cd252f8fa7b7b776c8b86f0c4e4357c46b5693b (diff) | |
| download | unexpected-keyboard-ebf80415d8034d853bd79ba7cfb578db67862529.tar.gz unexpected-keyboard-ebf80415d8034d853bd79ba7cfb578db67862529.zip | |
Refactor: KeyValue constants (#1180)
* Refactor: KeyValue constants
Add constants for keys that are accessed from the app's code. This
simplifies the fake pointer handling in Keyboard2View.
* Refactor: Pre-compute action key replacement
The action key and the enter swap are pre-computed in EditorConfig. This
simplifies the code.
Diffstat (limited to 'srcs/juloo.keyboard2/EditorConfig.java')
| -rw-r--r-- | srcs/juloo.keyboard2/EditorConfig.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/srcs/juloo.keyboard2/EditorConfig.java b/srcs/juloo.keyboard2/EditorConfig.java index 67b7799..a198775 100644 --- a/srcs/juloo.keyboard2/EditorConfig.java +++ b/srcs/juloo.keyboard2/EditorConfig.java @@ -9,10 +9,12 @@ import juloo.keyboard2.suggestions.CandidatesView; public final class EditorConfig { - public String actionLabel = null; // Might be [null] - /** Action performed by the Action key. Only when [actionLabel != null]. */ + /** Key that replaces the "ACTION" key. Might be [null] to remove that key. */ + public KeyValue action_key_replacement = null; + /** Key that replaces the "ENTER" key. Might be [null] to not replace the + enter key. */ + public KeyValue enter_key_replacement = null; public int actionId; - public boolean swapEnterActionKey = false; // Swap the "enter" and "action" keys /** Whether selection mode turns on automatically when text is selected. */ public boolean selection_mode_enabled = true; /** Whether the numeric layout should be shown by default. */ @@ -46,18 +48,29 @@ public final class EditorConfig /* Selection mode. Editors with [TYPE_NULL] are for example Termux and Emacs. */ selection_mode_enabled = inputType != InputType.TYPE_NULL; + enter_key_replacement = null; /* Action key. Looks at [info.actionLabel] first. */ if (info.actionLabel != null) { - actionLabel = info.actionLabel.toString(); actionId = info.actionId; - swapEnterActionKey = false; + action_key_replacement = + KeyValue.makeActionKey(info.actionLabel.toString()); } else { actionId = options & EditorInfo.IME_MASK_ACTION; - actionLabel = actionLabel_of_imeAction(actionId, res); - swapEnterActionKey = (options & EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0; + String label = actionLabel_of_imeAction(actionId, res); + action_key_replacement = null; + if (label != null) + { + action_key_replacement = KeyValue.makeActionKey(label); + // Swap the enter and action keys + if ((options & EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0) + { + enter_key_replacement = action_key_replacement; + action_key_replacement = KeyValue.ENTER; + } + } } /* Numeric layout */ switch (inputType) |
