From 7f5705af38d1dc5b5d913d1b91ae2fbcd8f8f5b9 Mon Sep 17 00:00:00 2001 From: xiaji Date: Mon, 6 Apr 2026 10:14:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=BA=E5=88=97=E8=A1=A8=E5=B8=83=E5=B1=80?= =?UTF-8?q?=EF=BC=8C=E6=AF=8F=E8=A1=8C=E6=98=BE=E7=A4=BA=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E3=80=81=E7=BC=96=E8=BE=91=E3=80=81=E5=88=A0=E9=99=A4=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/flomo_ai/SecondActivity.kt | 70 +++++++++---------- .../src/main/res/layout/activity_second.xml | 67 +++++++++--------- .../src/main/res/layout/model_list_item.xml | 46 ++++++++++++ 3 files changed, 114 insertions(+), 69 deletions(-) create mode 100644 flomo-ai/app/src/main/res/layout/model_list_item.xml diff --git a/flomo-ai/app/src/main/java/com/example/flomo_ai/SecondActivity.kt b/flomo-ai/app/src/main/java/com/example/flomo_ai/SecondActivity.kt index 89c7b49..98e166e 100644 --- a/flomo-ai/app/src/main/java/com/example/flomo_ai/SecondActivity.kt +++ b/flomo-ai/app/src/main/java/com/example/flomo_ai/SecondActivity.kt @@ -46,10 +46,8 @@ data class ButtonConfig(val id: String, val label: String, val action: String, v class SecondActivity : AppCompatActivity() { // View references - private lateinit var spModelSelector: Spinner private lateinit var llModelList: LinearLayout private lateinit var btnAddModel: Button - private lateinit var btnDeleteModel: Button private lateinit var etBaseUrl: EditText private lateinit var etApiKey: EditText private lateinit var btnToggleApiKey: ImageButton @@ -159,9 +157,8 @@ class SecondActivity : AppCompatActivity() { btnToggleApiKey = findViewById(R.id.btnToggleApiKey) etModel = findViewById(R.id.etModel) etModelName = findViewById(R.id.etModelName) - spModelSelector = findViewById(R.id.spModelSelector) + llModelList = findViewById(R.id.llModelList) btnAddModel = findViewById(R.id.btnAddModel) - btnDeleteModel = findViewById(R.id.btnDeleteModel) btnTestConnection = findViewById(R.id.btnTestConnection) tvTestStatus = findViewById(R.id.tvTestStatus) @@ -351,23 +348,42 @@ class SecondActivity : AppCompatActivity() { etApiKey.setSelection(etApiKey.text.length) } - private fun refreshModelSelector() { - val names = llmConfigs.map { it.name.ifEmpty { "未命名" } }.toMutableList() - val adapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, names) - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) - spModelSelector.adapter = adapter + private fun refreshModelList() { + llModelList.removeAllViews() + for ((index, config) in llmConfigs.withIndex()) { + val view = layoutInflater.inflate(R.layout.model_list_item, null) + val tvName = view.findViewById(R.id.tvModelName) + val btnEdit = view.findViewById