mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 13:49:13 +00:00
allow selecting more icons in custom keys, update layouts.md
This commit is contained in:
parent
38228f8b70
commit
8f3e4fff8c
4 changed files with 29 additions and 5 deletions
|
@ -166,9 +166,7 @@ public final class KeySpecParser {
|
||||||
// See {@link #getCode(Resources, String)}.
|
// See {@link #getCode(Resources, String)}.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (outputText.isEmpty() && DebugFlags.DEBUG_ENABLED) {
|
// also empty output texts are acceptable
|
||||||
throw new KeySpecParserError("Empty outputText: " + keySpec);
|
|
||||||
}
|
|
||||||
return outputText;
|
return outputText;
|
||||||
}
|
}
|
||||||
final String label = getLabel(keySpec);
|
final String label = getLabel(keySpec);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import helium314.keyboard.latin.R;
|
import helium314.keyboard.latin.R;
|
||||||
|
import helium314.keyboard.latin.utils.ToolbarKey;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@ -95,6 +96,26 @@ public final class KeyboardIconsSet {
|
||||||
NAME_START_ONEHANDED_KEY, R.styleable.Keyboard_iconStartOneHandedMode,
|
NAME_START_ONEHANDED_KEY, R.styleable.Keyboard_iconStartOneHandedMode,
|
||||||
NAME_STOP_ONEHANDED_KEY, R.styleable.Keyboard_iconStopOneHandedMode,
|
NAME_STOP_ONEHANDED_KEY, R.styleable.Keyboard_iconStopOneHandedMode,
|
||||||
NAME_SWITCH_ONEHANDED_KEY, R.styleable.Keyboard_iconSwitchOneHandedMode,
|
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;
|
private static final int NUM_ICONS = NAMES_AND_ATTR_IDS.length / 2;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.widget.ImageView
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import helium314.keyboard.keyboard.KeyboardTheme
|
import helium314.keyboard.keyboard.KeyboardTheme
|
||||||
|
import helium314.keyboard.keyboard.internal.KeyboardIconsSet
|
||||||
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode
|
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode
|
||||||
import helium314.keyboard.latin.R
|
import helium314.keyboard.latin.R
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
|
@ -73,6 +74,7 @@ fun getCodeForToolbarKeyLongClick(key: ToolbarKey) = when (key) {
|
||||||
else -> KeyCode.UNSPECIFIED
|
else -> KeyCode.UNSPECIFIED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: get the icons from KeyboardIconsSet (but currently it's loaded too late)
|
||||||
private fun getStyleableIconId(key: ToolbarKey) = when (key) {
|
private fun getStyleableIconId(key: ToolbarKey) = when (key) {
|
||||||
VOICE -> R.styleable.Keyboard_iconShortcutKey
|
VOICE -> R.styleable.Keyboard_iconShortcutKey
|
||||||
SETTINGS -> R.styleable.Keyboard_iconSettingsKey
|
SETTINGS -> R.styleable.Keyboard_iconSettingsKey
|
||||||
|
|
|
@ -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
|
* _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
|
* _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)
|
* _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.
|
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
|
## 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)
|
* You need a layout file in one of the formats above, and add it to [layouts](app/src/main/assets/layouts)
|
||||||
|
|
Loading…
Add table
Reference in a new issue