50 lines
1.6 KiB
Kotlin
50 lines
1.6 KiB
Kotlin
package net.mezimmah.wkt9.inputmode
|
|
|
|
import android.util.Log
|
|
import net.mezimmah.wkt9.keypad.Command
|
|
import net.mezimmah.wkt9.keypad.KeyCommandResolver
|
|
import net.mezimmah.wkt9.keypad.Key
|
|
import net.mezimmah.wkt9.keypad.KeyEventResult
|
|
import java.lang.StringBuilder
|
|
|
|
class NumericInputMode: InputMode {
|
|
private val tag = "WKT9"
|
|
private val keyCommandResolver: KeyCommandResolver = KeyCommandResolver.getBasic()
|
|
private val codeWord = StringBuilder()
|
|
|
|
override var status: Status = Status.NUM
|
|
private set
|
|
|
|
override fun onKeyDown(key: Key): KeyEventResult {
|
|
return when(keyCommandResolver.getCommand(key)) {
|
|
Command.CHARACTER -> buildCodeWord(key)
|
|
// Command.SELECT -> true
|
|
// Command.DELETE -> delete()
|
|
// Command.SPACE -> finalizeWordOrSentence()
|
|
// Command.CYCLE_CANDIDATES -> cycleCandidates()
|
|
else -> KeyEventResult(consumed = true)
|
|
}
|
|
}
|
|
|
|
override fun onKeyLongDown(key: Key): KeyEventResult {
|
|
return KeyEventResult(consumed = false)
|
|
}
|
|
|
|
override fun onKeyDownRepeatedly(key: Key, repeat: Int): KeyEventResult {
|
|
return KeyEventResult(consumed = false)
|
|
}
|
|
|
|
override fun afterKeyDown(key: Key): KeyEventResult {
|
|
return KeyEventResult(consumed = false)
|
|
}
|
|
|
|
override fun afterKeyLongDown(key: Key, keyDownMS: Long): KeyEventResult {
|
|
return KeyEventResult(consumed = false)
|
|
}
|
|
|
|
private fun buildCodeWord(key: Key): KeyEventResult {
|
|
Log.d(tag, "GR8!")
|
|
|
|
return KeyEventResult(consumed = true)
|
|
}
|
|
} |