fix: re-add setOnEditorActionListener for soft keyboard send

v1.2.9 removed setOnEditorActionListener, relying only on TextWatcher
detecting \n character. Many soft keyboards (especially Chinese IMEs)
send IME_ACTION_SEND/GO/DONE instead of inserting \n, so commands were
never sent.

This re-adds EditorInfo.IME_ACTION_SEND/GO/DONE handling alongside the
existing TextWatcher newline detection.
This commit is contained in:
茂之钳
2026-05-25 05:40:36 +00:00
parent 708f1cb986
commit 4c31834810
2 changed files with 19 additions and 3 deletions
+4 -3
View File
@@ -1,6 +1,7 @@
.gradle/
**/build/
build/
*.apk
*.aab
local.properties
.idea/
**/*.iml
*.apk
*.iml
@@ -523,6 +523,21 @@ fun SshTerminalScreen(
setHintTextColor(android.graphics.Color.parseColor("#6E7681"))
imeOptions = EditorInfo.IME_ACTION_SEND
setSingleLine()
setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE) {
val cmd = text.toString().trim()
if (cmd.isNotEmpty()) {
kotlinx.coroutines.MainScope().launch {
manager.sendCommand(cmd)
}
}
setText("")
currentInput = ""
true
} else {
false
}
}
addTextChangedListener(object : android.text.TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun afterTextChanged(s: android.text.Editable?) {}