removing the "on" value of keyboard keys
This commit is contained in:
parent
f3045fc68a
commit
c0fa39747e
|
@ -51,9 +51,6 @@ import java.util.*
|
|||
* @attr ref android.R.styleable#Keyboard_verticalGap
|
||||
*/
|
||||
class MyKeyboard {
|
||||
/** Keyboard label */
|
||||
private val mLabel: CharSequence? = null
|
||||
|
||||
/** Horizontal gap default for all rows */
|
||||
protected var mDefaultHorizontalGap = 0
|
||||
|
||||
|
@ -252,9 +249,6 @@ class MyKeyboard {
|
|||
/** The current pressed state of this key */
|
||||
var pressed = false
|
||||
|
||||
/** If this is a sticky key, is it on? */
|
||||
var on = false
|
||||
|
||||
/** Text to output when pressed. This can be multiple characters, like ".com" */
|
||||
var text: CharSequence? = null
|
||||
|
||||
|
@ -343,29 +337,6 @@ class MyKeyboard {
|
|||
pressed = !pressed
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the pressed state of the key.
|
||||
*
|
||||
* Toggled state of the key will be flipped when all the following conditions are
|
||||
* fulfilled:
|
||||
*
|
||||
* * This is a sticky key, that is, [.sticky] is `true`.
|
||||
* * The parameter `inside` is `true`.
|
||||
* * [android.os.Build.VERSION.SDK_INT] is greater than
|
||||
* [android.os.Build.VERSION_CODES.LOLLIPOP_MR1].
|
||||
*
|
||||
*
|
||||
* @param inside whether the finger was released inside the key. Works only on Android M and
|
||||
* later. See the method document for details.
|
||||
* @see .onPressed
|
||||
*/
|
||||
fun onReleased(inside: Boolean) {
|
||||
pressed = !pressed
|
||||
if (sticky && inside) {
|
||||
on = !on
|
||||
}
|
||||
}
|
||||
|
||||
fun parseCSV(value: String): ArrayList<Int> {
|
||||
var count = 0
|
||||
var lastIndex = 0
|
||||
|
@ -418,35 +389,6 @@ class MyKeyboard {
|
|||
val yDist = this.y + height / 2 - y
|
||||
return xDist * xDist + yDist * yDist
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drawable state for the key, based on the current state and type of the key.
|
||||
* @return the drawable state of the key.
|
||||
* @see android.graphics.drawable.StateListDrawable.setState
|
||||
*/
|
||||
fun getCurrentDrawableState(): IntArray {
|
||||
var states: IntArray = KEY_STATE_NORMAL
|
||||
if (on) {
|
||||
states = if (pressed) {
|
||||
KEY_STATE_PRESSED_ON
|
||||
} else {
|
||||
KEY_STATE_NORMAL_ON
|
||||
}
|
||||
} else {
|
||||
if (sticky) {
|
||||
states = if (pressed) {
|
||||
KEY_STATE_PRESSED_OFF
|
||||
} else {
|
||||
KEY_STATE_NORMAL_OFF
|
||||
}
|
||||
} else {
|
||||
if (pressed) {
|
||||
states = KEY_STATE_PRESSED
|
||||
}
|
||||
}
|
||||
}
|
||||
return states
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -563,10 +505,6 @@ class MyKeyboard {
|
|||
}
|
||||
|
||||
fun setShifted(shiftState: Int): Boolean {
|
||||
for (shiftKey in mShiftKeys) {
|
||||
shiftKey?.on = shiftState > SHIFT_OFF
|
||||
}
|
||||
|
||||
if (this.shiftState != shiftState) {
|
||||
this.shiftState = shiftState
|
||||
return true
|
||||
|
|
|
@ -568,13 +568,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
continue
|
||||
}
|
||||
|
||||
val drawableState = key.getCurrentDrawableState()
|
||||
keyBackground!!.state = drawableState
|
||||
|
||||
// Switch the character to uppercase if shift is pressed
|
||||
val label = adjustCase(key.label)?.toString()
|
||||
|
||||
val bounds = keyBackground.bounds
|
||||
val bounds = keyBackground!!.bounds
|
||||
if (key.width != bounds.right || key.height != bounds.bottom) {
|
||||
keyBackground.setBounds(0, 0, key.width, key.height)
|
||||
}
|
||||
|
@ -750,7 +746,6 @@ 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(mCurrentKeyIndex == NOT_A_KEY)
|
||||
invalidateKey(oldKeyIndex)
|
||||
val keyCode = oldKey.codes[0]
|
||||
sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT, keyCode)
|
||||
|
|
Loading…
Reference in New Issue