diff --git a/app/src/main/java/net/mezimmah/wkt9/WKT9.kt b/app/src/main/java/net/mezimmah/wkt9/WKT9.kt index 3370620..add09a2 100644 --- a/app/src/main/java/net/mezimmah/wkt9/WKT9.kt +++ b/app/src/main/java/net/mezimmah/wkt9/WKT9.kt @@ -10,6 +10,7 @@ import android.view.KeyEvent import android.view.View import android.view.ViewConfiguration import android.view.inputmethod.EditorInfo +import android.view.inputmethod.InputMethodManager import android.widget.LinearLayout import android.widget.TextView import android.widget.Toast @@ -112,6 +113,10 @@ class WKT9: InputMethodService() { inputMode = null cursorPosition = 0 sentenceStart = false + } + + override fun onFinishInputView(finishingInput: Boolean) { + super.onFinishInputView(finishingInput) clearCandidates() } @@ -175,7 +180,7 @@ class WKT9: InputMethodService() { else -> Log.d(tag, "Mode without input...") } - showStatusIcon(R.drawable.word_en_cap) + showStatusIcon(0) super.onStartInput(attribute, restarting) } @@ -200,6 +205,17 @@ class WKT9: InputMethodService() { ) } + override fun showStatusIcon(iconResId: Int) { + if (iconResId != 0) super.showStatusIcon(iconResId) + + when (inputMode) { + is WordInputMode -> super.showStatusIcon(R.drawable.word) + is AlphaInputMode -> super.showStatusIcon(R.drawable.alpha) + is NumericInputMode -> super.showStatusIcon(R.drawable.numeric) + else -> super.showStatusIcon(R.drawable.wkt9) + } + } + private fun clearCandidates() { clearCandidateUI() @@ -272,6 +288,7 @@ class WKT9: InputMethodService() { if (res.record) onRecord() if (res.transcribe) onTranscribe() if (res.updateStatus) onUpdateStatus() + if (res.focus) onFocus() return res.consumed } @@ -293,9 +310,10 @@ class WKT9: InputMethodService() { candidates.forEachIndexed { index, candidate -> val layout = if (index == highLight) R.layout.current_suggestion else R.layout.suggestion - val candidateView = layoutInflater.inflate(layout, null) as TextView + val candidateView = layoutInflater.inflate(layout, null) + val textView = candidateView.findViewById(R.id.suggestion_text) - candidateView.text = candidate + textView.text = candidate candidatesView.addView(candidateView) } @@ -342,6 +360,10 @@ class WKT9: InputMethodService() { deleteText(beforeCursor, afterCursor) } + private fun onFocus() { + requestShowSelf(InputMethodManager.SHOW_IMPLICIT) + } + private fun onLeft() { if (candidates.isEmpty()) return @@ -356,10 +378,11 @@ class WKT9: InputMethodService() { private fun onRecord() { // The recorder must be busy... - if (recorder !== null) return + if (recorder !== null || !isInputViewShown) return clearCandidates() + // Delete possible existing recording recording?.delete() // Toast settings diff --git a/app/src/main/java/net/mezimmah/wkt9/inputmode/WordInputMode.kt b/app/src/main/java/net/mezimmah/wkt9/inputmode/WordInputMode.kt index 21c1720..257a465 100644 --- a/app/src/main/java/net/mezimmah/wkt9/inputmode/WordInputMode.kt +++ b/app/src/main/java/net/mezimmah/wkt9/inputmode/WordInputMode.kt @@ -32,6 +32,7 @@ class WordInputMode: InputMode { Command.SPACE -> finalizeWordOrSentence() Command.LEFT -> navigateLeft() Command.RIGHT -> navigateRight() + Command.SELECT -> focus() else -> KeyEventResult() } } @@ -80,9 +81,7 @@ class WordInputMode: InputMode { } private fun deleteCharacter(repeat: Int = 0): KeyEventResult { - if (repeat % 2 != 0) return KeyEventResult() - - codeWord.clear() + if (repeat == 0) codeWord.clear() return KeyEventResult( finishComposing = true, @@ -104,6 +103,13 @@ class WordInputMode: InputMode { ) } + private fun focus(): KeyEventResult { + return KeyEventResult( + consumed = true, + focus = true + ) + } + private fun goBack(): KeyEventResult { reset() diff --git a/app/src/main/java/net/mezimmah/wkt9/keypad/KeyEventResult.kt b/app/src/main/java/net/mezimmah/wkt9/keypad/KeyEventResult.kt index 3d6aba7..0ef64f8 100644 --- a/app/src/main/java/net/mezimmah/wkt9/keypad/KeyEventResult.kt +++ b/app/src/main/java/net/mezimmah/wkt9/keypad/KeyEventResult.kt @@ -16,5 +16,6 @@ data class KeyEventResult( val record: Boolean = false, val transcribe: Boolean = false, val updateStatus: Boolean = false, - val sentenceStart: Boolean? = null + val sentenceStart: Boolean? = null, + val focus: Boolean = false ) diff --git a/app/src/main/res/drawable/blue_radius.xml b/app/src/main/res/drawable/blue_radius.xml new file mode 100644 index 0000000..0d957db --- /dev/null +++ b/app/src/main/res/drawable/blue_radius.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/button_radius.xml b/app/src/main/res/drawable/button_radius.xml new file mode 100644 index 0000000..53bdf87 --- /dev/null +++ b/app/src/main/res/drawable/button_radius.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/numeric.xml b/app/src/main/res/drawable/numeric.xml new file mode 100644 index 0000000..a55868d --- /dev/null +++ b/app/src/main/res/drawable/numeric.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/shift.xml b/app/src/main/res/drawable/shift.xml new file mode 100644 index 0000000..eddbf6a --- /dev/null +++ b/app/src/main/res/drawable/shift.xml @@ -0,0 +1,13 @@ + + + diff --git a/app/src/main/res/drawable/suggestion_border.xml b/app/src/main/res/drawable/suggestion_border.xml deleted file mode 100644 index ddf370d..0000000 --- a/app/src/main/res/drawable/suggestion_border.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/suggestion_current_border.xml b/app/src/main/res/drawable/suggestion_current_border.xml deleted file mode 100644 index 7cc6c29..0000000 --- a/app/src/main/res/drawable/suggestion_current_border.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/wkt9.xml b/app/src/main/res/drawable/wkt9.xml new file mode 100644 index 0000000..cd5f4b0 --- /dev/null +++ b/app/src/main/res/drawable/wkt9.xml @@ -0,0 +1,14 @@ + + + + diff --git a/app/src/main/res/drawable/word.xml b/app/src/main/res/drawable/word.xml new file mode 100644 index 0000000..33237f3 --- /dev/null +++ b/app/src/main/res/drawable/word.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/yellow_radius.xml b/app/src/main/res/drawable/yellow_radius.xml new file mode 100644 index 0000000..9c66729 --- /dev/null +++ b/app/src/main/res/drawable/yellow_radius.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/app/src/main/res/layout/current_suggestion.xml b/app/src/main/res/layout/current_suggestion.xml index 6078000..84aea66 100644 --- a/app/src/main/res/layout/current_suggestion.xml +++ b/app/src/main/res/layout/current_suggestion.xml @@ -1,13 +1,19 @@ - \ No newline at end of file + android:id="@+id/current_suggestion" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="2dp"> + + + \ No newline at end of file diff --git a/app/src/main/res/layout/suggestion.xml b/app/src/main/res/layout/suggestion.xml index b87a155..0d43019 100644 --- a/app/src/main/res/layout/suggestion.xml +++ b/app/src/main/res/layout/suggestion.xml @@ -1,13 +1,19 @@ - \ No newline at end of file + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="2dp"> + + + \ No newline at end of file diff --git a/app/src/main/res/layout/suggestions.xml b/app/src/main/res/layout/suggestions.xml index 59466eb..baf68b2 100644 --- a/app/src/main/res/layout/suggestions.xml +++ b/app/src/main/res/layout/suggestions.xml @@ -1,5 +1,5 @@ - + android:background="@color/black" + android:orientation="horizontal"> - - - \ No newline at end of file + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index b38071d..4bc94a3 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -7,6 +7,9 @@ #FF018786 #FF000000 #FFFFFFFF + #637783 + #FFFCF0 #C1E8FF - #FFC1F0 + #FFE3C1 + #424242 \ No newline at end of file