Skip to content

Commit

Permalink
Fix the Return key for EditorInfo.IME_FLAG_NO_ENTER_ACTION
Browse files Browse the repository at this point in the history
  • Loading branch information
bingzheung committed Sep 2, 2024
1 parent 4da6e7d commit a72a03d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jyutping.jyutping
import android.content.Context
import android.content.res.Configuration
import android.view.View
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import androidx.compose.runtime.MutableIntState
import androidx.compose.runtime.MutableState
Expand Down Expand Up @@ -454,6 +455,8 @@ class JyutpingInputMethodService: LifecycleInputMethodService(),
if (isBuffering.value) {
currentInputConnection.commitText(bufferText, bufferText.length)
bufferText = PresetString.EMPTY
} else if (currentInputEditorInfo.imeOptions == EditorInfo.IME_FLAG_NO_ENTER_ACTION) {
currentInputConnection.commitText(PresetString.NEW_LINE, PresetString.NEW_LINE.length)
} else {
sendDefaultEditorAction(true)
}
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/org/jyutping/jyutping/keyboard/Engine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ object Engine {
qualified.add(newItem)
} else {
if (!continuous.startsWith(text)) continue
val combinedInput = item.input + textTones
val newItem = Candidate(text = item.text, romanization = item.romanization, input = combinedInput)
val newItem = Candidate(text = item.text, romanization = item.romanization, input = text)
qualified.add(newItem)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ object PresetString {
const val EMPTY: String = ""
const val SPACE: String = " "
const val SEPARATOR: String = "'"
const val NEW_LINE: String = "\n"
}

0 comments on commit a72a03d

Please sign in to comment.