mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-20 00:40:29 +00:00
More cursor keys (#933)
This commit is contained in:
parent
e57e2e8de5
commit
bcf2a52d6a
23 changed files with 164 additions and 19 deletions
|
@ -46,12 +46,18 @@ fun getCodeForToolbarKey(key: ToolbarKey) = when (key) {
|
|||
RIGHT -> KeyCode.ARROW_RIGHT
|
||||
UP -> KeyCode.ARROW_UP
|
||||
DOWN -> KeyCode.ARROW_DOWN
|
||||
WORD_LEFT -> KeyCode.WORD_LEFT
|
||||
WORD_RIGHT -> KeyCode.WORD_RIGHT
|
||||
PAGE_UP -> KeyCode.PAGE_UP
|
||||
PAGE_DOWN -> KeyCode.PAGE_DOWN
|
||||
UNDO -> KeyCode.UNDO
|
||||
REDO -> KeyCode.REDO
|
||||
INCOGNITO -> KeyCode.TOGGLE_INCOGNITO_MODE
|
||||
AUTOCORRECT -> KeyCode.TOGGLE_AUTOCORRECT
|
||||
FULL_LEFT -> KeyCode.MOVE_START_OF_LINE
|
||||
FULL_RIGHT -> KeyCode.MOVE_END_OF_LINE
|
||||
PAGE_START -> KeyCode.MOVE_START_OF_PAGE
|
||||
PAGE_END -> KeyCode.MOVE_END_OF_PAGE
|
||||
SELECT_WORD -> KeyCode.CLIPBOARD_SELECT_WORD
|
||||
CLEAR_CLIPBOARD -> KeyCode.CLIPBOARD_CLEAR_HISTORY
|
||||
CLOSE_HISTORY -> KeyCode.ALPHA
|
||||
|
@ -59,10 +65,14 @@ fun getCodeForToolbarKey(key: ToolbarKey) = when (key) {
|
|||
}
|
||||
|
||||
fun getCodeForToolbarKeyLongClick(key: ToolbarKey) = when (key) {
|
||||
RIGHT -> KeyCode.MOVE_END_OF_LINE
|
||||
LEFT -> KeyCode.MOVE_START_OF_LINE
|
||||
LEFT -> KeyCode.WORD_LEFT
|
||||
RIGHT -> KeyCode.WORD_RIGHT
|
||||
UP -> KeyCode.PAGE_UP
|
||||
DOWN -> KeyCode.PAGE_DOWN
|
||||
WORD_LEFT -> KeyCode.MOVE_START_OF_LINE
|
||||
WORD_RIGHT -> KeyCode.MOVE_END_OF_LINE
|
||||
PAGE_UP -> KeyCode.MOVE_START_OF_PAGE
|
||||
PAGE_DOWN -> KeyCode.MOVE_END_OF_PAGE
|
||||
UNDO -> KeyCode.REDO
|
||||
REDO -> KeyCode.UNDO
|
||||
COPY -> KeyCode.CLIPBOARD_COPY_ALL
|
||||
|
@ -83,6 +93,10 @@ fun getStyleableIconId(key: ToolbarKey) = when (key) {
|
|||
RIGHT -> R.styleable.Keyboard_iconArrowRight
|
||||
UP -> R.styleable.Keyboard_iconArrowUp
|
||||
DOWN -> R.styleable.Keyboard_iconArrowDown
|
||||
WORD_LEFT -> R.styleable.Keyboard_iconWordLeft
|
||||
WORD_RIGHT -> R.styleable.Keyboard_iconWordRight
|
||||
PAGE_UP -> R.styleable.Keyboard_iconPageUp
|
||||
PAGE_DOWN -> R.styleable.Keyboard_iconPageDown
|
||||
UNDO -> R.styleable.Keyboard_iconUndo
|
||||
REDO -> R.styleable.Keyboard_iconRedo
|
||||
INCOGNITO -> R.styleable.Keyboard_iconIncognitoKey
|
||||
|
@ -90,6 +104,8 @@ fun getStyleableIconId(key: ToolbarKey) = when (key) {
|
|||
CLEAR_CLIPBOARD -> R.styleable.Keyboard_iconClearClipboardKey
|
||||
FULL_LEFT -> R.styleable.Keyboard_iconFullLeft
|
||||
FULL_RIGHT -> R.styleable.Keyboard_iconFullRight
|
||||
PAGE_START -> R.styleable.Keyboard_iconPageStart
|
||||
PAGE_END -> R.styleable.Keyboard_iconPageEnd
|
||||
SELECT_WORD -> R.styleable.Keyboard_iconSelectWord
|
||||
CLOSE_HISTORY -> R.styleable.Keyboard_iconClose
|
||||
EMOJI -> R.styleable.Keyboard_iconEmojiNormalKey
|
||||
|
@ -106,17 +122,17 @@ fun getToolbarIconByName(name: String, context: Context): Drawable? {
|
|||
|
||||
// names need to be aligned with resources strings (using lowercase of key.name)
|
||||
enum class ToolbarKey {
|
||||
VOICE, CLIPBOARD, UNDO, REDO, SETTINGS, SELECT_ALL, SELECT_WORD, COPY, CUT, ONE_HANDED, LEFT, RIGHT, UP, DOWN,
|
||||
FULL_LEFT, FULL_RIGHT, INCOGNITO, AUTOCORRECT, CLEAR_CLIPBOARD, CLOSE_HISTORY, EMOJI
|
||||
VOICE, CLIPBOARD, UNDO, REDO, SETTINGS, SELECT_ALL, SELECT_WORD, COPY, CUT, ONE_HANDED, INCOGNITO,
|
||||
AUTOCORRECT, CLEAR_CLIPBOARD, CLOSE_HISTORY, EMOJI, LEFT, RIGHT, UP, DOWN, WORD_LEFT, WORD_RIGHT,
|
||||
PAGE_UP, PAGE_DOWN, FULL_LEFT, FULL_RIGHT, PAGE_START, PAGE_END
|
||||
}
|
||||
|
||||
val toolbarKeyStrings = entries.associateWithTo(EnumMap(ToolbarKey::class.java)) { it.toString().lowercase(Locale.US) }
|
||||
|
||||
val defaultToolbarPref = entries.filterNot { it == CLOSE_HISTORY }.joinToString(";") {
|
||||
when (it) {
|
||||
INCOGNITO, AUTOCORRECT, UP, DOWN, ONE_HANDED, FULL_LEFT, FULL_RIGHT, CUT, CLEAR_CLIPBOARD, EMOJI -> "${it.name},false"
|
||||
else -> "${it.name},true"
|
||||
}
|
||||
val defaultToolbarPref by lazy {
|
||||
val default = listOf(VOICE, CLIPBOARD, UNDO, REDO, SETTINGS, SELECT_ALL, SELECT_WORD, COPY, LEFT, RIGHT)
|
||||
val others = entries.filterNot { it in default || it == CLOSE_HISTORY }
|
||||
default.joinToString(";") { "${it.name},true" } + ";" + others.joinToString(";") { "${it.name},false" }
|
||||
}
|
||||
|
||||
val defaultPinnedToolbarPref = entries.filterNot { it == CLOSE_HISTORY }.joinToString(";") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue