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 a442d03..69d37b3 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt
@@ -138,6 +138,9 @@ class MyKeyboard {
/** Icon to display instead of a label. Icon takes precedence over a label */
var icon: Drawable? = null
+ /** Icon to display top left of an icon.*/
+ var secondaryIcon: Drawable? = null
+
/** Width of the key, not including the gap */
var width: Int
@@ -204,6 +207,9 @@ class MyKeyboard {
icon = a.getDrawable(R.styleable.MyKeyboard_Key_keyIcon)
icon?.setBounds(0, 0, icon!!.intrinsicWidth, icon!!.intrinsicHeight)
+ secondaryIcon = a.getDrawable(R.styleable.MyKeyboard_Key_secondaryKeyIcon)
+ secondaryIcon?.setBounds(0, 0, secondaryIcon!!.intrinsicWidth, secondaryIcon!!.intrinsicHeight)
+
label = a.getText(R.styleable.MyKeyboard_Key_keyLabel) ?: ""
topSmallNumber = a.getString(R.styleable.MyKeyboard_Key_topSmallNumber) ?: ""
@@ -230,10 +236,12 @@ class MyKeyboard {
fun isInside(x: Int, y: Int): Boolean {
val leftEdge = edgeFlags and EDGE_LEFT > 0
val rightEdge = edgeFlags and EDGE_RIGHT > 0
- return ((x >= this.x || leftEdge && x <= this.x + width)
- && (x < this.x + width || rightEdge && x >= this.x)
- && (y >= this.y && y <= this.y + height)
- && (y < this.y + height && y >= this.y))
+ return (
+ (x >= this.x || leftEdge && x <= this.x + width) &&
+ (x < this.x + width || rightEdge && x >= this.x) &&
+ (y >= this.y && y <= this.y + height) &&
+ (y < this.y + height && y >= this.y)
+ )
}
}
@@ -249,7 +257,7 @@ class MyKeyboard {
mDefaultHorizontalGap = 0
mDefaultWidth = mDisplayWidth / 10
mDefaultHeight = mDefaultWidth
- mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier);
+ mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier)
mKeys = ArrayList()
mEnterKeyType = enterKeyType
loadKeyboard(context, context.resources.getXml(xmlLayoutResId))
@@ -273,7 +281,7 @@ class MyKeyboard {
row.defaultHeight = mDefaultHeight
row.defaultWidth = keyWidth
row.defaultHorizontalGap = mDefaultHorizontalGap
- mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier);
+ mKeyboardHeightMultiplier = getKeyboardHeightMultiplier(context.config.keyboardHeightMultiplier)
characters.forEachIndexed { index, character ->
val key = Key(row)
@@ -386,7 +394,7 @@ class MyKeyboard {
}
private fun getKeyboardHeightMultiplier(multiplierType: Int): Float {
- return when(multiplierType) {
+ return when (multiplierType) {
KEYBOARD_HEIGHT_MULTIPLIER_SMALL -> 1.0F
KEYBOARD_HEIGHT_MULTIPLIER_MEDIUM -> 1.2F
KEYBOARD_HEIGHT_MULTIPLIER_LARGE -> 1.4F
diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt
index c4d8ea9..262450e 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt
@@ -609,16 +609,53 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
if (code == KEYCODE_ENTER) {
key.icon!!.applyColorFilter(mPrimaryColor.getContrastColor())
+ key.secondaryIcon?.applyColorFilter(mPrimaryColor.getContrastColor())
} else if (code == KEYCODE_DELETE || code == KEYCODE_SHIFT || code == KEYCODE_EMOJI) {
key.icon!!.applyColorFilter(mTextColor)
+ key.secondaryIcon?.applyColorFilter(mTextColor)
}
+ val keyIcon = key.icon!!
+ val secondaryIcon = key.secondaryIcon
- 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, key.icon!!.intrinsicWidth, key.icon!!.intrinsicHeight)
- key.icon!!.draw(canvas)
- canvas.translate(-drawableX.toFloat(), -drawableY.toFloat())
+ if (secondaryIcon != null) {
+ val keyIconWidth = (keyIcon.intrinsicWidth * 0.9f).toInt()
+ val keyIconHeight = (keyIcon.intrinsicHeight * 0.9f).toInt()
+ val secondaryIconWidth = (secondaryIcon.intrinsicWidth * .6f).toInt()
+ val secondaryIconHeight = (secondaryIcon.intrinsicHeight * .6f).toInt()
+
+ val centerX = key.width / 2
+ val centerY = key.height / 2
+
+ val keyIconLeft = centerX - keyIconWidth / 2
+ val keyIconTop = centerY - keyIconHeight / 2
+
+ keyIcon.setBounds(keyIconLeft, keyIconTop, keyIconLeft + keyIconWidth, keyIconTop + keyIconHeight)
+ keyIcon.draw(canvas)
+
+ val secondaryIconPaddingRight = 10
+ val secondaryIconLeft = key.width - secondaryIconPaddingRight - secondaryIconWidth
+ val secondaryIconRight = secondaryIconLeft + secondaryIconWidth
+
+ val secondaryIconTop = 14 // This will act as a topPadding
+ val secondaryIconBottom = secondaryIconTop + secondaryIconHeight
+
+ secondaryIcon.setBounds(
+ secondaryIconLeft,
+ secondaryIconTop,
+ secondaryIconRight,
+ secondaryIconBottom
+ )
+ secondaryIcon.draw(canvas)
+
+ secondaryIcon.draw(canvas)
+ } else {
+ val drawableX = (key.width - keyIcon.intrinsicWidth) / 2
+ val drawableY = (key.height - keyIcon.intrinsicHeight) / 2
+ canvas.translate(drawableX.toFloat(), drawableY.toFloat())
+ keyIcon.setBounds(0, 0, keyIcon.intrinsicWidth, keyIcon.intrinsicHeight)
+ keyIcon.draw(canvas)
+ canvas.translate(-drawableX.toFloat(), -drawableY.toFloat())
+ }
}
canvas.translate(-key.x.toFloat(), -key.y.toFloat())
}
diff --git a/app/src/main/res/drawable/ic_language_outlined.xml b/app/src/main/res/drawable/ic_language_outlined.xml
new file mode 100644
index 0000000..b7f1596
--- /dev/null
+++ b/app/src/main/res/drawable/ic_language_outlined.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index 79cbc9e..695614c 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -33,6 +33,8 @@
+
+
diff --git a/app/src/main/res/xml/keys_letters_bengali.xml b/app/src/main/res/xml/keys_letters_bengali.xml
index 66f4abe..c57ffbf 100644
--- a/app/src/main/res/xml/keys_letters_bengali.xml
+++ b/app/src/main/res/xml/keys_letters_bengali.xml
@@ -162,6 +162,7 @@
app:code="-6"
app:keyEdgeFlags="left"
app:keyIcon="@drawable/ic_emoji_emotions_outline_vector"
+ app:secondaryKeyIcon="@drawable/ic_language_outlined"
app:keyWidth="10%p" />