mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-06-05 21:49:26 +02:00
simplifying some getters and setters
This commit is contained in:
@ -18,7 +18,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
|
|||||||
override fun onCreateInputView(): View {
|
override fun onCreateInputView(): View {
|
||||||
keyboardView = layoutInflater.inflate(R.layout.keyboard_view_keyboard, null) as MyKeyboardView
|
keyboardView = layoutInflater.inflate(R.layout.keyboard_view_keyboard, null) as MyKeyboardView
|
||||||
keyboard = Keyboard(this, R.xml.keys_layout)
|
keyboard = Keyboard(this, R.xml.keys_layout)
|
||||||
keyboardView!!.keyboard = keyboard
|
keyboardView!!.setKeyboard(keyboard!!)
|
||||||
keyboardView!!.onKeyboardActionListener = this
|
keyboardView!!.onKeyboardActionListener = this
|
||||||
return keyboardView!!
|
return keyboardView!!
|
||||||
}
|
}
|
||||||
|
@ -382,30 +382,28 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
* @see .getKeyboard
|
* @see .getKeyboard
|
||||||
* @param keyboard the keyboard to display in this view
|
* @param keyboard the keyboard to display in this view
|
||||||
*/
|
*/
|
||||||
var keyboard: Keyboard?
|
fun setKeyboard(keyboard: Keyboard) {
|
||||||
get() = mKeyboard
|
if (mKeyboard != null) {
|
||||||
set(keyboard) {
|
showPreview(NOT_A_KEY)
|
||||||
if (mKeyboard != null) {
|
|
||||||
showPreview(NOT_A_KEY)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove any pending messages
|
|
||||||
removeMessages()
|
|
||||||
mKeyboard = keyboard
|
|
||||||
val keys = mKeyboard!!.keys
|
|
||||||
mKeys = keys.toMutableList() as ArrayList<Keyboard.Key>
|
|
||||||
requestLayout()
|
|
||||||
// Hint to reallocate the buffer if the size changed
|
|
||||||
mKeyboardChanged = true
|
|
||||||
invalidateAllKeys()
|
|
||||||
computeProximityThreshold(keyboard)
|
|
||||||
mMiniKeyboardCache.clear()
|
|
||||||
// Not really necessary to do every time, but will free up views
|
|
||||||
// Switching to a different keyboard should abort any pending keys so that the key up
|
|
||||||
// doesn't get delivered to the old or new keyboard
|
|
||||||
mAbortKey = true // Until the next ACTION_DOWN
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove any pending messages
|
||||||
|
removeMessages()
|
||||||
|
mKeyboard = keyboard
|
||||||
|
val keys = mKeyboard!!.keys
|
||||||
|
mKeys = keys.toMutableList() as ArrayList<Keyboard.Key>
|
||||||
|
requestLayout()
|
||||||
|
// Hint to reallocate the buffer if the size changed
|
||||||
|
mKeyboardChanged = true
|
||||||
|
invalidateAllKeys()
|
||||||
|
computeProximityThreshold(keyboard)
|
||||||
|
mMiniKeyboardCache.clear()
|
||||||
|
// Not really necessary to do every time, but will free up views
|
||||||
|
// Switching to a different keyboard should abort any pending keys so that the key up
|
||||||
|
// doesn't get delivered to the old or new keyboard
|
||||||
|
mAbortKey = true // Until the next ACTION_DOWN
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the state of the shift key of the keyboard, if any.
|
* Sets the state of the shift key of the keyboard, if any.
|
||||||
* @param shifted whether or not to enable the state of the shift key
|
* @param shifted whether or not to enable the state of the shift key
|
||||||
@ -429,12 +427,13 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
* no shift key on the keyboard or there is no keyboard attached, it returns false.
|
* no shift key on the keyboard or there is no keyboard attached, it returns false.
|
||||||
* @see KeyboardView.setShifted
|
* @see KeyboardView.setShifted
|
||||||
*/
|
*/
|
||||||
var isShifted: Boolean = false
|
fun isShifted(): Boolean {
|
||||||
get() = if (mKeyboard != null) {
|
return if (mKeyboard != null) {
|
||||||
mKeyboard!!.isShifted
|
mKeyboard!!.isShifted
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setPopupParent(v: View) {
|
fun setPopupParent(v: View) {
|
||||||
mPopupParent = v
|
mPopupParent = v
|
||||||
@ -1010,7 +1009,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
Keyboard(context, popupKeyboardId)
|
Keyboard(context, popupKeyboardId)
|
||||||
}
|
}
|
||||||
|
|
||||||
mMiniKeyboard!!.keyboard = keyboard
|
mMiniKeyboard!!.setKeyboard(keyboard)
|
||||||
mMiniKeyboard!!.setPopupParent(this)
|
mMiniKeyboard!!.setPopupParent(this)
|
||||||
mMiniKeyboardContainer!!.measure(
|
mMiniKeyboardContainer!!.measure(
|
||||||
MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST),
|
MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST),
|
||||||
@ -1029,7 +1028,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
val x = mPopupX + mMiniKeyboardContainer!!.paddingRight + mCoordinates[0]
|
val x = mPopupX + mMiniKeyboardContainer!!.paddingRight + mCoordinates[0]
|
||||||
val y = mPopupY + mMiniKeyboardContainer!!.paddingBottom + mCoordinates[1]
|
val y = mPopupY + mMiniKeyboardContainer!!.paddingBottom + mCoordinates[1]
|
||||||
mMiniKeyboard!!.setPopupOffset(if (x < 0) 0 else x, y)
|
mMiniKeyboard!!.setPopupOffset(if (x < 0) 0 else x, y)
|
||||||
mMiniKeyboard!!.isShifted = isShifted
|
mMiniKeyboard!!.setShifted(isShifted())
|
||||||
mPopupKeyboard.contentView = mMiniKeyboardContainer
|
mPopupKeyboard.contentView = mMiniKeyboardContainer
|
||||||
mPopupKeyboard.width = mMiniKeyboardContainer!!.measuredWidth
|
mPopupKeyboard.width = mMiniKeyboardContainer!!.measuredWidth
|
||||||
mPopupKeyboard.height = mMiniKeyboardContainer!!.measuredHeight
|
mPopupKeyboard.height = mMiniKeyboardContainer!!.measuredHeight
|
||||||
|
Reference in New Issue
Block a user