Progress
This commit is contained in:
parent
9a9a37bc2b
commit
d6b94ce461
@ -206,6 +206,24 @@ class WKT9: InputMethodService() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun candidatesToLowerCase() {
|
||||
candidates.forEachIndexed { index, candidate ->
|
||||
candidates[index] = candidate.lowercase()
|
||||
}
|
||||
}
|
||||
|
||||
private fun candidatesToUpperCase() {
|
||||
candidates.forEachIndexed { index, candidate ->
|
||||
candidates[index] = candidate.uppercase()
|
||||
}
|
||||
}
|
||||
|
||||
private fun capitalizeCandidates() {
|
||||
candidates.forEachIndexed { index, candidate ->
|
||||
candidates[index] = candidate.lowercase().replaceFirstChar { it.uppercase() }
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearCandidates() {
|
||||
clearCandidateUI()
|
||||
|
||||
@ -293,8 +311,8 @@ class WKT9: InputMethodService() {
|
||||
if (res.right) onRight()
|
||||
if (res.record) onRecord()
|
||||
if (res.transcribe) onTranscribe()
|
||||
if (res.updateStatus) onUpdateStatus()
|
||||
// if (res.sentenceStart != null) sentenceStart = res.sentenceStart
|
||||
if (res.updateInputStatus) updateInputStatus()
|
||||
if (res.updateWordStatus) onUpdateWordStatus()
|
||||
if (res.focus) onFocus()
|
||||
|
||||
return res.consumed
|
||||
@ -320,7 +338,7 @@ class WKT9: InputMethodService() {
|
||||
val candidateView = layoutInflater.inflate(layout, null)
|
||||
val textView = candidateView.findViewById<TextView>(R.id.suggestion_text)
|
||||
|
||||
textView.text = candidate
|
||||
textView.text = candidate
|
||||
|
||||
candidatesView.addView(candidateView)
|
||||
}
|
||||
@ -464,8 +482,34 @@ class WKT9: InputMethodService() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun onUpdateStatus() {
|
||||
Log.d(tag, "We're going to update the status...")
|
||||
private fun onUpdateWordStatus() {
|
||||
clearCandidateUI()
|
||||
|
||||
when (inputStatus) {
|
||||
Status.CAP -> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
loadCandidates(candidateIndex)
|
||||
composeText(candidates[candidateIndex])
|
||||
}
|
||||
|
||||
private fun updateInputStatus() {
|
||||
|
@ -173,28 +173,21 @@ class WordInputMode: InputMode {
|
||||
}
|
||||
|
||||
private fun shiftMode(composing: Boolean): KeyEventResult {
|
||||
Log.d(tag, "Composing: $composing")
|
||||
if (!composing) {
|
||||
reset()
|
||||
|
||||
return KeyEventResult()
|
||||
// reset()
|
||||
status = when(status) {
|
||||
Status.CAP -> Status.UPPER
|
||||
Status.UPPER -> Status.LOWER
|
||||
else -> Status.CAP
|
||||
}
|
||||
}
|
||||
|
||||
// if (status == Status.CAP && sentenceStart || status == Status.LOWER && !sentenceStart) {
|
||||
// return KeyEventResult(
|
||||
// consumed = true,
|
||||
// sentenceStart = !sentenceStart
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// status = when(status) {
|
||||
// Status.CAP -> Status.UPPER
|
||||
// Status.LOWER -> Status.CAP
|
||||
// else -> Status.LOWER
|
||||
// }
|
||||
|
||||
// return KeyEventResult(
|
||||
// consumed = true,
|
||||
// updateStatus = true
|
||||
// )
|
||||
return KeyEventResult(
|
||||
consumed = true,
|
||||
updateInputStatus = !composing,
|
||||
updateWordStatus = composing
|
||||
)
|
||||
}
|
||||
|
||||
private fun switchMode(): KeyEventResult {
|
||||
|
@ -16,7 +16,7 @@ data class KeyEventResult(
|
||||
val right: Boolean = false,
|
||||
val record: Boolean = false,
|
||||
val transcribe: Boolean = false,
|
||||
val updateStatus: Boolean = false,
|
||||
val sentenceStart: Boolean? = null,
|
||||
val updateInputStatus: Boolean = false,
|
||||
val updateWordStatus: Boolean = false,
|
||||
val focus: Boolean = false
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user