Add emoji key

This commit is contained in:
Naveen 2022-07-30 21:28:01 +05:30
parent 2b052f4c7c
commit 71e6b63158
10 changed files with 90 additions and 45 deletions

View File

@ -12,7 +12,6 @@ import android.view.inputmethod.EditorInfo
import android.view.inputmethod.EditorInfo.IME_ACTION_NONE
import androidx.annotation.XmlRes
import com.simplemobiletools.keyboard.R
import java.util.*
/**
* Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard consists of rows of keys.
@ -61,6 +60,7 @@ class MyKeyboard {
const val KEYCODE_ENTER = -4
const val KEYCODE_DELETE = -5
const val KEYCODE_SPACE = 32
const val KEYCODE_EMOJI = -6
fun getDimensionOrFraction(a: TypedArray, index: Int, base: Int, defValue: Int): Int {
val value = a.peekValue(index) ?: return defValue
@ -203,7 +203,7 @@ class MyKeyboard {
topSmallNumber = a.getString(R.styleable.MyKeyboard_Key_topSmallNumber) ?: ""
if (label.isNotEmpty() && code != KEYCODE_MODE_CHANGE && code != KEYCODE_SHIFT) {
code = label[0].toInt()
code = label[0].code
}
a.recycle()
}
@ -281,7 +281,7 @@ class MyKeyboard {
key.x = x
key.y = y
key.label = character.toString()
key.code = character.toInt()
key.code = character.code
column++
x += key.width + key.gap
mKeys!!.add(key)

View File

@ -122,10 +122,15 @@
<Key
app:keyLabel="q"
app:keyWidth="10%p" />
<Key
app:code="-6"
app:keyEdgeFlags="left"
app:keyIcon="@drawable/ic_emoji_emotions_outline_vector"
app:keyWidth="8%p" />
<Key
app:code="32"
app:isRepeatable="true"
app:keyWidth="50%p" />
app:keyWidth="40%p" />
<Key
app:keyLabel="z"
app:keyWidth="10%p"

View File

@ -121,10 +121,15 @@
<Key
app:keyLabel=","
app:keyWidth="10%p" />
<Key
app:code="-6"
app:keyEdgeFlags="left"
app:keyIcon="@drawable/ic_emoji_emotions_outline_vector"
app:keyWidth="8%p" />
<Key
app:code="32"
app:isRepeatable="true"
app:keyWidth="50%p" />
app:keyWidth="40%p" />
<Key
app:keyLabel="."
app:keyWidth="10%p" />

View File

@ -121,10 +121,15 @@
<Key
app:keyLabel=","
app:keyWidth="10%p" />
<Key
app:code="-6"
app:keyEdgeFlags="left"
app:keyIcon="@drawable/ic_emoji_emotions_outline_vector"
app:keyWidth="8%p" />
<Key
app:code="32"
app:isRepeatable="true"
app:keyWidth="50%p" />
app:keyWidth="40%p" />
<Key
app:keyLabel="."
app:keyWidth="10%p" />

View File

@ -102,10 +102,15 @@
<Key
app:keyLabel=","
app:keyWidth="10%p" />
<Key
app:code="-6"
app:keyEdgeFlags="left"
app:keyIcon="@drawable/ic_emoji_emotions_outline_vector"
app:keyWidth="8%p" />
<Key
app:code="32"
app:isRepeatable="true"
app:keyWidth="50%p" />
app:keyWidth="40%p" />
<Key
app:keyLabel="."
app:keyWidth="10%p" />

View File

@ -121,10 +121,15 @@
<Key
app:keyLabel=","
app:keyWidth="10%p" />
<Key
app:code="-6"
app:keyEdgeFlags="left"
app:keyIcon="@drawable/ic_emoji_emotions_outline_vector"
app:keyWidth="8%p" />
<Key
app:code="32"
app:isRepeatable="true"
app:keyWidth="50%p" />
app:keyWidth="40%p" />
<Key
app:keyLabel="."
app:keyWidth="10%p" />

View File

@ -105,10 +105,15 @@
<Key
app:keyLabel=","
app:keyWidth="10%p" />
<Key
app:code="-6"
app:keyEdgeFlags="left"
app:keyIcon="@drawable/ic_emoji_emotions_outline_vector"
app:keyWidth="8%p" />
<Key
app:code="32"
app:isRepeatable="true"
app:keyWidth="50%p" />
app:keyWidth="40%p" />
<Key
app:keyLabel="."
app:keyWidth="10%p" />

View File

@ -155,10 +155,15 @@
<Key
app:keyLabel=","
app:keyWidth="10%p" />
<Key
app:code="-6"
app:keyEdgeFlags="left"
app:keyIcon="@drawable/ic_emoji_emotions_outline_vector"
app:keyWidth="8%p" />
<Key
app:code="32"
app:isRepeatable="true"
app:keyWidth="50%p" />
app:keyWidth="40%p" />
<Key
app:keyLabel="."
app:keyWidth="10%p" />

View File

@ -108,10 +108,15 @@
<Key
app:keyLabel=","
app:keyWidth="10%p" />
<Key
app:code="-6"
app:keyEdgeFlags="left"
app:keyIcon="@drawable/ic_emoji_emotions_outline_vector"
app:keyWidth="8%p" />
<Key
app:code="32"
app:isRepeatable="true"
app:keyWidth="50%p" />
app:keyWidth="40%p" />
<Key
app:keyLabel="."
app:keyWidth="10%p" />

View File

@ -119,10 +119,15 @@
<Key
app:keyLabel=","
app:keyWidth="10%p" />
<Key
app:code="-6"
app:keyEdgeFlags="left"
app:keyIcon="@drawable/ic_emoji_emotions_outline_vector"
app:keyWidth="8%p" />
<Key
app:code="32"
app:isRepeatable="true"
app:keyWidth="50%p"/>
app:keyWidth="40%p" />
<Key
app:keyLabel="."
app:keyWidth="10%p" />