Merge pull request #219 from telextractor/turkish-fix
Fixed Turkish Q layout
This commit is contained in:
commit
4f926ea61c
|
@ -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,8 +212,12 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
|
|||
val originalText = inputConnection.getExtractedText(ExtractedTextRequest(), 0)?.text
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -473,8 +473,12 @@ 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])) {
|
||||
if (context.config.keyboardLanguage == LANGUAGE_TURKISH_Q) {
|
||||
newLabel = newLabel.toString().uppercase(Locale.forLanguageTag("tr"))
|
||||
} else {
|
||||
newLabel = newLabel.toString().uppercase(Locale.getDefault())
|
||||
}
|
||||
}
|
||||
return newLabel
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue