removing some redundant helper functions

This commit is contained in:
tibbi 2022-01-21 23:27:28 +01:00
parent 470d47b5da
commit eebc0a4613
2 changed files with 6 additions and 11 deletions

View File

@ -1,5 +1,6 @@
package com.simplemobiletools.keyboard.helpers
import android.annotation.SuppressLint
import android.content.Context
import android.content.res.Resources
import android.content.res.TypedArray
@ -76,6 +77,7 @@ class MyKeyboard {
/** Number of key widths from current touch point to search for nearest keys. */
private const val SEARCH_DISTANCE = 1.8f
fun getDimensionOrFraction(a: TypedArray, index: Int, base: Int, defValue: Int): Int {
val value = a.peekValue(index) ?: return defValue
if (value.type == TypedValue.TYPE_DIMENSION) {
@ -179,7 +181,7 @@ class MyKeyboard {
* that are just out of the boundary of the key. This is a bit mask of
* [MyKeyboard.EDGE_LEFT], [MyKeyboard.EDGE_RIGHT], [MyKeyboard.EDGE_TOP] and [MyKeyboard.EDGE_BOTTOM].
*/
var edgeFlags = 0
private var edgeFlags = 0
/** The keyboard that this key belongs to */
private val keyboard: MyKeyboard = parent.parent
@ -234,14 +236,6 @@ class MyKeyboard {
gap = parent.defaultHorizontalGap
}
fun onPressed() {
pressed = true
}
fun onReleased() {
pressed = false
}
/**
* Detects if a point falls inside this key.
* @param x the x-coordinate of the point
@ -420,6 +414,7 @@ class MyKeyboard {
return Key(res, parent, x, y, parser)
}
@SuppressLint("UseCompatLoadingForDrawables")
private fun loadKeyboard(context: Context, parser: XmlResourceParser) {
var inKey = false
var inRow = false

View File

@ -603,7 +603,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
if (oldKeyIndex != mCurrentKeyIndex) {
if (oldKeyIndex != NOT_A_KEY && keys.size > oldKeyIndex) {
val oldKey = keys[oldKeyIndex]
oldKey.onReleased()
oldKey.pressed = false
invalidateKey(oldKeyIndex)
val keyCode = oldKey.codes[0]
sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT, keyCode)
@ -617,7 +617,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
if (code == MyKeyboard.KEYCODE_SHIFT || code == MyKeyboard.KEYCODE_MODE_CHANGE || code == MyKeyboard.KEYCODE_DELETE ||
code == MyKeyboard.KEYCODE_ENTER || code == MyKeyboard.KEYCODE_SPACE
) {
newKey.onPressed()
newKey.pressed = true
}
invalidateKey(mCurrentKeyIndex)