From 6c2a3e8b5fe4f0b1e2a433ec3069ae152746df21 Mon Sep 17 00:00:00 2001 From: Helium314 Date: Sun, 26 May 2024 14:43:37 +0200 Subject: [PATCH] add tab key --- .../keyboard/internal/keyboard_parser/floris/KeyCode.kt | 3 ++- .../keyboard/internal/keyboard_parser/floris/KeyLabel.kt | 1 + .../keyboard/internal/keyboard_parser/floris/TextKeyData.kt | 2 ++ .../java/helium314/keyboard/latin/inputlogic/InputLogic.java | 3 +++ layouts.md | 2 +- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyCode.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyCode.kt index 0982da41..20f224c1 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyCode.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyCode.kt @@ -138,6 +138,7 @@ object KeyCode { const val PAGE_DOWN = -10011 const val META = -10012 const val META_LOCK = -10013 // to be consistent with the CTRL/ALT(/FN LOCK codes, not sure whether this will be used + const val TAB = -10014 /** to make sure a FlorisBoard code works when reading a JSON layout */ fun Int.checkAndConvertCode(): Int = if (this > 0) this else when (this) { @@ -150,7 +151,7 @@ object KeyCode { // heliboard only SYMBOL_ALPHA, START_ONE_HANDED_MODE, STOP_ONE_HANDED_MODE, SWITCH_ONE_HANDED_MODE, SHIFT_ENTER, - ACTION_NEXT, ACTION_PREVIOUS, NOT_SPECIFIED, CLIPBOARD_COPY_ALL, PAGE_UP, PAGE_DOWN, META + ACTION_NEXT, ACTION_PREVIOUS, NOT_SPECIFIED, CLIPBOARD_COPY_ALL, PAGE_UP, PAGE_DOWN, META, TAB -> this // conversion diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyLabel.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyLabel.kt index 938f6598..8e0905d4 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyLabel.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyLabel.kt @@ -28,6 +28,7 @@ object KeyLabel { const val ALT = "alt" const val FN = "fn" const val META = "meta" + const val TAB = "tab" /** to make sure a FlorisBoard label works when reading a JSON layout */ // resulting special labels should be names of FunctionalKey enum, case insensitive diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/TextKeyData.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/TextKeyData.kt index 002fa7aa..42372c41 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/TextKeyData.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/TextKeyData.kt @@ -451,6 +451,7 @@ sealed interface KeyData : AbstractKeyData { KeyLabel.CURRENCY4 -> params.mLocaleKeyboardInfos.currencyKey.second[3] KeyLabel.CURRENCY5 -> params.mLocaleKeyboardInfos.currencyKey.second[4] KeyLabel.CTRL, KeyLabel.ALT, KeyLabel.FN, KeyLabel.META -> label.uppercase(Locale.US) + KeyLabel.TAB -> "!icon/tab_key|" else -> { if (label in toolbarKeyStrings) { "!icon/$label|" @@ -468,6 +469,7 @@ sealed interface KeyData : AbstractKeyData { KeyLabel.ALT -> KeyCode.ALT KeyLabel.FN -> KeyCode.FN KeyLabel.META -> KeyCode.META + KeyLabel.TAB -> KeyCode.TAB else -> { if (label in toolbarKeyStrings) { getCodeForToolbarKey(ToolbarKey.valueOf(label.uppercase(Locale.US))) diff --git a/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java b/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java index 808b5aa3..85b0f891 100644 --- a/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java +++ b/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java @@ -773,6 +773,9 @@ public final class InputLogic { case KeyCode.PAGE_DOWN: sendDownUpKeyEvent(KeyEvent.KEYCODE_PAGE_DOWN); break; + case KeyCode.TAB: + sendDownUpKeyEvent(KeyEvent.KEYCODE_TAB); + break; case KeyCode.VOICE_INPUT: // switching to shortcut IME, shift state, keyboard,... is handled by LatinIME, // {@link KeyboardSwitcher#onEvent(Event)}, or {@link #onPressKey(int,int,boolean)} and {@link #onReleaseKey(int,boolean)}. diff --git a/layouts.md b/layouts.md index 19c3e584..efeb1768 100644 --- a/layouts.md +++ b/layouts.md @@ -90,7 +90,7 @@ Usually the label is what is displayed on the key. However, there are some speci * _space_: space key, with icon when using a number layout * _zwnj_: Zero-width non-joiner (automatically added next to space in alphabet layout for some languages) * You can also use [toolbar keys](/app/src/main/java/helium314/keyboard/latin/utils/ToolbarUtils.kt#L109), e.g. _undo_. - * See [KeyLabel.kt](app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyLabel.kt) for more available labels + * See [KeyLabel.kt](app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/KeyLabel.kt) for more available labels that are parsed to the corresponding key. * In case a label clashes with text you want to add, put a `\` in front of the text you want, e.g. `\space` will write the label `space` instead of adding a space bar. * Note that you need to escape the `\` in json files by adding a second `\`. * If you want different key label and input text, set the label to [label]|[text], e.g. `aa|bb` will show `aa`, but pressing the key will input `bb`.