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:
+4
-3
@@ -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?) {}
|
||||
|
||||
Reference in New Issue
Block a user