mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-06-05 21:49:26 +02:00
adding some initial styling things
This commit is contained in:
@ -538,7 +538,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
val canvas = mCanvas
|
||||
canvas!!.clipRect(mDirtyRect)
|
||||
val paint = mPaint
|
||||
val keyBackground = mKeyBackground
|
||||
val clipRegion = mClipRegion
|
||||
val padding = mPadding
|
||||
val kbdPaddingLeft: Int = paddingLeft
|
||||
@ -574,6 +573,13 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
continue
|
||||
}
|
||||
|
||||
var keyBackground = mKeyBackground
|
||||
if (key.codes.firstOrNull() == MyKeyboard.KEYCODE_SPACE) {
|
||||
keyBackground = resources.getDrawable(R.drawable.keyboard_space_background, context.theme)
|
||||
} else if (key.codes.firstOrNull() == MyKeyboard.KEYCODE_ENTER) {
|
||||
keyBackground = resources.getDrawable(R.drawable.keyboard_enter_background, context.theme)
|
||||
}
|
||||
|
||||
// Switch the character to uppercase if shift is pressed
|
||||
val label = adjustCase(key.label)?.toString()
|
||||
val bounds = keyBackground!!.bounds
|
||||
@ -623,22 +629,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
key.icon = resources.getDrawable(drawableId)
|
||||
}
|
||||
|
||||
val iconWidthToUse = if (key.codes.firstOrNull() == MyKeyboard.KEYCODE_ENTER) {
|
||||
(key.icon!!.intrinsicWidth * 1.2).toInt()
|
||||
} else {
|
||||
key.icon!!.intrinsicWidth
|
||||
}
|
||||
|
||||
val iconHeightToUse = if (key.codes.firstOrNull() == MyKeyboard.KEYCODE_ENTER) {
|
||||
(key.icon!!.intrinsicHeight * 1.2).toInt()
|
||||
} else {
|
||||
key.icon!!.intrinsicHeight
|
||||
}
|
||||
|
||||
val drawableX = (key.width - iconWidthToUse) / 2
|
||||
val drawableY = (key.height - iconHeightToUse) / 2
|
||||
val drawableX = (key.width - key.icon!!.intrinsicWidth) / 2
|
||||
val drawableY = (key.height - key.icon!!.intrinsicHeight) / 2
|
||||
canvas.translate(drawableX.toFloat(), drawableY.toFloat())
|
||||
key.icon!!.setBounds(0, 0, iconWidthToUse, iconHeightToUse)
|
||||
key.icon!!.setBounds(0, 0, key.icon!!.intrinsicWidth, key.icon!!.intrinsicHeight)
|
||||
key.icon!!.draw(canvas)
|
||||
canvas.translate(-drawableX.toFloat(), -drawableY.toFloat())
|
||||
}
|
||||
|
Reference in New Issue
Block a user