mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-06-05 21:49:26 +02:00
ShiftState refactored
This commit is contained in:
@ -455,7 +455,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
* @param shifted whether or not to enable the state of the shift key
|
||||
* @return true if the shift key state changed, false if there was no change
|
||||
*/
|
||||
private fun setShifted(shiftState: Int) {
|
||||
private fun setShifted(shiftState: ShiftState) {
|
||||
if (mKeyboard?.setShifted(shiftState) == true) {
|
||||
invalidateAllKeys()
|
||||
}
|
||||
@ -466,7 +466,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
* @return true if the shift is in a pressed state, false otherwise
|
||||
*/
|
||||
private fun isShifted(): Boolean {
|
||||
return (mKeyboard?.mShiftState ?: SHIFT_OFF) > SHIFT_OFF
|
||||
return (mKeyboard?.mShiftState ?: ShiftState.OFF) > ShiftState.OFF
|
||||
}
|
||||
|
||||
private fun setPopupOffset(x: Int, y: Int) {
|
||||
@ -479,7 +479,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
|
||||
private fun adjustCase(label: CharSequence): CharSequence? {
|
||||
var newLabel: CharSequence? = label
|
||||
if (newLabel != null && newLabel.isNotEmpty() && mKeyboard!!.mShiftState > SHIFT_OFF && newLabel.length < 3 && Character.isLowerCase(newLabel[0])) {
|
||||
if (newLabel != null && newLabel.isNotEmpty() && mKeyboard!!.mShiftState != ShiftState.OFF && newLabel.length < 3 && Character.isLowerCase(newLabel[0])) {
|
||||
newLabel = newLabel.toString().uppercase(Locale.getDefault())
|
||||
}
|
||||
return newLabel
|
||||
@ -602,8 +602,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
} else if (key.icon != null && mKeyboard != null) {
|
||||
if (code == KEYCODE_SHIFT) {
|
||||
val drawableId = when (mKeyboard!!.mShiftState) {
|
||||
SHIFT_OFF -> R.drawable.ic_caps_outline_vector
|
||||
SHIFT_ON_ONE_CHAR -> R.drawable.ic_caps_vector
|
||||
ShiftState.OFF -> R.drawable.ic_caps_outline_vector
|
||||
ShiftState.ON_ONE_CHAR -> R.drawable.ic_caps_vector
|
||||
else -> R.drawable.ic_caps_underlined_vector
|
||||
}
|
||||
key.icon = resources.getDrawable(drawableId)
|
||||
@ -1129,7 +1129,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
mMiniKeyboardSelectedKeyIndex = selectedKeyIndex
|
||||
mMiniKeyboard!!.invalidateAllKeys()
|
||||
|
||||
val miniShiftStatus = if (isShifted()) SHIFT_ON_PERMANENT else SHIFT_OFF
|
||||
val miniShiftStatus = if (isShifted()) ShiftState.ON_PERMANENT else ShiftState.OFF
|
||||
mMiniKeyboard!!.setShifted(miniShiftStatus)
|
||||
mPopupKeyboard.contentView = mMiniKeyboardContainer
|
||||
mPopupKeyboard.width = mMiniKeyboardContainer!!.measuredWidth
|
||||
|
Reference in New Issue
Block a user