mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-18 21:32:04 +00:00
Add paste key and slightly re-arrange toolbar keys (#945)
This commit is contained in:
parent
cc4d8cfedc
commit
0bd76de9d9
10 changed files with 67 additions and 31 deletions
|
@ -172,8 +172,8 @@ object KeyCode {
|
|||
fun Int.checkAndConvertCode(): Int = if (this > 0) this else when (this) {
|
||||
// working
|
||||
CURRENCY_SLOT_1, CURRENCY_SLOT_2, CURRENCY_SLOT_3, CURRENCY_SLOT_4, CURRENCY_SLOT_5, CURRENCY_SLOT_6,
|
||||
VOICE_INPUT, LANGUAGE_SWITCH, SETTINGS, DELETE, ALPHA, SYMBOL, EMOJI, CLIPBOARD, CLIPBOARD_CUT,
|
||||
UNDO, REDO, ARROW_DOWN, ARROW_UP, ARROW_RIGHT, ARROW_LEFT, CLIPBOARD_COPY, CLIPBOARD_SELECT_ALL,
|
||||
VOICE_INPUT, LANGUAGE_SWITCH, SETTINGS, DELETE, ALPHA, SYMBOL, EMOJI, CLIPBOARD, CLIPBOARD_CUT, UNDO,
|
||||
REDO, ARROW_DOWN, ARROW_UP, ARROW_RIGHT, ARROW_LEFT, CLIPBOARD_COPY, CLIPBOARD_PASTE, CLIPBOARD_SELECT_ALL,
|
||||
CLIPBOARD_SELECT_WORD, TOGGLE_INCOGNITO_MODE, TOGGLE_AUTOCORRECT, MOVE_START_OF_LINE, MOVE_END_OF_LINE,
|
||||
MOVE_START_OF_PAGE, MOVE_END_OF_PAGE, SHIFT, CAPS_LOCK, MULTIPLE_CODE_POINTS, UNSPECIFIED, CTRL, ALT,
|
||||
FN, CLIPBOARD_CLEAR_HISTORY,
|
||||
|
|
|
@ -199,12 +199,12 @@ class ClipboardHistoryManager(
|
|||
val binding = ClipboardSuggestionBinding.inflate(LayoutInflater.from(latinIME), parent, false)
|
||||
val textView = binding.clipboardSuggestionText
|
||||
textView.text = if (isClipSensitive(inputType)) "*".repeat(content.length) else content
|
||||
val clipIcon = latinIME.mKeyboardSwitcher.keyboard.mIconsSet.getIconDrawable(ToolbarKey.CLIPBOARD.name.lowercase())
|
||||
val clipIcon = latinIME.mKeyboardSwitcher.keyboard.mIconsSet.getIconDrawable(ToolbarKey.PASTE.name.lowercase())
|
||||
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(clipIcon, null, null, null)
|
||||
textView.setOnClickListener {
|
||||
dontShowCurrentSuggestion = true
|
||||
latinIME.onTextInput(content.toString())
|
||||
AudioAndHapticFeedbackManager.getInstance().performHapticAndAudioFeedback(KeyCode.NOT_SPECIFIED, it);
|
||||
AudioAndHapticFeedbackManager.getInstance().performHapticAndAudioFeedback(KeyCode.NOT_SPECIFIED, it)
|
||||
binding.root.isGone = true
|
||||
}
|
||||
val closeButton = binding.clipboardSuggestionClose
|
||||
|
|
|
@ -36,12 +36,21 @@ fun createToolbarKey(context: Context, keyboardAttr: TypedArray, key: ToolbarKey
|
|||
|
||||
fun getCodeForToolbarKey(key: ToolbarKey) = when (key) {
|
||||
VOICE -> KeyCode.VOICE_INPUT
|
||||
SETTINGS -> KeyCode.SETTINGS
|
||||
CLIPBOARD -> KeyCode.CLIPBOARD
|
||||
UNDO -> KeyCode.UNDO
|
||||
REDO -> KeyCode.REDO
|
||||
SETTINGS -> KeyCode.SETTINGS
|
||||
SELECT_ALL -> KeyCode.CLIPBOARD_SELECT_ALL
|
||||
SELECT_WORD -> KeyCode.CLIPBOARD_SELECT_WORD
|
||||
COPY -> KeyCode.CLIPBOARD_COPY
|
||||
CUT -> KeyCode.CLIPBOARD_CUT
|
||||
PASTE -> KeyCode.CLIPBOARD_PASTE
|
||||
ONE_HANDED -> if (Settings.getInstance().current.mOneHandedModeEnabled) KeyCode.STOP_ONE_HANDED_MODE else KeyCode.START_ONE_HANDED_MODE
|
||||
INCOGNITO -> KeyCode.TOGGLE_INCOGNITO_MODE
|
||||
AUTOCORRECT -> KeyCode.TOGGLE_AUTOCORRECT
|
||||
CLEAR_CLIPBOARD -> KeyCode.CLIPBOARD_CLEAR_HISTORY
|
||||
CLOSE_HISTORY -> KeyCode.ALPHA
|
||||
EMOJI -> KeyCode.EMOJI
|
||||
LEFT -> KeyCode.ARROW_LEFT
|
||||
RIGHT -> KeyCode.ARROW_RIGHT
|
||||
UP -> KeyCode.ARROW_UP
|
||||
|
@ -50,21 +59,19 @@ fun getCodeForToolbarKey(key: ToolbarKey) = when (key) {
|
|||
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
|
||||
EMOJI -> KeyCode.EMOJI
|
||||
}
|
||||
|
||||
fun getCodeForToolbarKeyLongClick(key: ToolbarKey) = when (key) {
|
||||
CLIPBOARD -> KeyCode.CLIPBOARD_PASTE
|
||||
UNDO -> KeyCode.REDO
|
||||
REDO -> KeyCode.UNDO
|
||||
SELECT_WORD -> KeyCode.CLIPBOARD_SELECT_ALL
|
||||
COPY -> KeyCode.CLIPBOARD_COPY_ALL
|
||||
PASTE -> KeyCode.CLIPBOARD
|
||||
LEFT -> KeyCode.WORD_LEFT
|
||||
RIGHT -> KeyCode.WORD_RIGHT
|
||||
UP -> KeyCode.PAGE_UP
|
||||
|
@ -73,22 +80,26 @@ fun getCodeForToolbarKeyLongClick(key: ToolbarKey) = when (key) {
|
|||
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
|
||||
SELECT_WORD -> KeyCode.CLIPBOARD_SELECT_ALL
|
||||
CLIPBOARD -> KeyCode.CLIPBOARD_PASTE
|
||||
else -> KeyCode.UNSPECIFIED
|
||||
}
|
||||
|
||||
fun getStyleableIconId(key: ToolbarKey) = when (key) {
|
||||
VOICE -> R.styleable.Keyboard_iconShortcutKey
|
||||
SETTINGS -> R.styleable.Keyboard_iconSettingsKey
|
||||
CLIPBOARD -> R.styleable.Keyboard_iconClipboardNormalKey
|
||||
UNDO -> R.styleable.Keyboard_iconUndo
|
||||
REDO -> R.styleable.Keyboard_iconRedo
|
||||
SETTINGS -> R.styleable.Keyboard_iconSettingsKey
|
||||
SELECT_ALL -> R.styleable.Keyboard_iconSelectAll
|
||||
SELECT_WORD -> R.styleable.Keyboard_iconSelectWord
|
||||
COPY -> R.styleable.Keyboard_iconCopyKey
|
||||
CUT -> R.styleable.Keyboard_iconCutKey
|
||||
PASTE -> R.styleable.Keyboard_iconPasteKey
|
||||
ONE_HANDED -> R.styleable.Keyboard_iconStartOneHandedMode
|
||||
INCOGNITO -> R.styleable.Keyboard_iconIncognitoKey
|
||||
AUTOCORRECT -> R.styleable.Keyboard_iconAutoCorrect
|
||||
CLEAR_CLIPBOARD -> R.styleable.Keyboard_iconClearClipboardKey
|
||||
CLOSE_HISTORY -> R.styleable.Keyboard_iconClose
|
||||
EMOJI -> R.styleable.Keyboard_iconEmojiNormalKey
|
||||
LEFT -> R.styleable.Keyboard_iconArrowLeft
|
||||
RIGHT -> R.styleable.Keyboard_iconArrowRight
|
||||
UP -> R.styleable.Keyboard_iconArrowUp
|
||||
|
@ -97,18 +108,10 @@ fun getStyleableIconId(key: ToolbarKey) = when (key) {
|
|||
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
|
||||
AUTOCORRECT -> R.styleable.Keyboard_iconAutoCorrect
|
||||
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
|
||||
}
|
||||
|
||||
fun getToolbarIconByName(name: String, context: Context): Drawable? {
|
||||
|
@ -122,7 +125,7 @@ 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, INCOGNITO,
|
||||
VOICE, CLIPBOARD, UNDO, REDO, SETTINGS, SELECT_ALL, SELECT_WORD, COPY, CUT, PASTE, 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
|
||||
}
|
||||
|
@ -130,7 +133,7 @@ enum class ToolbarKey {
|
|||
val toolbarKeyStrings = entries.associateWithTo(EnumMap(ToolbarKey::class.java)) { it.toString().lowercase(Locale.US) }
|
||||
|
||||
val defaultToolbarPref by lazy {
|
||||
val default = listOf(VOICE, CLIPBOARD, UNDO, REDO, SETTINGS, SELECT_ALL, SELECT_WORD, COPY, LEFT, RIGHT)
|
||||
val default = listOf(SETTINGS, VOICE, CLIPBOARD, UNDO, REDO, SELECT_WORD, COPY, PASTE, LEFT, RIGHT)
|
||||
val others = entries.filterNot { it in default || it == CLOSE_HISTORY }
|
||||
default.joinToString(";") { "${it.name},true" } + ";" + others.joinToString(";") { "${it.name},false" }
|
||||
}
|
||||
|
@ -140,7 +143,7 @@ val defaultPinnedToolbarPref = entries.filterNot { it == CLOSE_HISTORY }.joinToS
|
|||
}
|
||||
|
||||
val defaultClipboardToolbarPref by lazy {
|
||||
val default = listOf(ONE_HANDED, UNDO, UP, DOWN, LEFT, RIGHT, CLEAR_CLIPBOARD, COPY, CUT, SELECT_WORD, CLOSE_HISTORY)
|
||||
val default = listOf(CLEAR_CLIPBOARD, UP, DOWN, LEFT, RIGHT, UNDO, CUT, COPY, PASTE, SELECT_WORD, CLOSE_HISTORY)
|
||||
val others = entries.filterNot { it in default }
|
||||
default.joinToString(";") { "${it.name},true" } + ";" + others.joinToString(";") { "${it.name},false" }
|
||||
}
|
||||
|
|
13
app/src/main/res/drawable/sym_keyboard_paste.xml
Normal file
13
app/src/main/res/drawable/sym_keyboard_paste.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
icon available in Android Studio
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="#FFF"
|
||||
android:pathData="M19,2h-4.18C14.4,0.84 13.3,0 12,0c-1.3,0 -2.4,0.84 -2.82,2L5,2c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,4c0,-1.1 -0.9,-2 -2,-2zM12,2c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 -1,-1 0.45,-1 1,-1zM19,20L5,20L5,4h2v3h10L17,4h2v16z"/>
|
||||
</vector>
|
15
app/src/main/res/drawable/sym_keyboard_paste_rounded.xml
Normal file
15
app/src/main/res/drawable/sym_keyboard_paste_rounded.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-FileCopyrightText: Material Design Authors / Google LLC
|
||||
modified
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path android:fillColor="#FFF"
|
||||
android:pathData="M200,840Q167,840 143.5,816.5Q120,793 120,760L120,200Q120,167 143.5,143.5Q167,120 200,120L367,120Q378,85 410,62.5Q442,40 480,40Q520,40 551.5,62.5Q583,85 594,120L760,120Q793,120 816.5,143.5Q840,167 840,200L840,760Q840,793 816.5,816.5Q793,840 760,840L200,840ZM200,760L760,760Q760,760 760,760Q760,760 760,760L760,200Q760,200 760,200Q760,200 760,200L680,200L680,280Q680,297 668.5,308.5Q657,320 640,320L320,320Q303,320 291.5,308.5Q280,297 280,280L280,200L200,200Q200,200 200,200Q200,200 200,200L200,760Q200,760 200,760Q200,760 200,760ZM480,200Q497,200 508.5,188.5Q520,177 520,160Q520,143 508.5,131.5Q497,120 480,120Q463,120 451.5,131.5Q440,143 440,160Q440,177 451.5,188.5Q463,200 480,200Z"/>
|
||||
</vector>
|
|
@ -258,6 +258,7 @@
|
|||
<attr name="iconClipboardNormalKey" format="reference" />
|
||||
<attr name="iconCopyKey" format="reference" />
|
||||
<attr name="iconCutKey" format="reference" />
|
||||
<attr name="iconPasteKey" format="reference" />
|
||||
<attr name="iconClearClipboardKey" format="reference" />
|
||||
<attr name="iconStartOneHandedMode" format="reference" />
|
||||
<attr name="iconStopOneHandedMode" format="reference" />
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
<item name="iconClipboardNormalKey">@drawable/sym_keyboard_clipboard_holo</item>
|
||||
<item name="iconCopyKey">@drawable/sym_keyboard_copy</item>
|
||||
<item name="iconCutKey">@drawable/sym_keyboard_cut</item>
|
||||
<item name="iconPasteKey">@drawable/sym_keyboard_paste</item>
|
||||
<item name="iconClearClipboardKey">@drawable/sym_keyboard_clear_clipboard_holo</item>
|
||||
<item name="iconStartOneHandedMode">@drawable/sym_keyboard_start_onehanded_holo</item>
|
||||
<item name="iconStopOneHandedMode">@drawable/sym_keyboard_stop_onehanded_holo</item>
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
<item name="iconClipboardNormalKey">@drawable/sym_keyboard_clipboard_lxx</item>
|
||||
<item name="iconCopyKey">@drawable/sym_keyboard_copy</item>
|
||||
<item name="iconCutKey">@drawable/sym_keyboard_cut</item>
|
||||
<item name="iconPasteKey">@drawable/sym_keyboard_paste</item>
|
||||
<item name="iconClearClipboardKey">@drawable/sym_keyboard_clear_clipboard_lxx</item>
|
||||
<item name="iconStartOneHandedMode">@drawable/sym_keyboard_start_onehanded_lxx</item>
|
||||
<item name="iconStopOneHandedMode">@drawable/sym_keyboard_stop_onehanded_lxx</item>
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
<item name="iconClipboardNormalKey">@drawable/sym_keyboard_clipboard_rounded</item>
|
||||
<item name="iconCopyKey">@drawable/sym_keyboard_copy_rounded</item>
|
||||
<item name="iconCutKey">@drawable/sym_keyboard_cut</item>
|
||||
<item name="iconPasteKey">@drawable/sym_keyboard_paste_rounded</item>
|
||||
<item name="iconClearClipboardKey">@drawable/sym_keyboard_clear_clipboard_rounded</item>
|
||||
<item name="iconStartOneHandedMode">@drawable/sym_keyboard_start_onehanded_rounded</item>
|
||||
<item name="iconStopOneHandedMode">@drawable/sym_keyboard_stop_onehanded_rounded</item>
|
||||
|
|
|
@ -242,8 +242,9 @@
|
|||
<!-- Title of the setting to set toolbar keys -->
|
||||
<string name="toolbar_keys">Select toolbar keys</string>
|
||||
<!-- Names of the toolbar keys-->
|
||||
<string name="paste" tools:keep="@string/paste" translatable="false">@android:string/paste</string>
|
||||
<string name="copy" tools:keep="@string/copy" translatable="false">@android:string/copy</string>
|
||||
<string name="cut" tools:keep="@string/cut">Cut</string>
|
||||
<string name="cut" tools:keep="@string/cut" translatable="false">@android:string/cut</string>
|
||||
<string name="clipboard" tools:keep="@string/clipboard">Clipboard</string>
|
||||
<string name="clear_clipboard" tools:keep="@string/clear_clipboard">Clear clipboard</string>
|
||||
<string name="voice" tools:keep="@string/voice">Voice input</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue