abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyEventHandler.java
AgeCommit message (Collapse)AuthorFilesLines
7 daysEmoji suggestion (#1235)Jules Aguillon1-2/+2
Suggest an emoji in addition to the 3 suggested words when the current word matches an alias in the emoji dictionary, if available.
2026-04-16Autocorrect middle word (#1242)Jules Aguillon1-14/+19
* Fix crash when typing space in the middle of a word * Don't trigger autocorrect when the cursor is not at the end of a word This prevented from editing a word that was already typed. * Don't undo autocorrect at the wrong time Backspace was trying to undo autocorrect even after some other action were done after the last autocorrect. This ensures that the keyboard remembers accurately the last action.
2026-04-12Better spell check with cursor in the middle of a word (#1233)Jules Aguillon1-4/+6
* Better spell check with cursor in the middle of a word Suggestions are based on the entire word and no longer the part of the word just before the cursor. Also, tapping a suggestion or the space bar autocorrect replaces the entire word. * Reduce the number of calls to refresh_current_word While the cursor moves, calls to refresh_current_word are now only done when the cursor exits the current word.
2026-04-12Insert a space when undoing autocorrect (#1232)Jules Aguillon1-1/+2
This prevents the same suggestions to be presented again and autocorrect to be activated again when pressing space. This extra space is wanted because pressing the spacebar triggered autocorrect in the first place.
2026-04-10Refresh suggestions immediately after language switch (#1229)Jules Aguillon1-0/+6
* Switch dictionary when language changes The dictionary was otherwise updated by closing and opening the keyboard again. * Refresh suggestions immediately after language switch
2026-04-10Disable spacebar autocomplete when suggestions are hidden (#1227)Jules Aguillon1-0/+1
The spacebar autocomplete option was still working even when the suggestions strip was correctly hidden in applications like Termux.
2026-02-19Autocomplete on space bar and undo on delete (#1179)Jules Aguillon1-7/+50
* Refactor: Implement the space key as an editing action The space key is no longer a CHAR key but now an EDITING key. This allows changing the behavior of the space bar while allowing custom layout users to define a key outputing a space as before. KeyModifier and ComposeKey are updated to treat the space key as before. * Enter the best suggestion when the space bar is pressed * Refactor: Implement backspace as an editing action * Undo suggestion when delete is pressed The delete key (backspace internally) undoes the suggestion if the last action done was entering the suggestion with either the space bar or the candidates view. * Add an option to enable space bar autocomplete This option is off by default. Undoing a completion with backspace works in any case. * Refactor: Track selection emptyness in CurrentlyTypedWord This removes an expensive RPC call.
2026-02-02Spell checking (#1137)Jules Aguillon1-2/+2
This adds dictionary-based spell checking to the keyboard. The keyboard looks at the word being typed and matches it against a dictionary to either complete the rest of the word or find alternative spellings. The core of this feature is implemented in cdict, which is included as a submodule in vendor/cidct. Cdict is developped at https://github.com/Julow/cdict The dictionaries are hosted at https://github.com/Julow/Unexpected-Keyboard-dictionaries/ The wordlists used to build the dictionaries are the same ones used by HeliBoard from https://codeberg.org/Helium314/aosp-dictionaries - Add an activity accessible from the launcher app that lists available dictionaries with a download button. The DictionaryListView view shows the list of available dictionaries and handles downloading and installing them. - The Dictionaries class manages installed dictionaries. Dictionaries are installed as individual files into the app's private directory. - Available dictionaries are listed in dictionaries.xml, which is generated when building Unexpected-Keyboard-dictionaries. method.xml mentions the dictionary name for each locales.
2026-02-01Candidates view improvements (#1168)Jules Aguillon1-1/+2
* Refactor: Create subpackage 'suggestions' * Candidates view: Status message when no dictionary installed Show a message on the candidates view instead of leaving it empty. A button points to the dictionary installation activity. * Add an option to disable the suggestions * Refactor: Remove Config.should_show_candidates_view This was moved to EditorConfig. * Don't disable text suggestions in some text boxes * Suggestion text size matching settings The candidates view height is based on the height of keyboard rows and the suggestion text size is based on the size of labels on the keys. This is influenced by symbol size and keyboard height options.
2026-01-31Avoid loops in modmaps (#1167)Jules Aguillon1-1/+1
It was possible to define a loop that would crash the app with the following modmap: <ctrl a="left" b="left:ctrl,left"/> With this change, modmap are not taken into account while evaluating macros. The modmap above modifies ctrl+left into ctrl+left.
2025-12-28Fix CurrentlyTypedWord counting the first letter twiceJules Aguillon1-3/+1
2025-12-28CurrentlyTypedWord: Handle key eventsJules Aguillon1-2/+6
Currently, refreshing the current word on each key event. Refreshing is done after a short delay, to ensure the editor has handled the event.
2025-12-28Enter the suggestion when it's pressedJules Aguillon1-1/+14
The current word is replaced by the pressed suggestion.
2025-12-28Track the currently typed wordJules Aguillon1-5/+20
The `CurrentlyTypedWord` class tracks the word that is being typed. It's implemented on the same model as Autocapitalisation and avoid expensive IPC calls when possible. The `Suggestions` class is where the suggestion lookup should go. It currently just echoes the current word.
2025-12-28Candidates viewJules Aguillon1-0/+6
The `CandidatesView` is implemented as a `LinearLayout` that is divided horizontally with up to 3 `TextView`. It might in the future contain buttons on the sides. The candidate view is nested into the input view rather than using Android's `setCandidatesView` and callbacks as the API is unreliable and complicated. The first suggestion goes in the middle to be more accessible. The second suggestion goes on the right to be more accessible to the right-handed, because it must go somewhere.
2025-12-22Fix various linting issues (#1146)Jules Aguillon1-1/+1
2025-12-18Disable selection mode in text editors (#1141)Jules Aguillon1-16/+4
* Disable selection mode in text editors Selection mode removes the space bar key (which is replaced by the Esc key) and can be annoying in Emacs for example. Text editor users probably have the `esc` key available. * Refactor: Move EditorInfo related code to EditorConfig Add the new EditorConfig class that handles configuration extracted from the EditorInfo. It is accessible from the Config class for convenience. This aims at reducing the length of already large classes and group the code that was spread over several classes.
2025-07-06Workaround Godot editor not implementing setSelection() (#1033)Jules Aguillon1-6/+12
This was tested against: org.godotengine.editor.v3 org.godotengine.editor.v4
2025-06-21cut and copy with built in keys only if text is selected (#1019)alotbsol5551-2/+9
cut and copy with built in keys only if text is selected to keep existing clipboard content. does not work for key combinations like ctrl+x or ctrl+c.
2025-06-19Improve selection mode when selection ends cross (#1013)Jules Aguillon1-9/+27
Emptying the selection with the spacebar slider puts the selection mode in an unexpected state. This checks that this doesn't happen. The selection ends can now cross each other, reversing the selection order. Special care is made to make sure that the sliders go in the expected direction. Pointers is changed to send a `onPointerDown` for the first slider event instead of a `onPointerHold`. This event is detected in `KeyEventHandler` and the selection ends are reordered if needed when sliding again.
2025-03-15Selection mode (#913)Jules Aguillon1-13/+62
* Selection mode: Space to cancel the selection This adds the "selection mode", which is activated when text is selected in the text box. The selection mode is exited when the selection is cleared. While the selection mode is activated, the Space and Esc keys are modified into the "selection cancel" key, which remove the selection without changing the text. The space bar is otherwise easy to type by accident during a selection and causes the selected text to be deleted. * Selection mode: Move each ends of selection separately with slider When the selection mode is activated, the space bar sliders change how they affect the selection: - The left side of the slider moves the left position of the selection. To shrink the selection from the left side, the slider must be activated by sliding to the left, extending the selection temporarilly, then by sliding to the right. - The right side of the slider affects the right position if the selection.
2025-03-10Add a delay after a Keyevent key in a macro (#918)Jules Aguillon1-13/+56
* Construct a single handler * Add a delay after a Keyevent key in a macro Add a delay before sending the next key to avoid race conditions causing keys to be handled in the wrong order. Notably, KeyEvent keys handling is scheduled differently than the other edit functions.
2025-03-01Add 'delete_word' and 'forward_delete_word' keysJules Aguillon1-10/+15
These keys are the equivalent of ctrl+backspace and ctrl+delete, respectively. They can be reached with Gesture+backspace and Gesture+delete respectively.
2025-02-28Refactor: Remove StringWithSymbolJules Aguillon1-1/+0
It's replaced with a macro containing one key.
2025-02-23Macro keys (#878)Jules Aguillon1-3/+31
Add "macro" keys that behave as if a sequence of keys is typed. Macro can be added to custom layouts or through the "Add keys to the keyboard option". The syntax is: symbol:key1,key2,.. The symbol cannot contain a : character. 'key1', 'key2', etc.. are: - 'String with \' escaping' The key will generate the specified string. - keyevent:123 The key will send a keyevent. - The name of any special key
2025-01-25Fix Enter key sending message in DiscordJules Aguillon1-1/+4
Set the flag FLAG_SOFT_KEYBOARD when sending key events stops Discord from sending message when typing Enter. The other values are the same that are sent when using sendDownUpKeyEvents().
2025-01-12Refactor: KeyValue: Simplify StringWithSymbolJules Aguillon1-11/+1
This removes the Complex key kind and class by making StringWithSymbol a new kind of key.
2025-01-12Add cursor_up and cursor_down slider keysJules Aguillon1-34/+41
Implement up and down cursor movement slider. This is not added to any layout yet due to the undesirable behavior when moving the focus out of the text box being edited.
2025-01-11Refactor: Restrict sliders to new 'Slider' key kindJules Aguillon1-1/+10
Setting 'slider="true"' on a key is no longer enough to make a slider, the key must also be of kind 'Slider'. Only the KeyValue that started sliding is now considered, they can be generated with negative values. This allows keys that don't have the complementary cursor movement key on the opposite direction. This will help implement other kind of sliders as well as up/down sliders.
2024-11-17Disable automatic Shift when pressing ComposeJules Aguillon1-1/+4
2024-09-29Add complex keys (#774)Jules Aguillon1-0/+11
This allows to add new kinds of keys that need more data without making KeyValue's footprint bigger for common keys. This changes the [_symbol] field into [_payload], which holds the same as the previous field for more common keys but can hold bigger objects for keys of the new "Complex" kind. This also adds a complex key: String keys with a symbol different than the outputted string. Unit tests are added as the Java language is not helpful in making robust code.
2024-07-06Clipboard pane (#681)Jules Aguillon1-1/+9
This adds the clipboard pane, which allows to save an arbitrary number of clipboards and to paste them later. The key can be disabled in settings. Checking the "Recently copied text" checkbox will cause the keyboard to keep a temporary history of copied text. This history can only contain 3 elements which expire after 5 minutes. If this is unchecked, no history is collected. History entries can be pinned into the persisted list of pins.
2024-05-02More precise and faster spacebar slider (#593)Jules Aguillon1-2/+1
* Make slider speed independent from swipe distance Swipe distances other than the default resulted in a slider that were not easy to control. * refactor: Add class Pointers.Sliding It holds the states and the code needed to make the slider work. 'Pointer.sliding' is set to [null] when sliding is not in progress. The implementation is changed not to depend on [downX] and [dx] but instead use the pointer's [x] coordinate directly. * Move the cursor further for faster slides In sliding mode, compute the speed of the pointer and use it to increase at which the cursor moves. * refactor: Separate kind for cursor movement keys This allows to define a key that moves the cursor more than one position at a time. This will be used to avoid lag during fast slider movements. * Reduce lag when sliding quickly on the spacebar Avoid sending key events in a loop while sliding quickly in a cursor movement key. Key of kind Cursor_move are "multiplied", meaning a single key event represents a movement of more than one position, reducing the number of key events sent. This is only for cursor move keys.
2024-03-18refactor: Implement Compose without global stateJules Aguillon1-4/+0
Thanks to the previous commit, a modifier key can now be more complex than just a KeyValue.Modifier. This allows a more elegant implementation of the compose key, that could be taken as a base for other features (eg. unicode hex entry, hangul) The COMPOSE_PENDING modifier is removed as keys of kind Compose_pending can act as a modifier. This has the advantage of highlighting the key that was last pressed in the sequence. Rules are added to Pointers: Non-special but latchable keys must clear latches and cannot be locked with a long press. These rules were not needed before but were intended.
2024-03-18refactor: Allow modifier of other key kindsJules Aguillon1-16/+21
Allow keys of a kind other than Modifier to be a modifier. This requires writing a compareTo function for KeyValue. Fields are compared in this order: Kind, value, flags, symbol.
2024-03-18refactor: Use Pointers.Modifiers.has lessJules Aguillon1-6/+5
The performance characteristics of this function will change in future plans.
2024-02-17Compose keyJules Aguillon1-0/+8
The COMPOSE_PENDING modifier indicate whether a compose sequence is in progress. The new key of kind Compose_pending sets the current state of the sequence. The compose sequences are compiled into a state machine by a python script into a compact encoding. The state of the pending compose is determined by the index of a state.
2024-02-10Fix various linter warningsJules Aguillon1-0/+2
Among others: - Use `apply` instead of `commit` when saving shared preferences. - Avoid inlined Api - Remove unused resources
2024-02-04Workaround cursor slider bug in AcodeJules Aguillon1-3/+15
Moving the cursor with setSelection has no effect on Acode, for which the fallback must be used.
2024-01-26Send down event for modifiers on timeJules Aguillon1-38/+77
This allows to use modifiers in combination with other inputs like a mouse click, for example under termux-x11. The key down event and notification about modifiers changing are sent down to KeyEventHandler. A mutable state remember for which modifier down events have been sent. When pressing down a modifier with one finger and typing with the other, it might appear that the modifier is released after the first time an other key is pressed and then pressed and released for the following keys. This prevents unintentionally type two modified keys instead of one when the second key is pressed while the other is not yet released.
2024-01-13Refactor: New namespace for preference classesJules Aguillon1-1/+1
2023-08-26Fix regression on Ctrl on space bar sliderJules Aguillon1-2/+8
This makes Ctrl+move_cursor the same as before 5123ce5.
2023-08-26Disable automatically Shift when pressing CtrlJules Aguillon1-0/+23
Automatic capitalisation might interferes with keyboard shortcuts.
2023-08-17Fix slider movements changing input focusJules Aguillon1-28/+88
The slider was repeatedly sending arrow keys, which change the focused input when the end of a text box is hit. A new key is added that implements cursor movements using the `InputConnection` API. The new keys are defined as `KeyValue.Editing`, which are no longer only context menu actions. The behavior when a selection has started is changed. The selection is modified instead of cleared even when shift isn't pressed or the selection would become empty. Fallbacks to sending arrow keys for editors that do not support the API, like Termux.
2023-06-03Refactor: Handle Event keys in Keyboard2Jules Aguillon1-40/+2
The `KeyEventHandler` class is intended to handle every keys and to call into the main class through a limited API. However, this is not true for `Event` keys, which in practice had each a corresponding API call.
2023-06-03Add Voice Typing keyJules Aguillon1-0/+2
The new key switches to any installed "voice" input method. If several input methods matches, no effort is made to choose. Might misbehave with some input methods other than Google's on API < 28. It is placed on the middle of the arrows on the bottom bar. It is enabled by default and can be removed in the "Extra keys" option. The key is not removed from the keyboard if no voice input method exists.
2023-02-12Option to switch to the previous input methodJules Aguillon1-2/+4
A new option changes the "change_method" into the new "change_method_prev". It switch to the previously used input method. A long press on "change_method_prev" sends "change_method". A new section is added in the settings and existing options are moved.
2023-01-30Modification step for the special layoutJules Aguillon1-12/+15
Refactor, follow up of 90b7944. Add a modification step to the "special" layouts: numpad, greekmath, pin entry. Remove the apply_key0 function, which is not expressive enough. Add an enum instead of yet an other "switch_" function.
2023-01-15Avoid switching back from secondary layout automaticallyJules Aguillon1-2/+3
Stay on the secondary layout after a config refresh or onStartInputView. The information is kept until the keyboard is restarted. Additionally, move tweaking the secondary layout to the Config class now that physical equality is not needed.
2022-12-30Add keys for every context menu actionsJules Aguillon1-7/+20
The most requested keys are undo and redo. Unfortunatly redo doesn't work reliably. The other context menu actions like share, assist and autofill are added even thought they are rarely useful or implemented.