From 980aa8838136e8aaf2e7e90312c7c351f6329aab Mon Sep 17 00:00:00 2001 From: Nehemiah of Zebulun Date: Tue, 5 Sep 2023 11:03:45 +0200 Subject: [PATCH] Getting to a stable version... --- app/src/main/java/net/mezimmah/wkt9/WKT9.kt | 16 ++- .../mezimmah/wkt9/inputmode/AlphaInputMode.kt | 136 ++---------------- .../mezimmah/wkt9/inputmode/BaseInputMode.kt | 34 ++++- .../mezimmah/wkt9/inputmode/FNInputMode.kt | 37 ++--- .../mezimmah/wkt9/inputmode/IdleInputMode.kt | 33 ++--- .../wkt9/inputmode/NumericInputMode.kt | 110 ++------------ .../mezimmah/wkt9/inputmode/WordInputMode.kt | 18 +-- .../wkt9/keypad/KeyCommandResolver.kt | 2 + .../mezimmah/wkt9/keypad/KeyEventResult.kt | 2 +- 9 files changed, 104 insertions(+), 284 deletions(-) diff --git a/app/src/main/java/net/mezimmah/wkt9/WKT9.kt b/app/src/main/java/net/mezimmah/wkt9/WKT9.kt index f9ecd85..1810b8f 100644 --- a/app/src/main/java/net/mezimmah/wkt9/WKT9.kt +++ b/app/src/main/java/net/mezimmah/wkt9/WKT9.kt @@ -100,7 +100,7 @@ class WKT9: InputMethodService(), SpellCheckerSession.SpellCheckerSessionListene private var spellCheckerSession: SpellCheckerSession? = null // UI - private lateinit var inputView: View + private var inputView: View? = null private var toast: Toast? = null // Whisper @@ -138,7 +138,7 @@ class WKT9: InputMethodService(), SpellCheckerSession.SpellCheckerSessionListene } @SuppressLint("InflateParams") - override fun onCreateInputView(): View { + override fun onCreateInputView(): View? { inputView = layoutInflater.inflate(R.layout.suggestions, null) return inputView @@ -290,7 +290,7 @@ class WKT9: InputMethodService(), SpellCheckerSession.SpellCheckerSessionListene } private fun clearCandidateUI() { - val candidatesView = inputView.findViewById(R.id.suggestions) + val candidatesView = inputView?.findViewById(R.id.suggestions) ?: return candidatesView.removeAllViews() } @@ -420,7 +420,7 @@ class WKT9: InputMethodService(), SpellCheckerSession.SpellCheckerSessionListene if (res.updateWordStatus) onUpdateWordStatus() if (res.focus) onFocus() if (res.switchInputMode != null) onSwitchInputMode(res.switchInputMode) - if (res.functionMode) onFunctionMode() + if (res.toggleFunctionMode) onToggleFunctionMode() if (res.increaseVolume) onIncreaseVolume() if (res.decreaseVolume) onDecreaseVolume() if (res.increaseBrightness) onIncreaseBrightness() @@ -442,7 +442,7 @@ class WKT9: InputMethodService(), SpellCheckerSession.SpellCheckerSessionListene } private fun loadCandidates(highLight: Int? = null) { - val candidatesView = inputView.findViewById(R.id.suggestions) + val candidatesView = inputView?.findViewById(R.id.suggestions) ?: return candidates.forEachIndexed { index, candidate -> val layout = if (index == highLight) R.layout.current_suggestion else R.layout.suggestion @@ -532,8 +532,10 @@ class WKT9: InputMethodService(), SpellCheckerSession.SpellCheckerSessionListene requestShowSelf(InputMethodManager.SHOW_IMPLICIT) } - private fun onFunctionMode() { - enableInputMode(WKT9InputMode.FN) + private fun onToggleFunctionMode() { + if (inputMode is FNInputMode) enableInputMode(lastInputMode) + else enableInputMode(WKT9InputMode.FN) + updateInputStatus() } diff --git a/app/src/main/java/net/mezimmah/wkt9/inputmode/AlphaInputMode.kt b/app/src/main/java/net/mezimmah/wkt9/inputmode/AlphaInputMode.kt index b38827d..9575c5a 100644 --- a/app/src/main/java/net/mezimmah/wkt9/inputmode/AlphaInputMode.kt +++ b/app/src/main/java/net/mezimmah/wkt9/inputmode/AlphaInputMode.kt @@ -3,29 +3,20 @@ package net.mezimmah.wkt9.inputmode import android.util.Log import net.mezimmah.wkt9.keypad.Command import net.mezimmah.wkt9.keypad.Key -import net.mezimmah.wkt9.keypad.KeyCommandResolver import net.mezimmah.wkt9.keypad.KeyEventResult -import net.mezimmah.wkt9.keypad.KeyLayout -import java.lang.StringBuilder -class AlphaInputMode: InputMode { +class AlphaInputMode: BaseInputMode() { private val tag = "WKT9" - private val keyCommandResolver: KeyCommandResolver = KeyCommandResolver.getBasic() - private var newKey = true - private var keyIndex = 0 - private var lastKey: Key? = null - - override val mode: String = "alpha" - - override var status: Status = Status.CAP - private set init { - Log.d(tag, "Started alpha input mode.") + mode = "alpha" + status = Status.CAP + + Log.d(tag, "Started $mode input mode.") } override fun onKeyDown(key: Key, composing: Boolean): KeyEventResult { - keyStats(key) + super.onKeyDown(key, composing) return when(keyCommandResolver.getCommand(key)) { Command.BACK -> KeyEventResult(consumed = false) @@ -41,7 +32,7 @@ class AlphaInputMode: InputMode { return when(keyCommandResolver.getCommand(key, true)) { Command.RECORD -> record(composing) Command.NUMBER -> commitNumber(key, composing) - Command.SWITCH_MODE -> switchMode(composing) + Command.SWITCH_MODE -> switchMode(WKT9InputMode.NUMERIC, composing) else -> KeyEventResult(true) } } @@ -58,6 +49,7 @@ class AlphaInputMode: InputMode { return when(keyCommandResolver.getCommand(key, after = true)) { Command.BACK -> goBack(composing) Command.CHARACTER -> composeCharacter(key, composing) + Command.FN -> functionMode() Command.SHIFT_MODE -> shiftMode() Command.SPACE -> finalizeWordOrSentence(composing) else -> KeyEventResult() @@ -71,102 +63,10 @@ class AlphaInputMode: InputMode { } } - private fun deleteCharacter(composing: Boolean): KeyEventResult { - return KeyEventResult( - finishComposing = composing, - deleteBeforeCursor = 1 - ) - } - - private fun commitNumber(key: Key, composing: Boolean): KeyEventResult { - val code = KeyLayout.numeric[key] ?: return KeyEventResult(true) - - return KeyEventResult( - consumed = true, - finishComposing = composing, - commit = code.toString() - ) - } - - private fun composeCharacter(key: Key, composing: Boolean): KeyEventResult { + override fun composeCharacter(key: Key, composing: Boolean): KeyEventResult { if (composing && !newKey) return navigateRight() - val layout = KeyLayout.en_US[key] ?: return KeyEventResult(true) - val candidates = layout.map { it.toString() } - - return KeyEventResult( - consumed = true, - finishComposing = composing, - startComposing = true, - candidates = candidates, - timeout = 400 - ) - } - - private fun finalizeWordOrSentence(composing: Boolean): KeyEventResult { - if (composing && !newKey) return navigateRight() - - return KeyEventResult( - finishComposing = composing, - startComposing = true, - candidates = listOf(" ", ". ", "? ", "! ", ", ", ": ", "; "), - timeout = 700 - ) - } - - private fun focus(): KeyEventResult { - return KeyEventResult( - consumed = true, - focus = true - ) - } - - private fun goBack(composing: Boolean): KeyEventResult { - return KeyEventResult( - consumed = false, - finishComposing = composing - ) - } - - private fun goHome(repeat: Int, composing: Boolean): KeyEventResult { - if (repeat > 1) return KeyEventResult(true) - - return KeyEventResult( - consumed = true, - finishComposing = composing, - goHome = true - ) - } - - private fun keyStats(key: Key) { - when (key != lastKey) { - true -> { - newKey = true - keyIndex = 0 - } - false -> { - newKey = false - keyIndex++ - } - } - - lastKey = key - } - - private fun navigateLeft(): KeyEventResult { - return KeyEventResult(left = true) - } - - private fun navigateRight(): KeyEventResult { - return KeyEventResult(right = true) - } - - private fun record(composing: Boolean): KeyEventResult { - return KeyEventResult( - consumed = true, - finishComposing = composing, - record = true - ) + return super.composeCharacter(key, composing) } private fun shiftMode(): KeyEventResult { @@ -181,20 +81,4 @@ class AlphaInputMode: InputMode { updateInputStatus = true ) } - - private fun switchMode(composing: Boolean): KeyEventResult { - return KeyEventResult( - consumed = true, - finishComposing = composing, - switchInputMode = WKT9InputMode.NUMERIC - ) - } - - private fun transcribe(composing: Boolean): KeyEventResult { - return KeyEventResult( - consumed = true, - finishComposing = composing, - transcribe = true - ) - } } \ No newline at end of file diff --git a/app/src/main/java/net/mezimmah/wkt9/inputmode/BaseInputMode.kt b/app/src/main/java/net/mezimmah/wkt9/inputmode/BaseInputMode.kt index 90d41ef..b7a2c00 100644 --- a/app/src/main/java/net/mezimmah/wkt9/inputmode/BaseInputMode.kt +++ b/app/src/main/java/net/mezimmah/wkt9/inputmode/BaseInputMode.kt @@ -6,11 +6,12 @@ import net.mezimmah.wkt9.keypad.KeyEventResult import net.mezimmah.wkt9.keypad.KeyLayout open class BaseInputMode: InputMode { - protected val keyCommandResolver: KeyCommandResolver = KeyCommandResolver.getBasic() protected var newKey = true protected var keyIndex = 0 protected var lastKey: Key? = null + protected open val keyCommandResolver: KeyCommandResolver = KeyCommandResolver.getBasic() + override lateinit var mode: String protected set @@ -49,7 +50,30 @@ open class BaseInputMode: InputMode { ) } - protected open fun deleteCharacter(repeat: Int = 0, composing: Boolean): KeyEventResult { + protected open fun composeCharacter(key: Key, composing: Boolean): KeyEventResult { + val layout = KeyLayout.en_US[key] ?: return KeyEventResult(true) + val candidates = layout.map { it.toString() } + + return KeyEventResult( + consumed = true, + finishComposing = composing, + startComposing = true, + candidates = candidates, + timeout = 1200 + ) + } + + protected fun composeNumber(key: Key, composing: Boolean): KeyEventResult { + val code = KeyLayout.numeric[key] ?: return KeyEventResult(true) + + return KeyEventResult( + consumed = true, + finishComposing = composing, + commit = code.toString() + ) + } + + protected open fun deleteCharacter(composing: Boolean): KeyEventResult { return KeyEventResult( finishComposing = composing, deleteBeforeCursor = 1 @@ -77,7 +101,7 @@ open class BaseInputMode: InputMode { protected fun functionMode(): KeyEventResult { return KeyEventResult( consumed = true, - functionMode = true + toggleFunctionMode = true ) } @@ -120,11 +144,11 @@ open class BaseInputMode: InputMode { ) } - protected open fun switchMode(composing: Boolean): KeyEventResult { + protected open fun switchMode(mode: WKT9InputMode, composing: Boolean): KeyEventResult { return KeyEventResult( consumed = true, finishComposing = composing, - switchInputMode = WKT9InputMode.ALPHA + switchInputMode = mode ) } diff --git a/app/src/main/java/net/mezimmah/wkt9/inputmode/FNInputMode.kt b/app/src/main/java/net/mezimmah/wkt9/inputmode/FNInputMode.kt index 6bcfaca..964dd68 100644 --- a/app/src/main/java/net/mezimmah/wkt9/inputmode/FNInputMode.kt +++ b/app/src/main/java/net/mezimmah/wkt9/inputmode/FNInputMode.kt @@ -6,11 +6,10 @@ import net.mezimmah.wkt9.keypad.Key import net.mezimmah.wkt9.keypad.KeyCommandResolver import net.mezimmah.wkt9.keypad.KeyEventResult -class FNInputMode: InputMode { +class FNInputMode: BaseInputMode() { private val tag = "WKT9" - private val parentKeyCommandResolver: KeyCommandResolver = KeyCommandResolver.getBasic() - private val keyCommandResolver: KeyCommandResolver = KeyCommandResolver( - parent = parentKeyCommandResolver, + override val keyCommandResolver: KeyCommandResolver = KeyCommandResolver( + parent = super.keyCommandResolver, onShort = HashMap(mapOf( Key.UP to Command.VOL_UP, @@ -23,49 +22,55 @@ class FNInputMode: InputMode { Key.UP to Command.VOL_UP, Key.DOWN to Command.VOL_DOWN, Key.LEFT to Command.BRIGHTNESS_DOWN, - Key.RIGHT to Command.BRIGHTNESS_UP + Key.RIGHT to Command.BRIGHTNESS_UP, + + Key.BACK to Command.HOME )) ) - override val mode: String = "fn" - - override var status: Status = Status.NA - private set - init { + mode = "fn" + status = Status.NA + Log.d(tag, "Started $mode input mode.") } override fun onKeyDown(key: Key, composing: Boolean): KeyEventResult { return when(keyCommandResolver.getCommand(key)) { + Command.BACK -> KeyEventResult(false) Command.VOL_UP -> volumeUp() Command.VOL_DOWN -> volumeDown() Command.BRIGHTNESS_DOWN -> brightnessDown() Command.BRIGHTNESS_UP -> brightnessUp() - else -> KeyEventResult(false) + else -> KeyEventResult(true) } } override fun onKeyLongDown(key: Key, composing: Boolean): KeyEventResult { - return KeyEventResult(false) + return KeyEventResult(true) } override fun onKeyDownRepeatedly(key: Key, repeat: Int, composing: Boolean): KeyEventResult { - return when(keyCommandResolver.getCommand(key, repeat = repeat)) { + return when(keyCommandResolver.getCommand(key, repeat = repeat)) { + Command.HOME -> goHome(repeat, composing) Command.VOL_UP -> volumeUp() Command.VOL_DOWN -> volumeDown() Command.BRIGHTNESS_DOWN -> brightnessDown() Command.BRIGHTNESS_UP -> brightnessUp() - else -> KeyEventResult(false) + else -> KeyEventResult(true) } } override fun afterKeyDown(key: Key, composing: Boolean): KeyEventResult { - return KeyEventResult(false) + return when(keyCommandResolver.getCommand(key, after = true)) { + Command.BACK -> goBack(composing) + Command.FN -> functionMode() + else -> KeyEventResult(true) + } } override fun afterKeyLongDown(key: Key, keyDownMS: Long, composing: Boolean): KeyEventResult { - return KeyEventResult(false) + return KeyEventResult(true) } private fun brightnessDown(): KeyEventResult { diff --git a/app/src/main/java/net/mezimmah/wkt9/inputmode/IdleInputMode.kt b/app/src/main/java/net/mezimmah/wkt9/inputmode/IdleInputMode.kt index 6c57368..204e5b8 100644 --- a/app/src/main/java/net/mezimmah/wkt9/inputmode/IdleInputMode.kt +++ b/app/src/main/java/net/mezimmah/wkt9/inputmode/IdleInputMode.kt @@ -3,24 +3,21 @@ package net.mezimmah.wkt9.inputmode import android.util.Log import net.mezimmah.wkt9.keypad.Command import net.mezimmah.wkt9.keypad.Key -import net.mezimmah.wkt9.keypad.KeyCommandResolver import net.mezimmah.wkt9.keypad.KeyEventResult -class IdleInputMode : InputMode { - override val mode: String = "idle" - - override var status: Status = Status.NA - private set - +class IdleInputMode : BaseInputMode() { private val tag = "WKT9" - private val keyCommandResolver: KeyCommandResolver = KeyCommandResolver.getBasic() init { + mode = "idle" + status = Status.NA + Log.d(tag, "Started $mode input mode.") } override fun onKeyDown(key: Key, composing: Boolean): KeyEventResult { return when(keyCommandResolver.getCommand(key)) { + Command.FN -> KeyEventResult(true) else -> KeyEventResult(false) } } @@ -33,14 +30,15 @@ class IdleInputMode : InputMode { override fun onKeyDownRepeatedly(key: Key, repeat: Int, composing: Boolean): KeyEventResult { return when(keyCommandResolver.getCommand(key, repeat = repeat)) { - Command.HOME -> goHome(repeat) + Command.HOME -> goHome(repeat, composing) else -> KeyEventResult(false) } } override fun afterKeyDown(key: Key, composing: Boolean): KeyEventResult { return when(keyCommandResolver.getCommand(key, after = true)) { - Command.BACK -> goBack() + Command.BACK -> goBack(composing) + Command.FN -> functionMode() else -> KeyEventResult(false) } } @@ -50,19 +48,4 @@ class IdleInputMode : InputMode { else -> KeyEventResult(false) } } - - private fun goBack(): KeyEventResult { - return KeyEventResult( - consumed = false, - ) - } - - private fun goHome(repeat: Int): KeyEventResult { - if (repeat > 1) return KeyEventResult(true) - - return KeyEventResult( - consumed = true, - goHome = true - ) - } } \ No newline at end of file diff --git a/app/src/main/java/net/mezimmah/wkt9/inputmode/NumericInputMode.kt b/app/src/main/java/net/mezimmah/wkt9/inputmode/NumericInputMode.kt index ce7b13b..f021bba 100644 --- a/app/src/main/java/net/mezimmah/wkt9/inputmode/NumericInputMode.kt +++ b/app/src/main/java/net/mezimmah/wkt9/inputmode/NumericInputMode.kt @@ -5,13 +5,11 @@ import net.mezimmah.wkt9.keypad.Command import net.mezimmah.wkt9.keypad.Key import net.mezimmah.wkt9.keypad.KeyCommandResolver import net.mezimmah.wkt9.keypad.KeyEventResult -import net.mezimmah.wkt9.keypad.KeyLayout -class NumericInputMode: InputMode { +class NumericInputMode: BaseInputMode() { private val tag = "WKT9" - private val parentKeyCommandResolver: KeyCommandResolver = KeyCommandResolver.getBasic() - private val keyCommandResolver: KeyCommandResolver = KeyCommandResolver( - parent = parentKeyCommandResolver, + override val keyCommandResolver: KeyCommandResolver = KeyCommandResolver( + parent = super.keyCommandResolver, onLong = HashMap(mapOf( Key.N0 to Command.SPACE, @@ -37,23 +35,22 @@ class NumericInputMode: InputMode { Key.N7 to Command.NUMBER, Key.N8 to Command.NUMBER, Key.N9 to Command.NUMBER + )), + + onRepeat = HashMap(mapOf( + Key.BACK to Command.HOME )) ) - private var newKey = true - private var keyIndex = 0 - private var lastKey: Key? = null - - override val mode: String = "numeric" - - override var status: Status = Status.NUM - private set init { - Log.d(tag, "Started numeric input mode.") + mode = "numeric" + status = Status.NUM + + Log.d(tag, "Started $mode input mode.") } override fun onKeyDown(key: Key, composing: Boolean): KeyEventResult { - keyStats(key) + super.onKeyDown(key, composing) return when(keyCommandResolver.getCommand(key)) { Command.BACK -> KeyEventResult(consumed = false) @@ -68,13 +65,13 @@ class NumericInputMode: InputMode { return when(keyCommandResolver.getCommand(key, true)) { Command.CHARACTER -> composeCharacter(key, composing) Command.SPACE -> insertSpace(composing) - Command.SWITCH_MODE -> switchMode(composing) + Command.SWITCH_MODE -> switchMode(WKT9InputMode.WORD, composing) else -> KeyEventResult(true) } } override fun onKeyDownRepeatedly(key: Key, repeat: Int, composing: Boolean): KeyEventResult { - return when(keyCommandResolver.getCommand(key, repeat = repeat)) { + return when(keyCommandResolver.getCommand(key, repeat = repeat)) { Command.HOME -> goHome(repeat, composing) Command.DELETE -> deleteCharacter(composing) else -> KeyEventResult() @@ -84,6 +81,7 @@ class NumericInputMode: InputMode { override fun afterKeyDown(key: Key, composing: Boolean): KeyEventResult { return when(keyCommandResolver.getCommand(key, after = true)) { Command.BACK -> goBack(composing) + Command.FN -> functionMode() Command.NUMBER -> composeNumber(key, composing) else -> KeyEventResult() } @@ -95,53 +93,6 @@ class NumericInputMode: InputMode { } } - private fun deleteCharacter(composing: Boolean): KeyEventResult { - return KeyEventResult( - finishComposing = composing, - deleteBeforeCursor = 1 - ) - } - - private fun composeCharacter(key: Key, composing: Boolean): KeyEventResult { - val layout = KeyLayout.en_US[key] ?: return KeyEventResult(true) - val candidates = layout.map { it.toString() } - - return KeyEventResult( - consumed = true, - finishComposing = composing, - startComposing = true, - candidates = candidates, - timeout = 1200 - ) - } - - private fun composeNumber(key: Key, composing: Boolean): KeyEventResult { - val code = KeyLayout.numeric[key] ?: return KeyEventResult(true) - - return KeyEventResult( - consumed = true, - finishComposing = composing, - commit = code.toString() - ) - } - - private fun goBack(composing: Boolean): KeyEventResult { - return KeyEventResult( - consumed = false, - finishComposing = composing - ) - } - - private fun goHome(repeat: Int, composing: Boolean): KeyEventResult { - if (repeat > 1) return KeyEventResult(true) - - return KeyEventResult( - consumed = true, - finishComposing = composing, - goHome = true - ) - } - private fun insertSpace(composing: Boolean): KeyEventResult { return KeyEventResult( consumed = true, @@ -149,35 +100,4 @@ class NumericInputMode: InputMode { commit = " " ) } - - private fun keyStats(key: Key) { - when (key != lastKey) { - true -> { - newKey = true - keyIndex = 0 - } - false -> { - newKey = false - keyIndex++ - } - } - - lastKey = key - } - - private fun navigateLeft(): KeyEventResult { - return KeyEventResult(left = true) - } - - private fun navigateRight(): KeyEventResult { - return KeyEventResult(right = true) - } - - private fun switchMode(composing: Boolean): KeyEventResult { - return KeyEventResult( - consumed = true, - finishComposing = composing, - switchInputMode = WKT9InputMode.WORD - ) - } } \ No newline at end of file diff --git a/app/src/main/java/net/mezimmah/wkt9/inputmode/WordInputMode.kt b/app/src/main/java/net/mezimmah/wkt9/inputmode/WordInputMode.kt index ecfc1c2..5a6e0bb 100644 --- a/app/src/main/java/net/mezimmah/wkt9/inputmode/WordInputMode.kt +++ b/app/src/main/java/net/mezimmah/wkt9/inputmode/WordInputMode.kt @@ -23,8 +23,7 @@ class WordInputMode: BaseInputMode() { return when(keyCommandResolver.getCommand(key)) { Command.BACK -> KeyEventResult(consumed = false) - Command.DELETE -> deleteCharacter(0, composing) - Command.FN -> functionMode() + Command.DELETE -> deleteCharacter(composing) Command.LEFT -> navigateLeft() Command.RIGHT -> navigateRight() Command.SELECT -> focus() @@ -35,7 +34,7 @@ class WordInputMode: BaseInputMode() { override fun onKeyLongDown(key: Key, composing: Boolean): KeyEventResult { return when(keyCommandResolver.getCommand(key, true)) { Command.RECORD -> record(composing) - Command.SWITCH_MODE -> switchMode(composing) + Command.SWITCH_MODE -> switchMode(WKT9InputMode.ALPHA, composing) Command.NUMBER -> commitNumber(key, composing) else -> KeyEventResult(true) } @@ -44,7 +43,7 @@ class WordInputMode: BaseInputMode() { override fun onKeyDownRepeatedly(key: Key, repeat: Int, composing: Boolean): KeyEventResult { return when(keyCommandResolver.getCommand(key, repeat = repeat)) { Command.HOME -> goHome(repeat, composing) - Command.DELETE -> deleteCharacter(repeat, composing) + Command.DELETE -> deleteCharacter(composing) else -> KeyEventResult() } } @@ -53,6 +52,7 @@ class WordInputMode: BaseInputMode() { return when(keyCommandResolver.getCommand(key, after = true)) { Command.BACK -> goBack(composing) Command.CHARACTER -> buildCodeWord(key, composing) + Command.FN -> functionMode() Command.SHIFT_MODE -> shiftMode(composing) Command.SPACE -> finalizeWordOrSentence(composing) else -> KeyEventResult() @@ -66,10 +66,10 @@ class WordInputMode: BaseInputMode() { } } - override fun deleteCharacter(repeat: Int, composing: Boolean): KeyEventResult { - if (repeat == 0) codeWord.clear() + override fun deleteCharacter(composing: Boolean): KeyEventResult { + codeWord.clear() - return super.deleteCharacter(repeat, composing) + return super.deleteCharacter(composing) } override fun finalizeWordOrSentence(composing: Boolean): KeyEventResult { @@ -96,10 +96,10 @@ class WordInputMode: BaseInputMode() { return super.record(composing) } - override fun switchMode(composing: Boolean): KeyEventResult { + override fun switchMode(mode: WKT9InputMode, composing: Boolean): KeyEventResult { reset() - return super.switchMode(composing) + return super.switchMode(mode, composing) } private fun buildCodeWord(key: Key, composing: Boolean): KeyEventResult { diff --git a/app/src/main/java/net/mezimmah/wkt9/keypad/KeyCommandResolver.kt b/app/src/main/java/net/mezimmah/wkt9/keypad/KeyCommandResolver.kt index 22f6e39..2ce27f2 100644 --- a/app/src/main/java/net/mezimmah/wkt9/keypad/KeyCommandResolver.kt +++ b/app/src/main/java/net/mezimmah/wkt9/keypad/KeyCommandResolver.kt @@ -71,6 +71,8 @@ class KeyCommandResolver ( Key.BACK to Command.BACK, Key.POUND to Command.SHIFT_MODE, + + Key.FN to Command.FN )), afterLong = HashMap(mapOf( diff --git a/app/src/main/java/net/mezimmah/wkt9/keypad/KeyEventResult.kt b/app/src/main/java/net/mezimmah/wkt9/keypad/KeyEventResult.kt index e188ca4..31c4c97 100644 --- a/app/src/main/java/net/mezimmah/wkt9/keypad/KeyEventResult.kt +++ b/app/src/main/java/net/mezimmah/wkt9/keypad/KeyEventResult.kt @@ -23,7 +23,7 @@ data class KeyEventResult( val updateWordStatus: Boolean = false, val focus: Boolean = false, val switchInputMode: WKT9InputMode? = null, - val functionMode: Boolean = false, + val toggleFunctionMode: Boolean = false, val increaseVolume: Boolean = false, val decreaseVolume: Boolean = false, val increaseBrightness: Boolean = false,