v1.2.7: visible input row with EditText, always tappable

This commit is contained in:
茂之钳
2026-05-24 15:06:58 +00:00
parent b1355aacff
commit 69f51e5fd8
@@ -504,59 +504,76 @@ fun SshTerminalScreen(
.clickable { requestEditTextFocus() }
) {
// EditText 输入桥——在 Column 顶部,0高度不占空间
AndroidView(
factory = { ctx ->
EditText(ctx).apply {
setTextColor(0x00000000)
setBackgroundColor(0x00000000)
textSize = 1f
imeOptions = EditorInfo.IME_ACTION_SEND or EditorInfo.IME_FLAG_NO_EXTRACT_UI
setSingleLine()
setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE) {
val cmd = text.toString().trim()
if (cmd.isNotEmpty()) {
coroutineScope.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?) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
currentInput = s?.toString() ?: ""
}
})
setOnKeyListener { _, keyCode, event ->
if (event.action == android.view.KeyEvent.ACTION_DOWN && keyCode == AndroidKeyEvent.KEYCODE_ENTER) {
val cmd = text.toString().trim()
if (cmd.isNotEmpty()) {
coroutineScope.launch {
manager.sendCommand(cmd)
}
}
setText("")
currentInput = ""
true
} else {
false
}
}
tag = "terminal_input"
editTextRef.value = this
}
},
Row(
modifier = Modifier
.fillMaxWidth()
.height(0.dp)
)
.height(40.dp)
.background(Color(0xFF0D1117))
.padding(horizontal = 8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = if (state.connected) "\$ " else "",
color = accent,
fontSize = 13.sp,
fontFamily = FontFamily.Monospace
)
AndroidView(
factory = { ctx ->
EditText(ctx).apply {
setBackgroundColor(android.graphics.Color.TRANSPARENT)
setTextColor(android.graphics.Color.parseColor("#E6EDF3"))
textSize = 14f
hint = if (state.connected) "type command..." else ""
setHintTextColor(android.graphics.Color.parseColor("#6E7681"))
imeOptions = EditorInfo.IME_ACTION_SEND
setSingleLine()
setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEND) {
val cmd = text.toString().trim()
if (cmd.isNotEmpty()) {
coroutineScope.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?) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
currentInput = s?.toString() ?: ""
}
})
setOnKeyListener { _, keyCode, event ->
if (event.action == android.view.KeyEvent.ACTION_DOWN && keyCode == AndroidKeyEvent.KEYCODE_ENTER) {
val cmd = text.toString().trim()
if (cmd.isNotEmpty()) {
coroutineScope.launch {
manager.sendCommand(cmd)
}
}
setText("")
currentInput = ""
true
} else {
false
}
}
tag = "terminal_input"
editTextRef.value = this
}
},
modifier = Modifier
.weight(1f)
.fillMaxHeight()
)
}
// ── 终端内容(顶栏 + 输出 + 输入行)──
Column(