This commit is contained in:
Nehemiah of Zebulun 2023-08-29 16:52:31 +02:00
parent d6b94ce461
commit e5f7caab0f
18 changed files with 94 additions and 94 deletions

View File

@ -490,54 +490,50 @@ class WKT9: InputMethodService() {
inputStatus = Status.UPPER
candidatesToUpperCase()
showStatusIcon(R.drawable.shift)
}
Status.UPPER -> {
inputStatus = Status.LOWER
candidatesToLowerCase()
showStatusIcon(R.drawable.word)
}
else -> {
inputStatus = Status.CAP
capitalizeCandidates()
showStatusIcon(R.drawable.shift)
}
}
showStatusIcon(getIconResource())
loadCandidates(candidateIndex)
composeText(candidates[candidateIndex])
}
@SuppressLint("DiscouragedApi")
private fun getIconResource(): Int {
val name = inputMode?.let {
val inputMethodManager = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
val inputMethodSubtype = inputMethodManager.currentInputMethodSubtype
it.mode
.plus("_")
.plus(inputMethodSubtype.languageTag)
.plus("_")
.plus(inputStatus.toString())
.replace('-', '_')
.lowercase()
} ?: "wkt9"
return resources.getIdentifier(name, "drawable", packageName)
}
private fun updateInputStatus() {
when (inputMode?.status) {
Status.UPPER -> {
inputStatus = Status.UPPER
inputStatus = inputMode?.status ?: Status.CAP
showStatusIcon(R.drawable.shift)
}
if (inputStatus == Status.CAP && !isSentenceStart()) inputStatus = Status.LOWER
Status.CAP -> {
if (isSentenceStart()) {
inputStatus = Status.CAP
showStatusIcon(R.drawable.shift)
} else {
inputStatus = Status.LOWER
showStatusIcon(R.drawable.word)
}
}
else -> {
inputStatus = Status.LOWER
showStatusIcon(R.drawable.word)
}
}
showStatusIcon(getIconResource())
}
private suspend fun queryT9Candidates(codeWord: StringBuilder, limit: Int = 10): Boolean {

View File

@ -4,6 +4,8 @@ import net.mezimmah.wkt9.keypad.Key
import net.mezimmah.wkt9.keypad.KeyEventResult
class AlphaInputMode: InputMode {
override val mode: String = "alpha"
override var status: Status = Status.CAP
private set

View File

@ -4,6 +4,7 @@ import net.mezimmah.wkt9.keypad.Key
import net.mezimmah.wkt9.keypad.KeyEventResult
interface InputMode {
val mode: String
val status: Status
fun onKeyDown(key: Key, composing: Boolean): KeyEventResult

View File

@ -8,6 +8,8 @@ import net.mezimmah.wkt9.keypad.KeyEventResult
import java.lang.StringBuilder
class NumericInputMode: InputMode {
override val mode: String = "numeric"
private val tag = "WKT9"
private val keyCommandResolver: KeyCommandResolver = KeyCommandResolver.getBasic()
private val codeWord = StringBuilder()

View File

@ -1,8 +1,8 @@
package net.mezimmah.wkt9.inputmode
enum class Status(val idx: Int) {
CAP(0),
UPPER(1),
LOWER(2),
NUM(3)
enum class Status {
CAP,
UPPER,
LOWER,
NUM
}

View File

@ -15,6 +15,8 @@ class WordInputMode: InputMode {
private var keyIndex = 0
private var lastKey: Key? = null
override val mode: String = "word"
override var status: Status = Status.CAP
private set
@ -174,8 +176,6 @@ class WordInputMode: InputMode {
private fun shiftMode(composing: Boolean): KeyEventResult {
if (!composing) {
reset()
status = when(status) {
Status.CAP -> Status.UPPER
Status.UPPER -> Status.LOWER

View File

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="m7.272,28.21q0.992,0 1.76,-0.087 0.8,-0.087 1.312,-0.216v-5.975q-0.512,-0.216 -1.248,-0.346 -0.704,-0.13 -1.504,-0.13 -0.736,0 -1.44,0.173 -0.704,0.13 -1.248,0.52 -0.544,0.39 -0.896,1.039 -0.352,0.606 -0.352,1.559 0,1.948 0.96,2.728 0.992,0.736 2.656,0.736zM7.016,10.198q1.664,0 2.784,0.563 1.152,0.563 1.856,1.559 0.704,0.996 0.992,2.425 0.288,1.429 0.288,3.118v12.557q-0.928,0.216 -2.464,0.52 -1.504,0.303 -3.104,0.303 -1.216,0 -2.368,-0.303 -1.152,-0.26 -2.048,-0.953 -0.896,-0.736 -1.44,-1.992 -0.544,-1.256 -0.544,-3.204 0,-1.732 0.544,-2.901 0.576,-1.212 1.44,-1.948 0.896,-0.736 2.016,-1.039 1.152,-0.346 2.304,-0.346 1.568,0 3.072,0.476L10.344,18.035q0,-0.909 -0.16,-1.732 -0.128,-0.866 -0.544,-1.559 -0.384,-0.693 -1.088,-1.082 -0.672,-0.433 -1.76,-0.433 -1.376,0 -2.4,0.26 -1.024,0.26 -1.568,0.52l-0.32,-2.944q0.544,-0.346 1.792,-0.606 1.28,-0.26 2.72,-0.26zM21.24,11.41q0.48,-0.39 1.376,-0.779 0.928,-0.433 2.048,-0.433 1.504,0 2.688,0.779 1.184,0.779 1.984,2.165 0.832,1.386 1.248,3.334 0.448,1.905 0.448,4.243 0,2.425 -0.512,4.373 -0.512,1.948 -1.44,3.334 -0.928,1.342 -2.24,2.078 -1.312,0.736 -2.912,0.736 -1.76,0 -3.136,-0.346 -1.376,-0.346 -2.208,-0.693L18.584,1.365l2.656,-0.606zM21.24,27.648q0.608,0.216 1.216,0.346 0.608,0.087 1.152,0.087 2.208,0 3.456,-1.819 1.248,-1.862 1.248,-5.542 0,-1.559 -0.224,-2.901 -0.224,-1.386 -0.704,-2.338 -0.48,-0.996 -1.248,-1.559 -0.736,-0.563 -1.792,-0.563 -0.928,0 -1.792,0.52 -0.864,0.476 -1.312,1.039z"
android:strokeWidth="1.16324"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="m10.537,5.201q0.832,2.6 1.629,5.269 0.832,2.635 1.595,5.547 0.797,2.912 1.56,6.171 0.797,3.259 1.595,7.037L13.796,29.225Q13.519,27.665 13.207,26.14 12.929,24.615 12.617,23.089L5.06,23.089q-0.347,1.525 -0.624,3.051 -0.277,1.525 -0.555,3.085L0.865,29.225Q1.628,25.447 2.425,22.188 3.223,18.929 3.985,16.017 4.783,13.105 5.58,10.471 6.412,7.801 7.244,5.201ZM8.839,8.737Q7.972,11.615 7.175,14.527 6.377,17.439 5.649,20.489L11.993,20.489Q11.3,17.439 10.503,14.527 9.705,11.615 8.839,8.737ZM22.26,26.799q0.485,0.139 0.936,0.208 0.451,0.035 0.832,0.035 2.011,0 2.981,-1.595 1.005,-1.629 1.005,-5.373 0,-1.941 -0.243,-3.259 -0.243,-1.317 -0.728,-2.115 -0.451,-0.797 -1.109,-1.144 -0.659,-0.347 -1.525,-0.347 -1.144,0 -2.149,0.555zM22.26,11.164q0.555,-0.277 1.109,-0.416 0.589,-0.173 1.387,-0.173 1.699,0 2.912,0.693 1.213,0.659 1.976,1.907 0.763,1.213 1.109,2.981 0.381,1.733 0.381,3.917 0,4.819 -1.733,7.211 -1.699,2.392 -5.373,2.392 -1.283,0 -2.531,-0.277 -1.248,-0.243 -2.219,-0.659L19.279,2.844L22.26,2.324Z"
android:strokeWidth="0.815"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="m3.023,11.053q0.971,-0.411 2.053,-0.635 1.083,-0.261 2.352,-0.261 2.613,0 4.256,1.643 1.643,1.605 1.643,5.04v12.992q-1.344,0.373 -2.763,0.597 -1.381,0.224 -2.725,0.224 -1.344,0 -2.539,-0.336Q4.143,29.981 3.247,29.235 2.388,28.488 1.865,27.368 1.343,26.211 1.343,24.568q0,-1.531 0.448,-2.651 0.485,-1.157 1.307,-1.904 0.821,-0.784 1.941,-1.157 1.12,-0.411 2.427,-0.411 1.232,0 2.725,0.299v-1.792q0,-2.165 -0.859,-3.024 -0.821,-0.859 -2.389,-0.859 -0.859,0 -1.643,0.187 -0.747,0.149 -1.605,0.523zM4.553,24.531q0,1.717 0.896,2.539 0.896,0.821 2.539,0.821 1.008,0 2.203,-0.261v-6.235q-1.12,-0.299 -2.203,-0.299 -0.709,0 -1.344,0.187 -0.635,0.149 -1.12,0.56 -0.448,0.373 -0.709,1.045 -0.261,0.635 -0.261,1.643zM21.1,27.629q0.523,0.149 1.008,0.224 0.485,0.037 0.896,0.037 2.165,0 3.211,-1.717 1.083,-1.755 1.083,-5.787 0,-2.091 -0.261,-3.509 -0.261,-1.419 -0.784,-2.277 -0.485,-0.859 -1.195,-1.232 -0.709,-0.373 -1.643,-0.373 -1.232,0 -2.315,0.597zM21.1,10.792q0.597,-0.299 1.195,-0.448 0.635,-0.187 1.493,-0.187 1.829,0 3.136,0.747 1.307,0.709 2.128,2.053 0.821,1.307 1.195,3.211 0.411,1.867 0.411,4.219 0,5.189 -1.867,7.765 -1.829,2.576 -5.787,2.576 -1.381,0 -2.725,-0.299 -1.344,-0.261 -2.389,-0.709L17.889,1.832l3.211,-0.56z"
android:strokeWidth="0.815"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="m10.068,4.944q0.768,2.4 1.504,4.864 0.768,2.432 1.472,5.12 0.736,2.688 1.44,5.696 0.736,3.008 1.472,6.496h-2.88q-0.256,-1.44 -0.544,-2.848 -0.256,-1.408 -0.544,-2.816L5.012,21.456q-0.32,1.408 -0.576,2.816 -0.256,1.408 -0.512,2.848h-2.784q0.704,-3.488 1.44,-6.496 0.736,-3.008 1.44,-5.696 0.736,-2.688 1.472,-5.12 0.768,-2.464 1.536,-4.864zM8.5,8.208q-0.8,2.656 -1.536,5.344 -0.736,2.688 -1.408,5.504h5.856q-0.64,-2.816 -1.376,-5.504 -0.736,-2.688 -1.536,-5.344zM21.164,14.384h1.984q3.968,0 3.968,-3.584 0,-1.12 -0.352,-1.824 -0.32,-0.736 -0.864,-1.12 -0.544,-0.416 -1.28,-0.576 -0.704,-0.16 -1.504,-0.16 -0.48,0 -0.992,0.032 -0.48,0.032 -0.96,0.096zM21.164,16.688v8q0.608,0.096 1.184,0.16 0.608,0.064 1.184,0.064 0.896,0 1.696,-0.192 0.8,-0.192 1.376,-0.64 0.608,-0.448 0.928,-1.216 0.352,-0.8 0.352,-1.952 0,-1.984 -1.088,-3.104 -1.056,-1.12 -3.328,-1.12zM18.284,5.264q1.12,-0.256 2.272,-0.384 1.184,-0.16 2.336,-0.16 1.44,0 2.72,0.288 1.312,0.256 2.304,0.928 0.992,0.64 1.568,1.728 0.608,1.056 0.608,2.656 0,1.984 -0.832,3.264 -0.832,1.248 -2.144,1.856 1.632,0.64 2.688,1.952 1.056,1.312 1.056,3.616 0,1.728 -0.576,2.912 -0.544,1.184 -1.568,1.952 -1.024,0.736 -2.464,1.088 -1.408,0.32 -3.104,0.32 -1.12,0 -2.336,-0.128 -1.216,-0.128 -2.528,-0.384z"
android:strokeWidth="0.815"/>
</vector>

View File

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="m1.48,7.721q1.632,-0.949 3.168,-2.372 1.536,-1.471 2.848,-3.701h1.856V27.695h3.744v3.321H2.44v-3.321h4.288V7.104q-0.352,0.474 -0.864,0.996 -0.48,0.474 -1.088,0.949 -0.576,0.474 -1.216,0.901 -0.64,0.427 -1.248,0.712zM29.72,9.144q0,1.518 -0.416,2.942 -0.384,1.423 -1.056,2.799 -0.64,1.376 -1.472,2.704 -0.832,1.328 -1.696,2.61 -0.48,0.712 -1.12,1.708 -0.64,0.996 -1.216,2.04 -0.576,1.044 -0.96,2.04 -0.384,0.996 -0.384,1.708h9.12v3.321h-12q-0.032,-0.237 -0.032,-0.474 0,-0.285 0,-0.522 0,-1.993 0.448,-3.701 0.448,-1.708 1.152,-3.226 0.704,-1.518 1.568,-2.847 0.896,-1.376 1.76,-2.657 0.704,-1.044 1.344,-2.04 0.672,-0.996 1.152,-1.993 0.512,-0.996 0.8,-2.04 0.32,-1.091 0.32,-2.23 0,-1.281 -0.288,-2.183Q26.488,6.202 26.008,5.633 25.56,5.016 24.952,4.732 24.344,4.447 23.64,4.447q-0.832,0 -1.536,0.332Q21.432,5.111 20.888,5.586 20.376,6.06 19.992,6.535 19.608,6.962 19.416,7.246L18.104,4.494Q18.36,4.067 18.872,3.451 19.384,2.834 20.088,2.312 20.824,1.743 21.72,1.363q0.896,-0.38 1.92,-0.38 3.104,0 4.576,2.135Q29.72,5.206 29.72,9.144Z"
android:strokeWidth="1.21765"/>
</vector>

View File

@ -1,13 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="0.96"
android:viewportHeight="0.96">
<path
android:pathData="m0.18429,0.89858c0.19439,-0.02486 0.38731,-0.03128 0.59301,0 -0.19342,0.0204 -0.39134,0.0192 -0.59301,0zM0.65022,0.48934c-0.05304,0.09212 -0.04872,0.15791 0,0.22735H0.31136c0.04442,-0.06852 0.06083,-0.14921 0,-0.22735H0.09957C0.23998,0.36908 0.38291,0.24413 0.48079,0.08011 0.58695,0.24401 0.72355,0.3679 0.86201,0.48934Z"
android:strokeLineJoin="miter"
android:strokeWidth="0.0750977"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="square"/>
</vector>

View File

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="M14.376,1.445L14.376,4.802L8.936,4.802L8.936,31.13h-2.624L6.312,4.802h-5.44L0.872,1.445ZM31.128,13.338q0,8.872 -2.88,13.38Q25.368,31.178 19.576,31.226L19.48,27.869q3.584,0 5.76,-2.11 2.208,-2.158 2.912,-7.385 -0.768,0.528 -1.696,0.863 -0.928,0.288 -1.952,0.288 -1.696,0 -2.848,-0.719 -1.152,-0.767 -1.856,-2.014 -0.704,-1.295 -1.024,-2.925 -0.32,-1.631 -0.32,-3.453 0,-1.631 0.352,-3.309 0.352,-1.726 1.088,-3.117 0.736,-1.391 1.888,-2.302 1.152,-0.911 2.752,-0.911 3.264,0 4.928,3.357 1.664,3.357 1.664,9.208zM24.792,16.264q1.024,0 1.888,-0.288 0.896,-0.288 1.728,-0.815 0.032,-0.48 0.032,-0.911 0,-0.432 0,-0.911 0,-1.87 -0.192,-3.549Q28.088,8.111 27.64,6.864 27.224,5.617 26.456,4.898 25.72,4.131 24.568,4.131q-0.96,0 -1.6,0.623 -0.64,0.575 -1.056,1.487 -0.416,0.863 -0.608,1.966 -0.16,1.103 -0.16,2.11 0,2.925 0.864,4.46 0.896,1.487 2.784,1.487z"
android:strokeWidth="1.22419"/>
</vector>

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="m8.136,14.448q3.008,0 4.64,1.888 1.632,1.856 1.632,5.664v0.928L3.784,22.928q0.16,2.304 1.504,3.52 1.376,1.184 3.84,1.184 1.408,0 2.4,-0.224 0.992,-0.224 1.504,-0.48l0.352,2.24q-0.48,0.256 -1.728,0.544 -1.248,0.288 -2.816,0.288 -1.92,0 -3.392,-0.576 -1.44,-0.608 -2.4,-1.632 -0.96,-1.024 -1.44,-2.432 -0.48,-1.44 -0.48,-3.104 0,-1.984 0.608,-3.456 0.608,-1.472 1.6,-2.432 0.992,-0.96 2.24,-1.44 1.248,-0.48 2.56,-0.48zM11.72,20.784q0,-1.888 -0.992,-2.976 -0.992,-1.12 -2.624,-1.12 -0.928,0 -1.696,0.352 -0.736,0.352 -1.28,0.928 -0.544,0.576 -0.864,1.312 -0.32,0.736 -0.416,1.504zM19.32,15.216q1.44,-0.352 2.848,-0.544 1.44,-0.192 2.688,-0.192 2.976,0 4.48,1.536 1.536,1.536 1.536,4.928v8.704h-2.624v-8.224q0,-1.44 -0.256,-2.336 -0.256,-0.896 -0.736,-1.376 -0.448,-0.512 -1.12,-0.704 -0.64,-0.192 -1.408,-0.192 -0.64,0 -1.376,0.096 -0.704,0.064 -1.376,0.192v12.544h-2.656z"/>
</vector>

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="M2.067,30V10.192H13.171v2.24H4.691v6.08h7.424v2.24H4.691V27.76H13.875V30ZM18.627,15.568q1.44,-0.352 2.848,-0.544 1.44,-0.192 2.688,-0.192 2.976,0 4.48,1.536 1.536,1.536 1.536,4.928V30h-2.624v-8.224q0,-1.44 -0.256,-2.336 -0.256,-0.896 -0.736,-1.376 -0.448,-0.512 -1.12,-0.704 -0.64,-0.192 -1.408,-0.192 -0.64,0 -1.376,0.096 -0.704,0.064 -1.376,0.192V30h-2.656z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="M1.903,28.936V3.064H13.513V5.939H5.263v8.027h7.467v2.8H5.263v9.296H14.111v2.875zM17.703,9.896q1.381,-0.411 2.987,-0.672 1.605,-0.299 2.949,-0.299 1.456,0 2.651,0.411 1.195,0.373 2.016,1.307 0.859,0.933 1.307,2.539 0.485,1.568 0.485,3.92V28.936H26.887V17.363q0,-2.912 -0.747,-4.256 -0.747,-1.344 -2.8,-1.344 -1.083,0 -2.427,0.373v16.8h-3.211z"
android:strokeWidth="0.815"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="m4.908,16.952q0.037,1.419 0.261,2.613 0.224,1.157 0.709,2.053 0.523,0.859 1.344,1.344 0.859,0.485 2.165,0.485 1.083,0 1.979,-0.299 0.933,-0.336 1.344,-0.56l0.597,2.576q-0.485,0.336 -1.643,0.709 -1.12,0.411 -2.688,0.411 -2.053,0 -3.472,-0.747 -1.381,-0.747 -2.277,-2.091 -0.859,-1.344 -1.232,-3.211 -0.373,-1.867 -0.373,-4.107 0,-5.413 1.792,-7.915 1.792,-2.501 4.741,-2.501 3.323,0 4.704,2.501 1.381,2.501 1.381,7.019 0,0.411 0,0.859 0,0.411 -0.037,0.859zM8.156,8.44q-1.605,0 -2.352,1.605 -0.709,1.605 -0.859,4.293h5.936q0,-2.725 -0.56,-4.293Q9.761,8.44 8.156,8.44ZM17.983,6.76q1.381,-0.411 2.987,-0.672 1.605,-0.299 2.949,-0.299 1.456,0 2.651,0.411 1.195,0.373 2.016,1.307 0.859,0.933 1.307,2.539 0.485,1.568 0.485,3.92V25.8H27.167V14.227q0,-2.912 -0.747,-4.256 -0.747,-1.344 -2.8,-1.344 -1.083,0 -2.427,0.373V25.8H17.983Z"
android:strokeWidth="0.815"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:fillColor="#FF000000"
android:pathData="M0.279,28.936L0.279,3.064L11.889,3.064L11.889,5.939L3.639,5.939L3.639,13.965L11.105,13.965v2.8L3.639,16.765v9.296h8.848v2.875zM28.996,28.936Q28.1,26.733 26.943,24.195 25.823,21.619 24.553,19.043 23.321,16.429 22.015,13.891 20.708,11.315 19.439,9.112L19.439,28.936L16.303,28.936L16.303,3.064h2.8q1.419,2.315 2.725,4.741 1.344,2.427 2.539,4.816 1.195,2.352 2.24,4.667 1.083,2.277 1.979,4.331L28.585,3.064h3.136L31.721,28.936Z"
android:strokeWidth="0.815"/>
</vector>