Getting to a stable version...

This commit is contained in:
zb
2023-09-05 11:03:45 +02:00
parent fa02792649
commit 980aa88381
9 changed files with 104 additions and 284 deletions

View File

@@ -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
)
}
}