Merge pull request #122 from suttod/main

Add cleanly numeric and phone keyboards
This commit is contained in:
Tibor Kaputa 2023-02-11 19:38:28 +01:00 committed by GitHub
commit 9b6adb09d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 155 additions and 1 deletions

View File

@ -28,6 +28,8 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
private val KEYBOARD_LETTERS = 0
private val KEYBOARD_SYMBOLS = 1
private val KEYBOARD_SYMBOLS_SHIFT = 2
private val KEYBOARD_NUMBERS = 3
private val KEYBOARD_PHONE = 4
private var keyboard: MyKeyboard? = null
private var keyboardView: MyKeyboardView? = null
@ -220,7 +222,15 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
private fun getKeyBoard(): MyKeyboard {
val keyboardXml = when (inputTypeClass) {
TYPE_CLASS_NUMBER, TYPE_CLASS_DATETIME, TYPE_CLASS_PHONE -> {
TYPE_CLASS_NUMBER -> {
keyboardMode = KEYBOARD_NUMBERS
R.xml.keys_numbers
}
TYPE_CLASS_PHONE -> {
keyboardMode = KEYBOARD_PHONE
R.xml.keys_phone
}
TYPE_CLASS_DATETIME -> {
keyboardMode = KEYBOARD_SYMBOLS
R.xml.keys_symbols
}

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:app="http://schemas.android.com/apk/res-auto">
<Row>
<Key
app:keyLabel="1"
app:keyEdgeFlags="left"
app:keyWidth="25%p" />
<Key
app:keyLabel="2"
app:keyWidth="25%p" />
<Key
app:keyLabel="3"
app:keyWidth="25%p" />
<Key
app:keyIcon="@drawable/ic_clear_vector"
app:code="-5"
app:isRepeatable="true"
app:keyEdgeFlags="right"
app:keyWidth="25%p" />
</Row>
<Row>
<Key
app:keyLabel="4"
app:keyEdgeFlags="left"
app:keyWidth="25%p" />
<Key
app:keyLabel="5"
app:keyWidth="25%p" />
<Key
app:keyLabel="6"
app:keyWidth="25%p" />
<Key
app:keyLabel="-"
app:keyEdgeFlags="right"
app:keyWidth="25%p" />
</Row>
<Row>
<Key
app:keyLabel="7"
app:keyEdgeFlags="left"
app:keyWidth="25%p" />
<Key
app:keyLabel="8"
app:keyWidth="25%p" />
<Key
app:keyLabel="9"
app:keyWidth="25%p" />
<Key
app:keyLabel="␣"
app:code="32"
app:keyEdgeFlags="right"
app:keyWidth="25%p" />
</Row>
<Row>
<Key
app:keyLabel=","
app:keyEdgeFlags="left"
app:keyWidth="25%p" />
<Key
app:keyLabel="0"
app:keyWidth="25%p" />
<Key
app:keyLabel="."
app:keyWidth="25%p" />
<Key
app:keyIcon="@drawable/ic_enter_vector"
app:code="-4"
app:keyEdgeFlags="right"
app:keyWidth="25%p" />
</Row>
</Keyboard>

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:app="http://schemas.android.com/apk/res-auto">
<Row>
<Key
app:keyLabel="1"
app:keyEdgeFlags="left"
app:keyWidth="25%p" />
<Key
app:keyLabel="2"
app:keyWidth="25%p" />
<Key
app:keyLabel="3"
app:keyWidth="25%p" />
<Key
app:keyIcon="@drawable/ic_clear_vector"
app:code="-5"
app:isRepeatable="true"
app:keyEdgeFlags="right"
app:keyWidth="25%p" />
</Row>
<Row>
<Key
app:keyLabel="4"
app:keyEdgeFlags="left"
app:keyWidth="25%p" />
<Key
app:keyLabel="5"
app:keyWidth="25%p" />
<Key
app:keyLabel="6"
app:keyWidth="25%p" />
<Key
app:keyEdgeFlags="right"
app:keyWidth="25%p" />
</Row>
<Row>
<Key
app:keyLabel="7"
app:keyEdgeFlags="left"
app:keyWidth="25%p" />
<Key
app:keyLabel="8"
app:keyWidth="25%p" />
<Key
app:keyLabel="9"
app:keyWidth="25%p" />
<Key
app:keyLabel="abc"
app:code="-2"
app:keyEdgeFlags="right"
app:keyWidth="25%p" />
</Row>
<Row>
<Key
app:keyLabel="*"
app:keyEdgeFlags="left"
app:keyWidth="25%p" />
<Key
app:keyLabel="0"
app:topSmallNumber="+"
app:popupKeyboard="@xml/keyboard_popup_template"
app:popupCharacters="+-,."
app:keyWidth="25%p" />
<Key
app:keyLabel="#"
app:keyWidth="25%p" />
<Key
app:keyIcon="@drawable/ic_enter_vector"
app:code="-4"
app:keyEdgeFlags="right"
app:keyWidth="25%p" />
</Row>
</Keyboard>