From ffe7b05008d48da54347cb0e1a71667274fec599 Mon Sep 17 00:00:00 2001 From: telextractor Date: Sat, 15 Jul 2023 23:18:52 +0530 Subject: [PATCH] Fixed Turkish Q layout --- .../keyboard/services/SimpleKeyboardIME.kt | 7 ++++++- .../com/simplemobiletools/keyboard/views/MyKeyboardView.kt | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) 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 8e73c94..81364c2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt @@ -36,6 +36,7 @@ import com.simplemobiletools.keyboard.interfaces.OnKeyboardActionListener import com.simplemobiletools.keyboard.views.MyKeyboardView import kotlinx.android.synthetic.main.keyboard_view_keyboard.view.keyboard_holder import kotlinx.android.synthetic.main.keyboard_view_keyboard.view.keyboard_view +import java.util.Locale // based on https://www.androidauthority.com/lets-build-custom-keyboard-android-832362/ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, SharedPreferences.OnSharedPreferenceChangeListener { @@ -211,7 +212,11 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared val originalText = inputConnection.getExtractedText(ExtractedTextRequest(), 0)?.text if (Character.isLetter(codeChar) && keyboard!!.mShiftState > ShiftState.OFF) { - codeChar = Character.toUpperCase(codeChar) + if (baseContext.config.keyboardLanguage == LANGUAGE_TURKISH_Q) { + codeChar = codeChar.toString().uppercase(Locale.forLanguageTag("tr")).single() + } else { + codeChar = Character.toUpperCase(codeChar) + } } // If the keyboard is set to symbols and the user presses space, we usually should switch back to the letters keyboard. 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 b5099eb..cbb2a0a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -473,7 +473,11 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut private fun adjustCase(label: CharSequence): CharSequence? { var newLabel: CharSequence? = label if (!newLabel.isNullOrEmpty() && mKeyboard!!.mShiftState != ShiftState.OFF && newLabel.length < 3 && Character.isLowerCase(newLabel[0])) { - newLabel = newLabel.toString().uppercase(Locale.getDefault()) + if (context.config.keyboardLanguage == LANGUAGE_TURKISH_Q) { + newLabel = newLabel.toString().uppercase(Locale.forLanguageTag("tr")) + } else { + newLabel = newLabel.toString().uppercase(Locale.getDefault()) + } } return newLabel }