From 9dc7abaaa7899de8300fc8ec47816665044386e4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 15 Jan 2022 21:02:38 +0100 Subject: [PATCH] adding the alternative symbol keyboards --- .../keyboard/helpers/MyKeyboard.kt | 2 +- .../keyboard/services/SimpleKeyboardIME.kt | 3 +- .../keyboard/views/MyKeyboardView.kt | 2 +- .../xml/{keys_layout.xml => keys_letters.xml} | 8 +- app/src/main/res/xml/keys_symbols.xml | 134 ++++++++++++++++++ app/src/main/res/xml/keys_symbols_shift.xml | 134 ++++++++++++++++++ 6 files changed, 278 insertions(+), 5 deletions(-) rename app/src/main/res/xml/{keys_layout.xml => keys_letters.xml} (97%) create mode 100755 app/src/main/res/xml/keys_symbols.xml create mode 100755 app/src/main/res/xml/keys_symbols_shift.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt index 4a5633d1..232c8bd0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt @@ -312,7 +312,7 @@ class MyKeyboard { text = a.getText(R.styleable.MyKeyboard_Key_keyOutputText) topSmallNumber = a.getString(R.styleable.MyKeyboard_Key_topSmallNumber) ?: "" - if (label.isNotEmpty()) { + if (label.isNotEmpty() && codes.firstOrNull() != KEYCODE_MODE_CHANGE) { codes = arrayListOf(label[0].toInt()) } a.recycle() diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt index edac81a4..7dcc8ca7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt @@ -22,7 +22,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL override fun onCreateInputView(): View { keyboardView = layoutInflater.inflate(R.layout.keyboard_view_keyboard, null) as MyKeyboardView - keyboard = MyKeyboard(this, R.xml.keys_layout) + keyboard = MyKeyboard(this, R.xml.keys_letters) keyboardView!!.setKeyboard(keyboard!!) keyboardView!!.onKeyboardActionListener = this return keyboardView!! @@ -66,6 +66,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL keyboardView!!.invalidateAllKeys() } MyKeyboard.KEYCODE_DONE -> inputConnection.sendKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER)) + MyKeyboard.KEYCODE_MODE_CHANGE -> {} else -> { var code = primaryCode.toChar() if (Character.isLetter(code) && keyboard!!.shiftState > SHIFT_OFF) { diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt index 2eee30a7..2b373e24 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -879,7 +879,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mPopupPreviewY += popupHeight } - if (key.label.isNotEmpty()) { + if (key.label.isNotEmpty() && key.codes.firstOrNull() != KEYCODE_MODE_CHANGE) { if (previewPopup.isShowing) { previewPopup.update(mPopupPreviewX, mPopupPreviewY, popupWidth, popupHeight) } else { diff --git a/app/src/main/res/xml/keys_layout.xml b/app/src/main/res/xml/keys_letters.xml similarity index 97% rename from app/src/main/res/xml/keys_layout.xml rename to app/src/main/res/xml/keys_letters.xml index b683ce95..4c0edec0 100644 --- a/app/src/main/res/xml/keys_layout.xml +++ b/app/src/main/res/xml/keys_letters.xml @@ -151,15 +151,19 @@ + + app:keyWidth="45%p" /> diff --git a/app/src/main/res/xml/keys_symbols.xml b/app/src/main/res/xml/keys_symbols.xml new file mode 100755 index 00000000..a6172ded --- /dev/null +++ b/app/src/main/res/xml/keys_symbols.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/xml/keys_symbols_shift.xml b/app/src/main/res/xml/keys_symbols_shift.xml new file mode 100755 index 00000000..74d07dd9 --- /dev/null +++ b/app/src/main/res/xml/keys_symbols_shift.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +