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,9 +382,7 @@ 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
|
|
||||||
set(keyboard) {
|
|
||||||
if (mKeyboard != null) {
|
if (mKeyboard != null) {
|
||||||
showPreview(NOT_A_KEY)
|
showPreview(NOT_A_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