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 ff8d60b..9ea1660 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt @@ -211,7 +211,7 @@ class MyKeyboard { a.recycle() a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard_Key) - code = a.getInt(R.styleable.MyKeyboard_Key_codes, 0) + code = a.getInt(R.styleable.MyKeyboard_Key_code, 0) popupCharacters = a.getText(R.styleable.MyKeyboard_Key_popupCharacters) popupResId = a.getResourceId(R.styleable.MyKeyboard_Key_popupKeyboard, 0) 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 e214dfe..e9d34d7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt @@ -82,13 +82,13 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL } } - override fun onKey(primaryCode: Int, keyCodes: IntArray?) { + override fun onKey(code: Int) { val inputConnection = currentInputConnection if (keyboard == null || inputConnection == null) { return } - when (primaryCode) { + when (code) { MyKeyboard.KEYCODE_DELETE -> { if (keyboard!!.mShiftState == SHIFT_ON_ONE_CHAR) { keyboard!!.mShiftState = SHIFT_OFF @@ -141,21 +141,21 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL keyboardView!!.setKeyboard(keyboard!!) } else -> { - var code = primaryCode.toChar() - if (Character.isLetter(code) && keyboard!!.mShiftState > SHIFT_OFF) { - code = Character.toUpperCase(code) + var codeChar = code.toChar() + if (Character.isLetter(codeChar) && keyboard!!.mShiftState > SHIFT_OFF) { + codeChar = Character.toUpperCase(codeChar) } // If the keyboard is set to symbols and the user presses space, we usually should switch back to the letters keyboard. // However, avoid doing that in cases when the EditText for example requires numbers as the input. // We can detect that by the text not changing on pressing Space. - if (keyboardMode != KEYBOARD_LETTERS && primaryCode == MyKeyboard.KEYCODE_SPACE) { + if (keyboardMode != KEYBOARD_LETTERS && code == MyKeyboard.KEYCODE_SPACE) { val originalText = inputConnection.getExtractedText(ExtractedTextRequest(), 0).text - inputConnection.commitText(code.toString(), 1) + inputConnection.commitText(codeChar.toString(), 1) val newText = inputConnection.getExtractedText(ExtractedTextRequest(), 0).text switchToLetters = originalText != newText } else { - inputConnection.commitText(code.toString(), 1) + inputConnection.commitText(codeChar.toString(), 1) } if (keyboard!!.mShiftState == SHIFT_ON_ONE_CHAR && keyboardMode == KEYBOARD_LETTERS) { @@ -165,7 +165,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL } } - if (primaryCode != MyKeyboard.KEYCODE_SHIFT) { + if (code != MyKeyboard.KEYCODE_SHIFT) { updateShiftKeyState() } } 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 50cbe2c..dc0cbc8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -39,12 +39,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut /** * Send a key press to the listener. - * @param primaryCode this is the key that was pressed - * @param keyCodes the codes for all the possible alternative keys with the primary code being the first. If the primary key code is a single character - * such as an alphabet or number or symbol, the alternatives will include other characters that may be on the same key or adjacent keys. These codes - * are useful to correct for accidental presses of a key adjacent to the intended key. + * @param code this is the key that was pressed */ - fun onKey(primaryCode: Int, keyCodes: IntArray?) + fun onKey(code: Int) /** * Called when the finger has been lifted after pressing a key @@ -555,7 +552,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut val codes = IntArray(MAX_NEARBY_KEYS) Arrays.fill(codes, NOT_A_KEY) getKeyIndices(x, y, codes) - mOnKeyboardActionListener!!.onKey(key.code, codes) + mOnKeyboardActionListener!!.onKey(key.code) mLastTapTime = eventTime } } @@ -785,8 +782,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mMiniKeyboard = mMiniKeyboardContainer!!.findViewById(R.id.mini_keyboard_view) as MyKeyboardView mMiniKeyboard!!.mOnKeyboardActionListener = object : OnKeyboardActionListener { - override fun onKey(primaryCode: Int, keyCodes: IntArray?) { - mOnKeyboardActionListener!!.onKey(primaryCode, keyCodes) + override fun onKey(primaryCode: Int) { + mOnKeyboardActionListener!!.onKey(primaryCode) dismissPopupKeyboard() } @@ -962,7 +959,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { mMiniKeyboard?.mKeys?.firstOrNull { it.focused }?.apply { - mOnKeyboardActionListener!!.onKey(code, intArrayOf(code)) + mOnKeyboardActionListener!!.onKey(code) } mMiniKeyboardSelectedKeyIndex = -1 dismissPopupKeyboard() diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index aea9af9..79cbc9e 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -14,8 +14,8 @@ - - + + diff --git a/app/src/main/res/xml/keys_letters.xml b/app/src/main/res/xml/keys_letters.xml index 6ca2615..1f5409a 100644 --- a/app/src/main/res/xml/keys_letters.xml +++ b/app/src/main/res/xml/keys_letters.xml @@ -2,62 +2,62 @@ diff --git a/app/src/main/res/xml/keys_symbols.xml b/app/src/main/res/xml/keys_symbols.xml index e4ac31c..fe9854c 100755 --- a/app/src/main/res/xml/keys_symbols.xml +++ b/app/src/main/res/xml/keys_symbols.xml @@ -2,101 +2,101 @@ diff --git a/app/src/main/res/xml/keys_symbols_shift.xml b/app/src/main/res/xml/keys_symbols_shift.xml index 5c14748..994256d 100755 --- a/app/src/main/res/xml/keys_symbols_shift.xml +++ b/app/src/main/res/xml/keys_symbols_shift.xml @@ -2,101 +2,101 @@