Merge pull request #219 from telextractor/turkish-fix

Fixed Turkish Q layout
This commit is contained in:
Tibor Kaputa 2023-07-26 16:41:22 +02:00 committed by GitHub
commit 4f926ea61c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
} }