diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt index d8985a6..5ff51ef 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt @@ -19,4 +19,8 @@ class Config(context: Context) : BaseConfig(context) { var lastExportedClipsFolder: String get() = prefs.getString(LAST_EXPORTED_CLIPS_FOLDER, "")!! set(lastExportedClipsFolder) = prefs.edit().putString(LAST_EXPORTED_CLIPS_FOLDER, lastExportedClipsFolder).apply() + + var keyboardLanguage: String + get() = prefs.getString(KEYBOARD_LANGUAGE, "en")!! + set(keyboardLanguage) = prefs.edit().putString(KEYBOARD_LANGUAGE, keyboardLanguage).apply() } diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt index 260eafb..2b6a40b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt @@ -11,6 +11,7 @@ const val MAX_KEYS_PER_MINI_ROW = 8 const val VIBRATE_ON_KEYPRESS = "vibrate_on_keypress" const val SHOW_POPUP_ON_KEYPRESS = "show_popup_on_keypress" const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder" +const val KEYBOARD_LANGUAGE = "keyboard_language" // differentiate current and pinned clips at the keyboards' Clipboard section const val ITEM_SECTION_LABEL = 0 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 e5a05cd..9e9bf89 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt @@ -9,6 +9,7 @@ import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo.IME_ACTION_NONE import android.view.inputmethod.ExtractedTextRequest import com.simplemobiletools.keyboard.R +import com.simplemobiletools.keyboard.extensions.config import com.simplemobiletools.keyboard.helpers.MyKeyboard import com.simplemobiletools.keyboard.helpers.SHIFT_OFF import com.simplemobiletools.keyboard.helpers.SHIFT_ON_ONE_CHAR @@ -33,7 +34,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL override fun onInitializeInterface() { super.onInitializeInterface() - keyboard = MyKeyboard(this, R.xml.keys_letters_english, enterKeyType) + keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) } override fun onCreateInputView(): View { @@ -63,7 +64,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL } else -> { keyboardMode = KEYBOARD_LETTERS - R.xml.keys_letters_english + getKeyboardLayoutXML() } } @@ -137,7 +138,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL R.xml.keys_symbols } else { keyboardMode = KEYBOARD_LETTERS - R.xml.keys_letters_english + getKeyboardLayoutXML() } keyboard = MyKeyboard(this, keyboardXml, enterKeyType) keyboardView!!.setKeyboard(keyboard!!) @@ -175,7 +176,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL override fun onActionUp() { if (switchToLetters) { keyboardMode = KEYBOARD_LETTERS - keyboard = MyKeyboard(this, R.xml.keys_letters_english, enterKeyType) + keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) val editorInfo = currentInputEditorInfo if (editorInfo != null && editorInfo.inputType != InputType.TYPE_NULL && keyboard?.mShiftState != SHIFT_ON_PERMANENT) { @@ -212,4 +213,11 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL currentInputConnection?.setSelection(newCursorPosition, newCursorPosition) } + + private fun getKeyboardLayoutXML(): Int { + return when (baseContext.config.keyboardLanguage) { + "ru" -> R.xml.keys_letters_russian + else -> R.xml.keys_letters_english + } + } } diff --git a/app/src/main/res/xml/keys_letters_russian.xml b/app/src/main/res/xml/keys_letters_russian.xml new file mode 100644 index 0000000..df046c7 --- /dev/null +++ b/app/src/main/res/xml/keys_letters_russian.xml @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +