v1.2.6: move EditText to top, 0 height, no overlap

This commit is contained in:
茂之钳
2026-05-24 13:16:44 +00:00
parent 0bb7616ed2
commit b1355aacff
@@ -496,26 +496,22 @@ fun SshTerminalScreen(
}
}
Box(
Column(
modifier = modifier
.fillMaxSize()
.background(bg)
.onKeyEvent { handleKeyEvent(it) }
.clickable { requestEditTextFocus() }
) {
// 原生 EditText 输入桥——任何输入法都能正确识别
// EditText 输入桥——在 Column 顶部,0高度不占空间
AndroidView(
factory = { ctx ->
EditText(ctx).apply {
setTextColor(0x00000000) // 透明文字
setBackgroundColor(0x00000000) // 透明背景
textSize = 1f // 极小的字号
val lp = android.view.ViewGroup.LayoutParams(1, 30)
layoutParams = lp
// IME 选项:Done 动作(回车即发送)
setTextColor(0x00000000)
setBackgroundColor(0x00000000)
textSize = 1f
imeOptions = EditorInfo.IME_ACTION_SEND or EditorInfo.IME_FLAG_NO_EXTRACT_UI
setSingleLine()
// 文本变化监听
// Editor action 监听——IME 回车按键
setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE) {
val cmd = text.toString().trim()
@@ -531,7 +527,6 @@ fun SshTerminalScreen(
false
}
}
// 文本变化同步
addTextChangedListener(object : android.text.TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun afterTextChanged(s: android.text.Editable?) {}
@@ -539,7 +534,6 @@ fun SshTerminalScreen(
currentInput = s?.toString() ?: ""
}
})
// 硬件键盘回车
setOnKeyListener { _, keyCode, event ->
if (event.action == android.view.KeyEvent.ACTION_DOWN && keyCode == AndroidKeyEvent.KEYCODE_ENTER) {
val cmd = text.toString().trim()
@@ -555,16 +549,16 @@ fun SshTerminalScreen(
false
}
}
// IDE 编辑器标记:用于焦点请求
tag = "terminal_input"
editTextRef.value = this
}
},
modifier = Modifier
.width(1.dp)
.height(30.dp)
.fillMaxWidth()
.height(0.dp)
)
// ── 终端内容(顶栏 + 输出 + 输入行)──
Column(
modifier = Modifier
.fillMaxSize()