From 65f7c96c1256a2f3c36151ae7f0eb0e9d33ad4f4 Mon Sep 17 00:00:00 2001 From: merkost Date: Thu, 18 May 2023 13:04:44 +1000 Subject: [PATCH 1/4] Added additional EditText with inputType="phone" --- app/src/main/res/layout/activity_main.xml | 26 ++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 4ec8767..998ff11 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -41,12 +41,32 @@ - + android:orientation="vertical"> + + + + + + From 2df2ac7196016fa8daae61ce61f0ad76d047e366 Mon Sep 17 00:00:00 2001 From: merkost Date: Thu, 18 May 2023 13:07:56 +1000 Subject: [PATCH 2/4] Space key fix --- .../simplemobiletools/keyboard/helpers/MyKeyboard.kt | 11 +++++++---- .../keyboard/services/SimpleKeyboardIME.kt | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) 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 b2c77c0..91b596f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt @@ -201,8 +201,14 @@ class MyKeyboard { a.recycle() a = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.MyKeyboard_Key) + + label = a.getText(R.styleable.MyKeyboard_Key_keyLabel) ?: "" code = a.getInt(R.styleable.MyKeyboard_Key_code, 0) + if (label.isNotEmpty() && code == 0) { + code = label[0].code + } + popupCharacters = a.getText(R.styleable.MyKeyboard_Key_popupCharacters) popupResId = a.getResourceId(R.styleable.MyKeyboard_Key_popupKeyboard, 0) repeatable = a.getBoolean(R.styleable.MyKeyboard_Key_isRepeatable, false) @@ -213,12 +219,9 @@ class MyKeyboard { 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) ?: "" - if (label.isNotEmpty() && code != KEYCODE_MODE_CHANGE && code != KEYCODE_SHIFT) { - code = label[0].code - } + a.recycle() } diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt index 8e1192e..cb4778d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt @@ -164,7 +164,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL // If the keyboard is set to symbols and the user presses space, we usually should switch back to the letters keyboard. // However, avoid doing that in cases when the EditText for example requires numbers as the input. // We can detect that by the text not changing on pressing Space. - if (keyboardMode != KEYBOARD_LETTERS && code == MyKeyboard.KEYCODE_SPACE) { + if (keyboardMode != KEYBOARD_LETTERS && keyboardMode != KEYBOARD_PHONE && code == MyKeyboard.KEYCODE_SPACE) { val originalText = inputConnection.getExtractedText(ExtractedTextRequest(), 0)?.text ?: return inputConnection.commitText(codeChar.toString(), 1) val newText = inputConnection.getExtractedText(ExtractedTextRequest(), 0)?.text From 45cc59560600ddb612ebfac2104aa27d044e9720 Mon Sep 17 00:00:00 2001 From: merkost Date: Thu, 18 May 2023 13:08:16 +1000 Subject: [PATCH 3/4] Space key background TODO added --- .../com/simplemobiletools/keyboard/views/MyKeyboardView.kt | 2 ++ 1 file changed, 2 insertions(+) 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 dd1f520..e9956d5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -569,6 +569,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut for (i in 0 until keyCount) { val key = keys[i] val code = key.code + + // TODO: Space key background on a KEYBOARD_PHONE should not be applied setupKeyBackground(key, code, canvas) // Switch the character to uppercase if shift is pressed From 22be930c7b84282ef37a2f51babdf64680d1893b Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Thu, 18 May 2023 09:20:35 +0200 Subject: [PATCH 4/4] minor xml style update --- app/src/main/res/layout/activity_main.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 998ff11..4a1cf2c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -60,14 +60,13 @@ android:id="@+id/text_editphone" android:layout_width="match_parent" android:layout_height="wrap_content" - android:inputType="phone" android:layout_marginStart="@dimen/activity_margin" android:layout_marginTop="@dimen/activity_margin" android:layout_marginEnd="@dimen/activity_margin" - android:layout_marginBottom="@dimen/activity_margin" /> + android:layout_marginBottom="@dimen/activity_margin" + android:inputType="phone" /> -