removing some redundant helper functions
This commit is contained in:
parent
470d47b5da
commit
eebc0a4613
|
@ -1,5 +1,6 @@
|
||||||
package com.simplemobiletools.keyboard.helpers
|
package com.simplemobiletools.keyboard.helpers
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.content.res.TypedArray
|
import android.content.res.TypedArray
|
||||||
|
@ -76,6 +77,7 @@ class MyKeyboard {
|
||||||
|
|
||||||
/** Number of key widths from current touch point to search for nearest keys. */
|
/** Number of key widths from current touch point to search for nearest keys. */
|
||||||
private const val SEARCH_DISTANCE = 1.8f
|
private const val SEARCH_DISTANCE = 1.8f
|
||||||
|
|
||||||
fun getDimensionOrFraction(a: TypedArray, index: Int, base: Int, defValue: Int): Int {
|
fun getDimensionOrFraction(a: TypedArray, index: Int, base: Int, defValue: Int): Int {
|
||||||
val value = a.peekValue(index) ?: return defValue
|
val value = a.peekValue(index) ?: return defValue
|
||||||
if (value.type == TypedValue.TYPE_DIMENSION) {
|
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
|
* 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].
|
* [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 */
|
/** The keyboard that this key belongs to */
|
||||||
private val keyboard: MyKeyboard = parent.parent
|
private val keyboard: MyKeyboard = parent.parent
|
||||||
|
@ -234,14 +236,6 @@ class MyKeyboard {
|
||||||
gap = parent.defaultHorizontalGap
|
gap = parent.defaultHorizontalGap
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onPressed() {
|
|
||||||
pressed = true
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onReleased() {
|
|
||||||
pressed = false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detects if a point falls inside this key.
|
* Detects if a point falls inside this key.
|
||||||
* @param x the x-coordinate of the point
|
* @param x the x-coordinate of the point
|
||||||
|
@ -420,6 +414,7 @@ class MyKeyboard {
|
||||||
return Key(res, parent, x, y, parser)
|
return Key(res, parent, x, y, parser)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("UseCompatLoadingForDrawables")
|
||||||
private fun loadKeyboard(context: Context, parser: XmlResourceParser) {
|
private fun loadKeyboard(context: Context, parser: XmlResourceParser) {
|
||||||
var inKey = false
|
var inKey = false
|
||||||
var inRow = false
|
var inRow = false
|
||||||
|
|
|
@ -603,7 +603,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||||
if (oldKeyIndex != mCurrentKeyIndex) {
|
if (oldKeyIndex != mCurrentKeyIndex) {
|
||||||
if (oldKeyIndex != NOT_A_KEY && keys.size > oldKeyIndex) {
|
if (oldKeyIndex != NOT_A_KEY && keys.size > oldKeyIndex) {
|
||||||
val oldKey = keys[oldKeyIndex]
|
val oldKey = keys[oldKeyIndex]
|
||||||
oldKey.onReleased()
|
oldKey.pressed = false
|
||||||
invalidateKey(oldKeyIndex)
|
invalidateKey(oldKeyIndex)
|
||||||
val keyCode = oldKey.codes[0]
|
val keyCode = oldKey.codes[0]
|
||||||
sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT, keyCode)
|
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 ||
|
if (code == MyKeyboard.KEYCODE_SHIFT || code == MyKeyboard.KEYCODE_MODE_CHANGE || code == MyKeyboard.KEYCODE_DELETE ||
|
||||||
code == MyKeyboard.KEYCODE_ENTER || code == MyKeyboard.KEYCODE_SPACE
|
code == MyKeyboard.KEYCODE_ENTER || code == MyKeyboard.KEYCODE_SPACE
|
||||||
) {
|
) {
|
||||||
newKey.onPressed()
|
newKey.pressed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidateKey(mCurrentKeyIndex)
|
invalidateKey(mCurrentKeyIndex)
|
||||||
|
|
Loading…
Reference in New Issue