diff options
| author | Jules Aguillon | 2022-04-03 17:15:12 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2022-04-03 17:15:12 +0200 |
| commit | aa78229b2aef963d5f840b72d8aa3cad3a78dfc4 (patch) | |
| tree | 4ea7950b7a62829890ba0e9dc1b8108b39dcc902 /srcs/juloo.keyboard2/Keyboard2.java | |
| parent | d62e7647e0feb9c3c7d363c50f31f1aaf101ecd0 (diff) | |
| download | unexpected-keyboard-aa78229b2aef963d5f840b72d8aa3cad3a78dfc4.tar.gz unexpected-keyboard-aa78229b2aef963d5f840b72d8aa3cad3a78dfc4.zip | |
Add the Programming Layout option
Allow specifying a layout for programming and add a key for switching to
it easily.
The switching key is placed on the top edge of the space bar.
The option has no effect by default because the ergonomic isn't ideal,
it needs to be enabled explicitly.
Users of Latin-script languages certainly prefer to use one layout (for
programming or not). This feature might be removed in favor of a better
language-switching mechanisms in the future.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 70c0892..abea412 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -139,6 +139,9 @@ public class Keyboard2 extends InputMethodService refreshSubtypeLayout(subtype); refreshAccentsOption(imm, subtype); } + _config.shouldOfferSwitchingToProgramming = + _config.programming_layout != -1 && + _currentTextLayout != _config.programming_layout; } private String actionLabel_of_imeAction(int action) @@ -276,11 +279,27 @@ public class Keyboard2 extends InputMethodService conn.performEditorAction(_config.actionId); } - public void setLayout(int res_id) + public void switchMain() { - if (res_id == -1) - res_id = _currentTextLayout; - _keyboardView.setKeyboard(getLayout(res_id)); + _keyboardView.setKeyboard(getLayout(_currentTextLayout)); + } + + public void switchNumeric() + { + _keyboardView.setKeyboard(getLayout(R.xml.numeric)); + } + + public void switchProgramming() + { + if (_config.programming_layout == -1) + return; + KeyboardData layout = + getLayout(_config.programming_layout).replaceKeys(key -> { + if (key != null && key.eventCode == KeyValue.EVENT_SWITCH_PROGRAMMING) + return KeyValue.getKeyByName("switch_text"); + return key; + }); + _keyboardView.setKeyboard(layout); } public void sendKeyEvent(int eventAction, int eventCode, int meta) |
