diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt index a7bec73..8f04596 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt @@ -39,16 +39,16 @@ import java.util.* */ class MyKeyboard { /** Horizontal gap default for all rows */ - protected var mDefaultHorizontalGap = 0 + private var mDefaultHorizontalGap = 0 /** Default key width */ - protected var mDefaultWidth = 0 + private var mDefaultWidth = 0 /** Default key height */ - protected var mDefaultHeight = 0 + private var mDefaultHeight = 0 /** Default gap between rows */ - protected var mDefaultVerticalGap = 0 + private var mDefaultVerticalGap = 0 /** Is the keyboard in the shifted state */ var shiftState = SHIFT_OFF @@ -56,9 +56,6 @@ class MyKeyboard { /** Key instance for the shift key, if present */ private val mShiftKeys = arrayOf(null, null) - /** Key index for the shift key, if present */ - private val shiftKeyIndices = intArrayOf(-1, -1) - /** Total height of the keyboard, including the padding and keys */ var height = 0 @@ -68,9 +65,6 @@ class MyKeyboard { /** List of keys in this keyboard */ var mKeys: MutableList? = null - /** List of modifier keys such as Shift & Alt, if any */ - private var mModifierKeys = ArrayList() - /** Width of the screen available to fit the keyboard */ private var mDisplayWidth = 0 @@ -165,7 +159,7 @@ class MyKeyboard { this.parent = parent var a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard) defaultWidth = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, parent.mDisplayWidth, parent.mDefaultWidth) - defaultHeight = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyHeight, parent.mDisplayHeight, parent.mDefaultHeight) + defaultHeight = res.getDimension(R.dimen.key_height).toInt() defaultHorizontalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, parent.mDisplayWidth, parent.mDefaultHorizontalGap) verticalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_verticalGap, parent.mDisplayHeight, parent.mDefaultVerticalGap) @@ -272,7 +266,7 @@ class MyKeyboard { this.y = y var a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard) width = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, keyboard.mDisplayWidth, parent.defaultWidth) - height = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyHeight, keyboard.mDisplayHeight, parent.defaultHeight) + height = parent.defaultHeight gap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, keyboard.mDisplayWidth, parent.defaultHorizontalGap) a.recycle() @@ -555,11 +549,11 @@ class MyKeyboard { return IntArray(0) } - protected fun createRowFromXml(res: Resources, parser: XmlResourceParser?): Row { + private fun createRowFromXml(res: Resources, parser: XmlResourceParser?): Row { return Row(res, this, parser) } - protected fun createKeyFromXml(res: Resources, parent: Row, x: Int, y: Int, parser: XmlResourceParser?): Key { + private fun createKeyFromXml(res: Resources, parent: Row, x: Int, y: Int, parser: XmlResourceParser?): Key { return Key(res, parent, x, y, parser) } @@ -596,11 +590,9 @@ class MyKeyboard { for (i in mShiftKeys.indices) { if (mShiftKeys[i] == null) { mShiftKeys[i] = key - shiftKeyIndices[i] = mKeys!!.size - 1 break } } - mModifierKeys.add(key) } else if (key.codes[0] == KEYCODE_ENTER) { val enterResourceId = when (mEnterKeyType) { EditorInfo.IME_ACTION_SEARCH -> R.drawable.ic_search_vector @@ -646,7 +638,7 @@ class MyKeyboard { private fun parseKeyboardAttributes(res: Resources, parser: XmlResourceParser) { val a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard) mDefaultWidth = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyWidth, mDisplayWidth, mDisplayWidth / 10) - mDefaultHeight = getDimensionOrFraction(a, R.styleable.MyKeyboard_keyHeight, mDisplayHeight, 50) + mDefaultHeight = res.getDimension(R.dimen.key_height).toInt() mDefaultHorizontalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_horizontalGap, mDisplayWidth, 0) mDefaultVerticalGap = getDimensionOrFraction(a, R.styleable.MyKeyboard_verticalGap, mDisplayHeight, 0) mProximityThreshold = (mDefaultWidth * SEARCH_DISTANCE).toInt() diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 319fd36..cccfbda 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -37,8 +37,6 @@ - - diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index ca79286..2d788a7 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -2,5 +2,7 @@ 60dp 12dp 18dp + 60dp + 26sp diff --git a/app/src/main/res/xml/keyboard_popup_template.xml b/app/src/main/res/xml/keyboard_popup_template.xml index fa28d10..195b279 100644 --- a/app/src/main/res/xml/keyboard_popup_template.xml +++ b/app/src/main/res/xml/keyboard_popup_template.xml @@ -1,6 +1,4 @@ diff --git a/app/src/main/res/xml/keys_letters.xml b/app/src/main/res/xml/keys_letters.xml index 9afbeb8..6b989f1 100644 --- a/app/src/main/res/xml/keys_letters.xml +++ b/app/src/main/res/xml/keys_letters.xml @@ -1,7 +1,6 @@