Added delay for fast typing
This commit is contained in:
parent
7b80307abd
commit
dc1972a096
2 changed files with 11 additions and 8 deletions
|
@ -179,7 +179,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
when {
|
when {
|
||||||
originalText != null && originalText.isNotEmpty() && cachedVNTelexData.isNotEmpty() -> {
|
!originalText.isNullOrEmpty() && cachedVNTelexData.isNotEmpty() -> {
|
||||||
val fullText = originalText.toString() + codeChar.toString()
|
val fullText = originalText.toString() + codeChar.toString()
|
||||||
val lastIndexEmpty = if (fullText.contains(" ")) {
|
val lastIndexEmpty = if (fullText.contains(" ")) {
|
||||||
fullText.lastIndexOf(" ")
|
fullText.lastIndexOf(" ")
|
||||||
|
|
|
@ -224,7 +224,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
override fun onAttachedToWindow() {
|
override fun onAttachedToWindow() {
|
||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
if (mHandler == null) {
|
if (mHandler == null) {
|
||||||
mHandler = object : Handler() {
|
mHandler = object : Handler(Looper.getMainLooper()) {
|
||||||
override fun handleMessage(msg: Message) {
|
override fun handleMessage(msg: Message) {
|
||||||
when (msg.what) {
|
when (msg.what) {
|
||||||
MSG_REMOVE_PREVIEW -> mPreviewText!!.visibility = INVISIBLE
|
MSG_REMOVE_PREVIEW -> mPreviewText!!.visibility = INVISIBLE
|
||||||
|
@ -800,7 +800,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun detectAndSendKey(index: Int, x: Int, y: Int, eventTime: Long) {
|
private fun detectAndSendKey(index: Int, x: Int, y: Int, eventTime: Long) {
|
||||||
if (index != NOT_A_KEY && index < mKeys.size) {
|
if (index != NOT_A_KEY && index in mKeys.indices) {
|
||||||
val key = mKeys[index]
|
val key = mKeys[index]
|
||||||
getPressedKeyIndex(x, y)
|
getPressedKeyIndex(x, y)
|
||||||
mOnKeyboardActionListener!!.onKey(key.code)
|
mOnKeyboardActionListener!!.onKey(key.code)
|
||||||
|
@ -1194,12 +1194,15 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
val newPointerY = me.getY(1).toInt()
|
val newPointerY = me.getY(1).toInt()
|
||||||
val secondKeyIndex = getPressedKeyIndex(newPointerX, newPointerY)
|
val secondKeyIndex = getPressedKeyIndex(newPointerX, newPointerY)
|
||||||
showPreview(secondKeyIndex)
|
showPreview(secondKeyIndex)
|
||||||
|
|
||||||
|
mHandler!!.postDelayed({
|
||||||
detectAndSendKey(secondKeyIndex, newPointerX, newPointerY, eventTime)
|
detectAndSendKey(secondKeyIndex, newPointerX, newPointerY, eventTime)
|
||||||
|
|
||||||
val secondKeyCode = mKeys.getOrNull(secondKeyIndex)?.code
|
val secondKeyCode = mKeys.getOrNull(secondKeyIndex)?.code
|
||||||
if (secondKeyCode != null) {
|
if (secondKeyCode != null) {
|
||||||
mOnKeyboardActionListener!!.onPress(secondKeyCode)
|
mOnKeyboardActionListener!!.onPress(secondKeyCode)
|
||||||
}
|
}
|
||||||
|
}, REPEAT_INTERVAL.toLong())
|
||||||
|
|
||||||
showPreview(NOT_A_KEY)
|
showPreview(NOT_A_KEY)
|
||||||
invalidateKey(mCurrentKey)
|
invalidateKey(mCurrentKey)
|
||||||
|
|
Loading…
Reference in a new issue