diff --git a/app/src/main/java/jp/deadend/noname/skk/QwertyKeyboardView.kt b/app/src/main/java/jp/deadend/noname/skk/QwertyKeyboardView.kt
index 4149b11..fa58e45 100644
--- a/app/src/main/java/jp/deadend/noname/skk/QwertyKeyboardView.kt
+++ b/app/src/main/java/jp/deadend/noname/skk/QwertyKeyboardView.kt
@@ -4,6 +4,7 @@ import android.content.Context
import android.view.KeyEvent
import android.view.MotionEvent
import android.util.AttributeSet
+import jp.deadend.noname.skk.engine.SKKCyrillicState
class QwertyKeyboardView : KeyboardView, KeyboardView.OnKeyboardActionListener {
private lateinit var mService: SKKService
@@ -11,6 +12,7 @@ class QwertyKeyboardView : KeyboardView, KeyboardView.OnKeyboardActionListener {
private val mLatinKeyboard = Keyboard(context, R.xml.qwerty)
private val mSymbolsKeyboard = Keyboard(context, R.xml.symbols)
private val mSymbolsShiftedKeyboard = Keyboard(context, R.xml.symbols_shift)
+ private val mCyrillicKeyboard = Keyboard(context, R.xml.cyrillic)
private var mFlickSensitivitySquared = 100
private var mFlickStartX = -1f
@@ -38,6 +40,8 @@ class QwertyKeyboardView : KeyboardView, KeyboardView.OnKeyboardActionListener {
mFlickSensitivitySquared = sensitivity * sensitivity
}
+ fun setCyrillicMode(isCyrillic: Boolean) { keyboard = if (isCyrillic) mCyrillicKeyboard else mLatinKeyboard }
+
override fun onLongPress(key: Keyboard.Key): Boolean {
if (key.codes[0] == KEYCODE_QWERTY_ENTER) {
mService.keyDownUp(KeyEvent.KEYCODE_SEARCH)
@@ -89,11 +93,20 @@ class QwertyKeyboardView : KeyboardView, KeyboardView.OnKeyboardActionListener {
}
}
KEYCODE_QWERTY_ENTER -> if (!mService.handleEnter()) mService.pressEnter()
- KEYCODE_QWERTY_TOJP -> mService.handleKanaKey()
+ KEYCODE_QWERTY_TOJP -> {
+ if (keyboard === mCyrillicKeyboard) { keyboard = mLatinKeyboard }
+ mService.handleKanaKey()
+ }
KEYCODE_QWERTY_TOSYM -> keyboard = mSymbolsKeyboard
- KEYCODE_QWERTY_TOLATIN -> keyboard = mLatinKeyboard
+ KEYCODE_QWERTY_TOLATIN -> {
+ if (keyboard === mCyrillicKeyboard) {
+ mService.processKey(SKKCyrillicState.KEYCODE_TOGGLE_CYRILLIC)
+ }
+ keyboard = mLatinKeyboard
+ }
+
else -> {
- val code = if (keyboard === mLatinKeyboard && (isShifted xor mFlicked)) {
+ val code = if ((keyboard === mLatinKeyboard || keyboard === mCyrillicKeyboard) && (isShifted xor mFlicked)) {
Character.toUpperCase(primaryCode)
} else {
primaryCode
@@ -111,7 +124,10 @@ class QwertyKeyboardView : KeyboardView, KeyboardView.OnKeyboardActionListener {
override fun swipeRight() {}
- override fun swipeLeft() {}
+ override fun swipeLeft() {
+ keyboard = if (keyboard === mCyrillicKeyboard) mLatinKeyboard else mCyrillicKeyboard
+ mService.processKey(SKKCyrillicState.KEYCODE_TOGGLE_CYRILLIC)
+ }
override fun swipeDown() {}
diff --git a/app/src/main/java/jp/deadend/noname/skk/SKKPrefs.kt b/app/src/main/java/jp/deadend/noname/skk/SKKPrefs.kt
index 867c05d..6117008 100644
--- a/app/src/main/java/jp/deadend/noname/skk/SKKPrefs.kt
+++ b/app/src/main/java/jp/deadend/noname/skk/SKKPrefs.kt
@@ -31,6 +31,10 @@ class SKKPrefs(context: Context) {
get() = prefs.getInt(res.getString(R.string.prefkey_cancel_key), 564) // 564はCtrl+g
set(value) = prefs.edit().putInt(res.getString(R.string.prefkey_cancel_key), value).apply()
+ var cyrillicKey: Int
+ get() = prefs.getInt(res.getString(R.string.prefkey_cyrillic_key), 0)
+ set(value) = prefs.edit().putInt(res.getString(R.string.prefkey_cyrillic_key), value).apply()
+
var toggleKanaKey: Boolean
get() = prefs.getBoolean(res.getString(R.string.prefkey_toggle_kana_key), true)
set(value) = prefs.edit().putBoolean(res.getString(R.string.prefkey_toggle_kana_key), value).apply()
diff --git a/app/src/main/java/jp/deadend/noname/skk/SKKService.kt b/app/src/main/java/jp/deadend/noname/skk/SKKService.kt
index 82c2ce1..74256bd 100644
--- a/app/src/main/java/jp/deadend/noname/skk/SKKService.kt
+++ b/app/src/main/java/jp/deadend/noname/skk/SKKService.kt
@@ -521,6 +521,11 @@ class SKKService : InputMethodService() {
return true
}
+ if ((engineState === SKKHiraganaState || engineState === SKKKatakanaState || engineState === SKKASCIIState || engineState === SKKZenkakuState || engineState === SKKCyrillicState) && encodedKey == skkPrefs.cyrillicKey) {
+ processKey(SKKCyrillicState.KEYCODE_TOGGLE_CYRILLIC)
+ return true
+ }
+
if (engineState === SKKASCIIState && !mEngine.isRegistering) {
return super.onKeyDown(keyCode, event)
}
@@ -758,6 +763,7 @@ class SKKService : InputMethodService() {
when (state) {
SKKASCIIState -> {
val qwerty = mQwertyInputView ?: return
+ qwerty.setCyrillicMode(false)
setInputView(qwerty)
}
SKKHiraganaState -> {
@@ -774,6 +780,11 @@ class SKKService : InputMethodService() {
val abbrev = mAbbrevKeyboardView ?: return
setInputView(abbrev)
}
+ SKKCyrillicState -> {
+ val qwerty = mQwertyInputView ?: return
+ qwerty.setCyrillicMode(true)
+ setInputView(qwerty)
+ }
}
}
diff --git a/app/src/main/java/jp/deadend/noname/skk/engine/SKKASCIIState.kt b/app/src/main/java/jp/deadend/noname/skk/engine/SKKASCIIState.kt
index 3bd33aa..841e3bd 100644
--- a/app/src/main/java/jp/deadend/noname/skk/engine/SKKASCIIState.kt
+++ b/app/src/main/java/jp/deadend/noname/skk/engine/SKKASCIIState.kt
@@ -8,10 +8,14 @@ object SKKASCIIState : SKKState {
override fun handleKanaKey(context: SKKEngine) = context.changeState(SKKHiraganaState)
override fun processKey(context: SKKEngine, pcode: Int) {
- context.commitTextSKK(pcode.toChar().toString(), 1)
+ if (pcode == SKKCyrillicState.KEYCODE_TOGGLE_CYRILLIC) {
+ context.changeState(SKKCyrillicState)
+ } else {
+ context.commitTextSKK(pcode.toChar().toString(), 1)
+ }
}
- override fun afterBackspace(context: SKKEngine) {}
+ override fun afterBackspace(context: SKKEngine) {}
override fun handleCancel(context: SKKEngine) = false
}
diff --git a/app/src/main/java/jp/deadend/noname/skk/engine/SKKCyrillicState.kt b/app/src/main/java/jp/deadend/noname/skk/engine/SKKCyrillicState.kt
new file mode 100644
index 0000000..d7e287c
--- /dev/null
+++ b/app/src/main/java/jp/deadend/noname/skk/engine/SKKCyrillicState.kt
@@ -0,0 +1,45 @@
+package jp.deadend.noname.skk.engine
+
+import android.os.Build
+import jp.deadend.noname.skk.R
+
+// キリル文字モード
+object SKKCyrillicState : SKKState {
+ override val isTransient = false
+ override val icon = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ R.drawable.ic_cyrillic
+ } else {
+ R.drawable.immodeic_cyrillic
+ }
+ private val mCyrillicMap = mapOf(
+ 'q' to "й", 'w' to "ц", 'e' to "у", 'r' to "к", 't' to "е", 'y' to "н", 'u' to "г", 'i' to "ш", 'o' to "щ", 'p' to "з", '-' to "х", '\\' to "ё",
+ 'Q' to "Й", 'W' to "Ц", 'E' to "У", 'R' to "К", 'T' to "Е", 'Y' to "Н", 'U' to "Г", 'I' to "Ш", 'O' to "Щ", 'P' to "З", '=' to "Х", '_' to "Ё",
+ 'a' to "ф", 's' to "ы", 'd' to "в", 'f' to "а", 'g' to "п", 'h' to "р", 'j' to "о", 'k' to "л", 'l' to "д", '/' to "ж", ':' to "ъ",
+ 'A' to "Ф", 'S' to "Ы", 'D' to "В", 'F' to "А", 'G' to "П", 'H' to "Р", 'J' to "О", 'K' to "Л", 'L' to "Д", '?' to "Ж", '*' to "Ъ",
+ 'z' to "я", 'x' to "ч", 'c' to "с", 'v' to "м", 'b' to "и", 'n' to "т", 'm' to "ь", ',' to "б", '.' to "ю", ']' to "э",
+ 'Z' to "Я", 'X' to "Ч", 'C' to "С", 'V' to "М", 'B' to "И", 'N' to "Т", 'M' to "Ь", '<' to "Б", '>' to "Ю", '}' to "Э"
+ )
+ const val KEYCODE_TOGGLE_CYRILLIC = -1012
+
+ override fun handleKanaKey(context: SKKEngine) {
+ context.changeState(SKKHiraganaState)
+ }
+
+ override fun processKey(context: SKKEngine, pcode: Int) {
+ if (pcode == KEYCODE_TOGGLE_CYRILLIC) {
+ context.changeState(SKKASCIIState)
+ return
+ }
+
+ val cy = mCyrillicMap[pcode.toChar()]
+ if (cy != null) {
+ context.commitTextSKK(cy, 1)
+ } else {
+ context.commitTextSKK(pcode.toChar().toString(), 1)
+ }
+ }
+
+ override fun afterBackspace(context: SKKEngine) {}
+
+ override fun handleCancel(context: SKKEngine) = false
+}
diff --git a/app/src/main/java/jp/deadend/noname/skk/engine/SKKEngine.kt b/app/src/main/java/jp/deadend/noname/skk/engine/SKKEngine.kt
index 665ead6..f73160a 100644
--- a/app/src/main/java/jp/deadend/noname/skk/engine/SKKEngine.kt
+++ b/app/src/main/java/jp/deadend/noname/skk/engine/SKKEngine.kt
@@ -661,6 +661,10 @@ class SKKEngine(
changeState(SKKAbbrevState)
return true
}
+ SKKCyrillicState.KEYCODE_TOGGLE_CYRILLIC -> {
+ changeState(SKKCyrillicState)
+ return true
+ }
}
return false
diff --git a/app/src/main/java/jp/deadend/noname/skk/engine/SKKZenkakuState.kt b/app/src/main/java/jp/deadend/noname/skk/engine/SKKZenkakuState.kt
index 8bfe423..9bfadff 100644
--- a/app/src/main/java/jp/deadend/noname/skk/engine/SKKZenkakuState.kt
+++ b/app/src/main/java/jp/deadend/noname/skk/engine/SKKZenkakuState.kt
@@ -18,7 +18,11 @@ object SKKZenkakuState : SKKState {
}
override fun processKey(context: SKKEngine, pcode: Int) {
- context.commitTextSKK(hankaku2zenkaku(pcode).toChar().toString(), 1)
+ if (pcode == SKKCyrillicState.KEYCODE_TOGGLE_CYRILLIC) {
+ context.changeState(SKKCyrillicState)
+ } else {
+ context.commitTextSKK(hankaku2zenkaku(pcode).toChar().toString(), 1)
+ }
}
override fun afterBackspace(context: SKKEngine) {}
diff --git a/app/src/main/res/drawable/ic_cyrillic.xml b/app/src/main/res/drawable/ic_cyrillic.xml
new file mode 100644
index 0000000..7952984
--- /dev/null
+++ b/app/src/main/res/drawable/ic_cyrillic.xml
@@ -0,0 +1,8 @@
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a35942a..aafe0d1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -49,6 +49,7 @@
PrefKeyKanaKey
PrefKeyToggleKanaKey
PrefKeyCancelKey
+ PrefKeyCyrillicKey
PrefKeyCandidatesSize
PrefKeyUseCandidatesView
PrefKeyFlickSensitivity
diff --git a/app/src/main/res/xml/cyrillic.xml b/app/src/main/res/xml/cyrillic.xml
new file mode 100644
index 0000000..b073245
--- /dev/null
+++ b/app/src/main/res/xml/cyrillic.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/xml/prefs_hardkey.xml b/app/src/main/res/xml/prefs_hardkey.xml
index 185b9b9..27bddfe 100644
--- a/app/src/main/res/xml/prefs_hardkey.xml
+++ b/app/src/main/res/xml/prefs_hardkey.xml
@@ -26,6 +26,15 @@
app:positiveButtonText="OK"
app:iconSpaceReserved="false"
/>
+