Fixed Turkish Q layout

This commit is contained in:
telextractor 2023-07-15 23:18:52 +05:30
parent 0489f9a9b3
commit ffe7b05008
2 changed files with 11 additions and 2 deletions

View File

@ -36,6 +36,7 @@ import com.simplemobiletools.keyboard.interfaces.OnKeyboardActionListener
import com.simplemobiletools.keyboard.views.MyKeyboardView 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_holder
import kotlinx.android.synthetic.main.keyboard_view_keyboard.view.keyboard_view 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/ // based on https://www.androidauthority.com/lets-build-custom-keyboard-android-832362/
class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, SharedPreferences.OnSharedPreferenceChangeListener { class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, SharedPreferences.OnSharedPreferenceChangeListener {
@ -211,8 +212,12 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
val originalText = inputConnection.getExtractedText(ExtractedTextRequest(), 0)?.text val originalText = inputConnection.getExtractedText(ExtractedTextRequest(), 0)?.text
if (Character.isLetter(codeChar) && keyboard!!.mShiftState > ShiftState.OFF) { if (Character.isLetter(codeChar) && keyboard!!.mShiftState > ShiftState.OFF) {
if (baseContext.config.keyboardLanguage == LANGUAGE_TURKISH_Q) {
codeChar = codeChar.toString().uppercase(Locale.forLanguageTag("tr")).single()
} else {
codeChar = Character.toUpperCase(codeChar) 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. // 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. // However, avoid doing that in cases when the EditText for example requires numbers as the input.

View File

@ -473,8 +473,12 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
private fun adjustCase(label: CharSequence): CharSequence? { private fun adjustCase(label: CharSequence): CharSequence? {
var newLabel: CharSequence? = label var newLabel: CharSequence? = label
if (!newLabel.isNullOrEmpty() && mKeyboard!!.mShiftState != ShiftState.OFF && newLabel.length < 3 && Character.isLowerCase(newLabel[0])) { if (!newLabel.isNullOrEmpty() && mKeyboard!!.mShiftState != ShiftState.OFF && newLabel.length < 3 && Character.isLowerCase(newLabel[0])) {
if (context.config.keyboardLanguage == LANGUAGE_TURKISH_Q) {
newLabel = newLabel.toString().uppercase(Locale.forLanguageTag("tr"))
} else {
newLabel = newLabel.toString().uppercase(Locale.getDefault()) newLabel = newLabel.toString().uppercase(Locale.getDefault())
} }
}
return newLabel return newLabel
} }