@@ -138,6 +138,9 @@ class MyKeyboard {
138138 /* * Icon to display instead of a label. Icon takes precedence over a label */
139139 var icon: Drawable ? = null
140140
141+ /* * Icon to display top left of an icon.*/
142+ var secondaryIcon: Drawable ? = null
143+
141144 /* * Width of the key, not including the gap */
142145 var width: Int
143146
@@ -204,6 +207,9 @@ class MyKeyboard {
204207 icon = a.getDrawable(R .styleable.MyKeyboard_Key_keyIcon )
205208 icon?.setBounds(0 , 0 , icon!! .intrinsicWidth, icon!! .intrinsicHeight)
206209
210+ secondaryIcon = a.getDrawable(R .styleable.MyKeyboard_Key_secondaryKeyIcon )
211+ secondaryIcon?.setBounds(0 , 0 , secondaryIcon!! .intrinsicWidth, secondaryIcon!! .intrinsicHeight)
212+
207213 label = a.getText(R .styleable.MyKeyboard_Key_keyLabel ) ? : " "
208214 topSmallNumber = a.getString(R .styleable.MyKeyboard_Key_topSmallNumber ) ? : " "
209215
@@ -230,10 +236,12 @@ class MyKeyboard {
230236 fun isInside (x : Int , y : Int ): Boolean {
231237 val leftEdge = edgeFlags and EDGE_LEFT > 0
232238 val rightEdge = edgeFlags and EDGE_RIGHT > 0
233- return ((x >= this .x || leftEdge && x <= this .x + width)
234- && (x < this .x + width || rightEdge && x >= this .x)
235- && (y >= this .y && y <= this .y + height)
236- && (y < this .y + height && y >= this .y))
239+ return (
240+ (x >= this .x || leftEdge && x <= this .x + width) &&
241+ (x < this .x + width || rightEdge && x >= this .x) &&
242+ (y >= this .y && y <= this .y + height) &&
243+ (y < this .y + height && y >= this .y)
244+ )
237245 }
238246 }
239247
@@ -249,7 +257,7 @@ class MyKeyboard {
249257 mDefaultHorizontalGap = 0
250258 mDefaultWidth = mDisplayWidth / 10
251259 mDefaultHeight = mDefaultWidth
252- mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier);
260+ mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier)
253261 mKeys = ArrayList ()
254262 mEnterKeyType = enterKeyType
255263 loadKeyboard(context, context.resources.getXml(xmlLayoutResId))
@@ -273,7 +281,7 @@ class MyKeyboard {
273281 row.defaultHeight = mDefaultHeight
274282 row.defaultWidth = keyWidth
275283 row.defaultHorizontalGap = mDefaultHorizontalGap
276- mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier);
284+ mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier)
277285
278286 characters.forEachIndexed { index, character ->
279287 val key = Key (row)
@@ -386,7 +394,7 @@ class MyKeyboard {
386394 }
387395
388396 private fun getKeyboardHeightMultiplier (multiplierType : Int ): Float {
389- return when (multiplierType) {
397+ return when (multiplierType) {
390398 KEYBOARD_HEIGHT_MULTIPLIER_SMALL -> 1.0F
391399 KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM -> 1.2F
392400 KEYBOARD_HEIGHT_MULTIPLIER_LARGE -> 1.4F
0 commit comments