@@ -138,6 +138,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
138138 private var mLastKey = 0
139139 private var mLastCodeX = 0
140140 private var mLastCodeY = 0
141+ private var mLastKeyPressedCode = 0
141142 private var mCurrentKey: Int = NOT_A_KEY
142143 private var mLastKeyTime = 0L
143144 private var mCurrentKeyTime = 0L
@@ -263,6 +264,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
263264 val repeat = Message .obtain(this , MSG_REPEAT )
264265 sendMessageDelayed(repeat, REPEAT_INTERVAL .toLong())
265266 }
267+
266268 MSG_LONGPRESS -> openPopupIfRequired(msg.obj as MotionEvent )
267269 }
268270 }
@@ -591,7 +593,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
591593 label, (key.width / 2 ).toFloat(), key.height / 2 + (paint.textSize - paint.descent()) / 2 , paint
592594 )
593595
594- if (key.topSmallNumber.isNotEmpty()) {
596+ if (key.topSmallNumber.isNotEmpty() && ! context.config.showNumbersRow ) {
595597 canvas.drawText(key.topSmallNumber, key.width - mTopSmallNumberMarginWidth, mTopSmallNumberMarginHeight, smallLetterPaint)
596598 }
597599
@@ -1204,6 +1206,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
12041206 }
12051207 }
12061208 }
1209+
12071210 MotionEvent .ACTION_UP , MotionEvent .ACTION_CANCEL -> {
12081211 mMiniKeyboard?.mKeys?.firstOrNull { it.focused }?.apply {
12091212 mOnKeyboardActionListener!! .onKey(code)
@@ -1262,6 +1265,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
12621265 invalidateKey(mCurrentKey)
12631266 return true
12641267 }
1268+
12651269 MotionEvent .ACTION_DOWN -> {
12661270 mAbortKey = false
12671271 mLastCodeX = touchX
@@ -1278,8 +1282,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
12781282 } else {
12791283 0
12801284 }
1281-
12821285 mOnKeyboardActionListener!! .onPress(onPressKey)
1286+ mLastKeyPressedCode = onPressKey
12831287
12841288 var wasHandled = false
12851289 if (mCurrentKey >= 0 && mKeys[mCurrentKey].repeatable) {
@@ -1310,6 +1314,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
13101314 showPreview(keyIndex)
13111315 }
13121316 }
1317+
13131318 MotionEvent .ACTION_MOVE -> {
13141319 var continueLongPress = false
13151320 if (keyIndex != NOT_A_KEY ) {
@@ -1363,6 +1368,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
13631368 mLastMoveTime = eventTime
13641369 }
13651370 }
1371+
13661372 MotionEvent .ACTION_UP -> {
13671373 mLastSpaceMoveX = 0
13681374 removeMessages()
@@ -1391,11 +1397,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
13911397 detectAndSendKey(mCurrentKey, touchX, touchY, eventTime)
13921398 }
13931399
1394- invalidateKey(keyIndex)
1400+ if (mLastKeyPressedCode != KEYCODE_MODE_CHANGE ) {
1401+ invalidateKey(keyIndex)
1402+ }
13951403 mRepeatKeyIndex = NOT_A_KEY
13961404 mOnKeyboardActionListener!! .onActionUp()
13971405 mIsLongPressingSpace = false
13981406 }
1407+
13991408 MotionEvent .ACTION_CANCEL -> {
14001409 mIsLongPressingSpace = false
14011410 mLastSpaceMoveX = 0
@@ -1515,12 +1524,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
15151524 mHandler!! .sendMessageDelayed(msg, REPEAT_START_DELAY .toLong())
15161525 true
15171526 }
1527+
15181528 MotionEvent .ACTION_UP -> {
15191529 mHandler!! .removeMessages(MSG_REPEAT )
15201530 mRepeatKeyIndex = NOT_A_KEY
15211531 isPressed = false
15221532 false
15231533 }
1534+
15241535 else -> false
15251536 }
15261537 }
0 commit comments