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