diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/KeySpecParser.java b/app/src/main/java/helium314/keyboard/keyboard/internal/KeySpecParser.java index 9eb0b82e..a8515c66 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/KeySpecParser.java +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/KeySpecParser.java @@ -166,9 +166,7 @@ public final class KeySpecParser { // See {@link #getCode(Resources, String)}. return null; } - if (outputText.isEmpty() && DebugFlags.DEBUG_ENABLED) { - throw new KeySpecParserError("Empty outputText: " + keySpec); - } + // also empty output texts are acceptable return outputText; } final String label = getLabel(keySpec); diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardIconsSet.java b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardIconsSet.java index 58b37559..9c669378 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardIconsSet.java +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardIconsSet.java @@ -16,6 +16,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import helium314.keyboard.latin.R; +import helium314.keyboard.latin.utils.ToolbarKey; import java.util.HashMap; @@ -95,6 +96,26 @@ public final class KeyboardIconsSet { NAME_START_ONEHANDED_KEY, R.styleable.Keyboard_iconStartOneHandedMode, NAME_STOP_ONEHANDED_KEY, R.styleable.Keyboard_iconStopOneHandedMode, NAME_SWITCH_ONEHANDED_KEY, R.styleable.Keyboard_iconSwitchOneHandedMode, + ToolbarKey.VOICE.name(), R.styleable.Keyboard_iconShortcutKey, + ToolbarKey.SETTINGS.name(), R.styleable.Keyboard_iconSettingsKey, + ToolbarKey.CLIPBOARD.name(), R.styleable.Keyboard_iconClipboardNormalKey, + ToolbarKey.SELECT_ALL.name(), R.styleable.Keyboard_iconSelectAll, + ToolbarKey.COPY.name(), R.styleable.Keyboard_iconCopyKey, + ToolbarKey.CUT.name(), R.styleable.Keyboard_iconCutKey, + ToolbarKey.ONE_HANDED.name(), R.styleable.Keyboard_iconStartOneHandedMode, + ToolbarKey.LEFT.name(), R.styleable.Keyboard_iconArrowLeft, + ToolbarKey.RIGHT.name(), R.styleable.Keyboard_iconArrowRight, + ToolbarKey.UP.name(), R.styleable.Keyboard_iconArrowUp, + ToolbarKey.DOWN.name(), R.styleable.Keyboard_iconArrowDown, + ToolbarKey.UNDO.name(), R.styleable.Keyboard_iconUndo, + ToolbarKey.REDO.name(), R.styleable.Keyboard_iconRedo, + ToolbarKey.INCOGNITO.name(), R.styleable.Keyboard_iconIncognitoKey, + ToolbarKey.AUTOCORRECT.name(), R.styleable.Keyboard_iconAutoCorrect, + ToolbarKey.CLEAR_CLIPBOARD.name(),R.styleable.Keyboard_iconClearClipboardKey, + ToolbarKey.FULL_LEFT.name(), R.styleable.Keyboard_iconFullLeft, + ToolbarKey.FULL_RIGHT.name(), R.styleable.Keyboard_iconFullRight, + ToolbarKey.SELECT_WORD.name(), R.styleable.Keyboard_iconSelectWord, + ToolbarKey.CLOSE_HISTORY.name(), R.styleable.Keyboard_iconClose, }; private static final int NUM_ICONS = NAMES_AND_ATTR_IDS.length / 2; diff --git a/app/src/main/java/helium314/keyboard/latin/utils/ToolbarUtils.kt b/app/src/main/java/helium314/keyboard/latin/utils/ToolbarUtils.kt index e584e4d7..672cb144 100644 --- a/app/src/main/java/helium314/keyboard/latin/utils/ToolbarUtils.kt +++ b/app/src/main/java/helium314/keyboard/latin/utils/ToolbarUtils.kt @@ -10,6 +10,7 @@ import android.widget.ImageView import androidx.appcompat.view.ContextThemeWrapper import androidx.core.content.edit import helium314.keyboard.keyboard.KeyboardTheme +import helium314.keyboard.keyboard.internal.KeyboardIconsSet import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode import helium314.keyboard.latin.R import helium314.keyboard.latin.settings.Settings @@ -73,6 +74,7 @@ fun getCodeForToolbarKeyLongClick(key: ToolbarKey) = when (key) { else -> KeyCode.UNSPECIFIED } +// todo: get the icons from KeyboardIconsSet (but currently it's loaded too late) private fun getStyleableIconId(key: ToolbarKey) = when (key) { VOICE -> R.styleable.Keyboard_iconShortcutKey SETTINGS -> R.styleable.Keyboard_iconSettingsKey diff --git a/layouts.md b/layouts.md index d3d59727..e7191082 100644 --- a/layouts.md +++ b/layouts.md @@ -86,9 +86,12 @@ Usually the label is what is displayed on the key. However, there are some speci * _comma_: `,` key with special popups, will adapt to language-specific comma, or display `/` in URL fields and `@` in email fields * _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) -* If you want different key label and use text, set the label to [label]|[text], e.g. `aa|bb` will show `aa`, but pressing the key will input `bb`. +* 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`. You can also specify special key codes like `a|!code/key_action_previous`, but it's cleaner to use a json layout and specify the code explicitly. Note that when specifying a code in the label, and a code in a json layout, the code in the label will be ignored. -It's also possible to specify an icon together with a code `!icon/previous_key|!code/key_action_previous`, but this is not fully supported yet. +* It's also possible to specify an icon, like `!icon/previous_key|!code/key_action_previous`. + * For normal keys, even if you specify a code, you will need to add a `|` to the label, e.g. `!icon/go_key|` or `!icon/go_key|ignored` (to be fixed). + * For popups keys, you must _not_ add a `|` (to be fixed). + * You can find available icon names in [KeyboardIconsSet](/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardIconsSet.java). You can also use toolbar key icons using the uppercase name of the toolbar key, e.g. `!icon/REDO` ## Adding new layouts / languages * You need a layout file in one of the formats above, and add it to [layouts](app/src/main/assets/layouts)