diff options
| author | Jules Aguillon | 2025-12-18 19:15:32 +0100 |
|---|---|---|
| committer | GitHub | 2025-12-18 19:15:32 +0100 |
| commit | 41777fdda61715a59be241f0be9a8e3385222888 (patch) | |
| tree | bcddb5a4a29af2caf37e1f565efcfbffdd6814be /srcs/juloo.keyboard2/KeyEventHandler.java | |
| parent | be0aa07a2a728509b6244e00247bfe2fff5c66e0 (diff) | |
| download | unexpected-keyboard-41777fdda61715a59be241f0be9a8e3385222888.tar.gz unexpected-keyboard-41777fdda61715a59be241f0be9a8e3385222888.zip | |
Disable selection mode in text editors (#1141)
* 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.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyEventHandler.java')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyEventHandler.java | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index 33089d9..21a60c1 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -3,10 +3,8 @@ package juloo.keyboard2; import android.annotation.SuppressLint; import android.os.Looper; import android.os.Handler; -import android.text.InputType; import android.view.KeyCharacterMap; import android.view.KeyEvent; -import android.view.inputmethod.EditorInfo; import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; @@ -38,10 +36,11 @@ public final class KeyEventHandler } /** Editing just started. */ - public void started(EditorInfo info) + public void started(Config conf) { - _autocap.started(info, _recv.getCurrentInputConnection()); - _move_cursor_force_fallback = should_move_cursor_force_fallback(info); + _autocap.started(conf, _recv.getCurrentInputConnection()); + _move_cursor_force_fallback = + conf.editor_config.should_move_cursor_force_fallback; } /** Selection has been updated. */ @@ -468,17 +467,6 @@ public final class KeyEventHandler return (conn.getSelectedText(0) != null); } - /** Workaround some apps which answers to [getExtractedText] but do not react - to [setSelection] while returning [true]. */ - boolean should_move_cursor_force_fallback(EditorInfo info) - { - // This catch Acode: which sets several variations at once. - if ((info.inputType & InputType.TYPE_MASK_VARIATION & InputType.TYPE_TEXT_VARIATION_PASSWORD) != 0) - return true; - // Godot editor: Doesn't handle setSelection() but returns true. - return info.packageName.startsWith("org.godotengine.editor"); - } - public static interface IReceiver { public void handle_event_key(KeyValue.Event ev); |
