优化UI配色方案,新增快捷操作图标,添加笔记API配置和提交功能

This commit is contained in:
Developer
2026-03-30 22:29:28 +08:00
parent 795d065aef
commit 443644a1df
18 changed files with 814 additions and 184 deletions

View File

@@ -11,6 +11,7 @@ import android.widget.ArrayAdapter
import android.widget.Button
import android.widget.EditText
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
import android.widget.Toast
@@ -23,6 +24,13 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONArray
import org.json.JSONObject
class MainActivity : AppCompatActivity() {
private lateinit var inputEditText: EditText
@@ -65,7 +73,10 @@ class MainActivity : AppCompatActivity() {
Log.d("MainActivity", "onCreate: Views initialized")
headerTitle.text = "AI优化"
headerModelName.text = "gpt-4o"
headerModelName.text = "GPT-4o"
// Initialize quick action buttons
initQuickButtons()
// Load prompts from configuration
loadPromptsFromConfig()
@@ -157,6 +168,17 @@ class MainActivity : AppCompatActivity() {
Log.w("MainActivity", "No text to copy")
}
}
val btnSaveNote = findViewById<Button>(R.id.btnSaveNote)
btnSaveNote.setOnClickListener {
Log.d("MainActivity", "btnSaveNote clicked")
val textToSave = outputTextView.text.toString()
if (textToSave.isNotEmpty() && textToSave != "发送消息后结果将在此显示") {
saveToNoteApi(textToSave)
} else {
Toast.makeText(this, "没有可保存的内容", Toast.LENGTH_SHORT).show()
}
}
try {
configButton = findViewById<Button>(R.id.configButton)
@@ -222,6 +244,24 @@ class MainActivity : AppCompatActivity() {
promptContents.add("解释代码的功能和逻辑")
}
// Add quick action prompts
if (!promptTitles.contains("检查错别字")) {
promptTitles.add("检查错别字")
promptContents.add("请检查以下文本中的错别字并纠正:")
}
if (!promptTitles.contains("总结")) {
promptTitles.add("总结")
promptContents.add("请用简洁的语言总结以下文本的主要内容:")
}
if (!promptTitles.contains("翻译")) {
promptTitles.add("翻译")
promptContents.add("请翻译以下文本:")
}
if (!promptTitles.contains("润色")) {
promptTitles.add("润色")
promptContents.add("请润色以下文本,使其更通顺流畅:")
}
// Store prompt contents in a map for easy access
val promptMap = mutableMapOf<String, String>()
for (i in promptTitles.indices) {
@@ -256,4 +296,143 @@ class MainActivity : AppCompatActivity() {
promptSelector.setSelection(0)
}
}
private fun initQuickButtons() {
val btnCheckTypos = findViewById<LinearLayout>(R.id.btnCheckTypos)
val btnSummarize = findViewById<LinearLayout>(R.id.btnSummarize)
val btnTranslate = findViewById<LinearLayout>(R.id.btnTranslate)
val btnPolishing = findViewById<LinearLayout>(R.id.btnPolishing)
btnCheckTypos.setOnClickListener {
selectPrompt("检查错别字")
}
btnSummarize.setOnClickListener {
selectPrompt("总结")
}
btnTranslate.setOnClickListener {
selectPrompt("翻译")
}
btnPolishing.setOnClickListener {
selectPrompt("润色")
}
}
private fun selectPrompt(promptName: String) {
@Suppress("UNCHECKED_CAST")
val promptMap = promptSelector.tag as? MutableMap<String, String>
val content = promptMap?.get(promptName) ?: when (promptName) {
"检查错别字" -> "请检查以下文本中的错别字并纠正:"
"总结" -> "请用简洁的语言总结以下文本的主要内容:"
"翻译" -> "请翻译以下文本:"
"润色" -> "请润色以下文本,使其更通顺流畅:"
else -> ""
}
promptContentText.text = content
Toast.makeText(this, "已选择: $promptName", Toast.LENGTH_SHORT).show()
// Auto-trigger send if input is not empty
if (inputEditText.text.isNotEmpty()) {
findViewById<Button>(R.id.sendButton).performClick()
}
}
private fun saveToNoteApi(content: String) {
try {
val sharedPrefs = getSharedPreferences("APIConfigs", Context.MODE_PRIVATE)
val json = sharedPrefs.getString("configs", null)
if (json == null) {
Toast.makeText(this, "请先配置笔记API", Toast.LENGTH_SHORT).show()
return
}
val settings = Gson().fromJson(json, NoteSettingsData::class.java)
val noteConfig = settings.noteApiConfig
if (noteConfig == null || noteConfig.apiUrl.isBlank() || noteConfig.apiKey.isBlank()) {
Toast.makeText(this, "请先配置笔记API", Toast.LENGTH_SHORT).show()
return
}
outputStatusLabel.text = "提交中..."
CoroutineScope(Dispatchers.Main).launch {
try {
val result = submitToNoteApi(noteConfig.apiType, noteConfig.apiUrl, noteConfig.apiKey, content)
if (result) {
outputStatusLabel.text = "已提交"
Toast.makeText(this@MainActivity, "笔记已保存", Toast.LENGTH_SHORT).show()
} else {
outputStatusLabel.text = "提交失败"
Toast.makeText(this@MainActivity, "保存失败,请检查配置", Toast.LENGTH_SHORT).show()
}
} catch (e: Exception) {
outputStatusLabel.text = "提交失败"
Toast.makeText(this@MainActivity, "保存失败: ${e.message}", Toast.LENGTH_SHORT).show()
Log.e("MainActivity", "saveToNoteApi error", e)
}
}
} catch (e: Exception) {
Toast.makeText(this, "请先配置笔记API", Toast.LENGTH_SHORT).show()
Log.e("MainActivity", "saveToNoteApi error", e)
}
}
private suspend fun submitToNoteApi(apiType: String, apiUrl: String, apiKey: String, content: String): Boolean {
return withContext(Dispatchers.IO) {
try {
val client = OkHttpClient()
val requestBody = when (apiType) {
"Flomo" -> {
val json = JSONObject().put("content", content)
json.toString().toRequestBody("application/json".toMediaType())
}
"Notion" -> {
val json = JSONObject()
.put("parent", JSONObject().put("database_id", apiKey))
.put("properties", JSONObject()
.put("Name", JSONObject()
.put("title", JSONArray()
.put(JSONObject().put("text", JSONObject().put("content", "AI优化结果")))
)
)
)
json.toString().toRequestBody("application/json".toMediaType())
}
else -> {
val json = JSONObject().put("content", content)
json.toString().toRequestBody("application/json".toMediaType())
}
}
val request = Request.Builder()
.url(apiUrl)
.addHeader("Authorization", "Bearer $apiKey")
.addHeader("Content-Type", "application/json")
.post(requestBody)
.build()
val response = client.newCall(request).execute()
response.isSuccessful
} catch (e: Exception) {
Log.e("MainActivity", "submitToNoteApi error", e)
false
}
}
}
data class NoteSettingsData(
val noteApiConfig: NoteApiConfig?
)
data class NoteApiConfig(
val apiType: String,
val apiUrl: String,
val apiKey: String
)
}

View File

@@ -10,11 +10,13 @@ import android.os.Bundle
import android.text.method.PasswordTransformationMethod
import android.util.Log
import android.view.View
import android.widget.ArrayAdapter
import android.widget.Button
import android.widget.EditText
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
import android.widget.Toast
import android.widget.RadioGroup
@@ -66,6 +68,12 @@ class SecondActivity : AppCompatActivity() {
private lateinit var rbThemeFollowSystem: RadioButton
private lateinit var rbThemeLight: RadioButton
private lateinit var rbThemeDark: RadioButton
// Note API view references
private lateinit var spNoteApiType: Spinner
private lateinit var etNoteApiUrl: EditText
private lateinit var etNoteApiKey: EditText
private lateinit var btnToggleNoteApiKey: ImageButton
// Data storage
private var headerConfigs = mutableListOf<HeaderConfig>()
@@ -164,6 +172,12 @@ class SecondActivity : AppCompatActivity() {
rbThemeLight = findViewById(R.id.rbThemeLight)
rbThemeDark = findViewById(R.id.rbThemeDark)
// Note API Section
spNoteApiType = findViewById(R.id.spNoteApiType)
etNoteApiUrl = findViewById(R.id.etNoteApiUrl)
etNoteApiKey = findViewById(R.id.etNoteApiKey)
btnToggleNoteApiKey = findViewById(R.id.btnToggleNoteApiKey)
Log.d("SecondActivity", "initViews: All views found")
// Setup API key toggle
@@ -208,6 +222,19 @@ class SecondActivity : AppCompatActivity() {
}
}
// Setup Note API key toggle
btnToggleNoteApiKey.setOnClickListener {
val isPassword = etNoteApiKey.transformationMethod is PasswordTransformationMethod
etNoteApiKey.transformationMethod = if (isPassword) null else PasswordTransformationMethod()
etNoteApiKey.setSelection(etNoteApiKey.text.length)
if (isPassword) {
btnToggleNoteApiKey.setImageResource(android.R.drawable.ic_menu_view)
} else {
btnToggleNoteApiKey.setImageResource(android.R.drawable.ic_lock_idle_lock)
}
}
Log.d("SecondActivity", "initViews: Completed")
} catch (e: Exception) {
Log.e("SecondActivity", "initViews: Error finding views", e)
@@ -237,6 +264,17 @@ class SecondActivity : AppCompatActivity() {
etApiKey.setText(settings.llmConfig?.apiKey ?: "")
etModel.setText(settings.llmConfig?.model ?: "gpt-4o")
// Load Note API config
settings.noteApiConfig?.let { noteConfig ->
val apiTypes = listOf("Flomo", "Notion", "Joplin", "Custom")
val typeIndex = apiTypes.indexOf(noteConfig.apiType)
if (typeIndex >= 0) {
spNoteApiType.setSelection(typeIndex)
}
etNoteApiUrl.setText(noteConfig.apiUrl)
etNoteApiKey.setText(noteConfig.apiKey)
}
// Update API key visibility based on whether it has text
updateApiKeyVisibility()
@@ -302,6 +340,12 @@ class SecondActivity : AppCompatActivity() {
// Setup theme
setupTheme()
// Setup Note API spinner
val noteApiTypes = listOf("Flomo", "Notion", "Joplin", "Custom")
val noteApiAdapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, noteApiTypes)
noteApiAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
spNoteApiType.adapter = noteApiAdapter
}
private fun setupTheme() {
@@ -405,13 +449,21 @@ class SecondActivity : AppCompatActivity() {
apiKey = etApiKey.text.toString(),
model = etModel.text.toString()
)
// Save Note API config
val noteApiConfig = NoteApiConfig(
apiType = spNoteApiType.selectedItem.toString(),
apiUrl = etNoteApiUrl.text.toString(),
apiKey = etNoteApiKey.text.toString()
)
// Save everything
val settingsData = SettingsData(
llmConfig = llmConfig,
headerConfigs = headerConfigs,
promptConfigs = promptConfigs,
buttonConfigs = buttonConfigs
buttonConfigs = buttonConfigs,
noteApiConfig = noteApiConfig
)
val json = Gson().toJson(settingsData)
@@ -445,11 +497,18 @@ class SecondActivity : AppCompatActivity() {
val apiKey: String,
val model: String
)
data class NoteApiConfig(
val apiType: String,
val apiUrl: String,
val apiKey: String
)
data class SettingsData(
val llmConfig: LLMConfig?,
val headerConfigs: List<HeaderConfig>?,
val promptConfigs: List<PromptConfig>?,
val buttonConfigs: List<ButtonConfig>?
val buttonConfigs: List<ButtonConfig>?,
val noteApiConfig: NoteApiConfig?
)
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/btn_polish_bg" />
<stroke
android:width="1dp"
android:color="@color/btn_polish_border" />
<corners android:radius="14dp" />
</shape>

View File

@@ -2,5 +2,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/primary" />
<corners android:radius="16dp" />
<corners android:radius="14dp" />
</shape>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/icon_container_bg"/>
<corners android:radius="10dp"/>
</shape>

View File

@@ -3,7 +3,7 @@
android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<stroke
android:width="2dp"
android:color="@color/primary" />
<corners android:radius="16dp" />
android:width="1dp"
android:color="@color/config_button_border" />
<corners android:radius="12dp" />
</shape>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/btn_summarize_bg" />
<stroke
android:width="1dp"
android:color="@color/btn_summarize_border" />
<corners android:radius="14dp" />
</shape>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/btn_translate_bg" />
<stroke
android:width="1dp"
android:color="@color/btn_translate_border" />
<corners android:radius="14dp" />
</shape>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/btn_typos_bg" />
<stroke
android:width="1dp"
android:color="@color/btn_typos_border" />
<corners android:radius="14dp" />
</shape>

View File

@@ -3,6 +3,6 @@
<solid android:color="@color/surface" />
<stroke
android:width="1dp"
android:color="@color/border" />
<corners android:radius="16dp" />
android:color="@color/border_default" />
<corners android:radius="14dp" />
</shape>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/primary"/>
<size android:width="6dp" android:height="6dp"/>
</shape>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/surface"/>
<stroke android:width="1dp" android:color="@color/border_default"/>
<corners android:radius="22dp"/>
</shape>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/surface"/>
<stroke android:width="1dp" android:color="@color/card_border"/>
<corners android:radius="14dp"/>
</shape>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/primary"/>
<corners android:radius="14dp"/>
</shape>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/stop_generate_bg"/>
<stroke android:width="1dp" android:color="@color/stop_generate"/>
<corners android:radius="8dp"/>
</shape>

View File

@@ -7,45 +7,64 @@
android:orientation="vertical"
android:background="@color/background">
<!-- 顶部导航栏 - 去掉圆角 -->
<!-- 导航栏 -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="56dp"
android:background="@color/surface"
android:padding="16dp">
android:paddingStart="20dp"
android:paddingEnd="20dp">
<TextView
android:id="@+id/headerTitle"
<LinearLayout
android:id="@+id/headerLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AI优化"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="@color/text_primary"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"/>
android:layout_centerVertical="true"
android:orientation="vertical">
<TextView
android:id="@+id/headerModelName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="gpt-4o"
android:textSize="14sp"
android:textColor="@color/text_hint"
android:layout_alignParentStart="true"
android:layout_below="@id/headerTitle"/>
<TextView
android:id="@+id/headerTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AI优化"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/text_primary"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginTop="2dp">
<View
android:layout_width="6dp"
android:layout_height="6dp"
android:background="@drawable/indicator_dot"/>
<TextView
android:id="@+id/headerModelName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GPT-4o"
android:textSize="11sp"
android:textColor="@color/primary"
android:layout_marginStart="5dp"/>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/configButton"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_height="36dp"
android:text="配置"
android:textSize="14sp"
android:textColor="@color/white"
android:textColor="@color/primary"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginTop="4dp"
android:background="@drawable/button_config_bg"
android:layout_centerVertical="true"
android:background="@drawable/button_secondary_bg"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:minWidth="0dp"
@@ -53,64 +72,245 @@
</RelativeLayout>
<!-- 提示词选择区域 - 去掉圆角 -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<!-- 快速操作 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="快速操作"
android:textSize="12sp"
android:textColor="@color/text_hint"
android:textAllCaps="true"
android:letterSpacing="0.15"
android:layout_marginBottom="14dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="18dp">
<LinearLayout
android:id="@+id/btnCheckTypos"
android:layout_width="34dp"
android:layout_height="34dp"
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/button_quick_bg"
android:layout_marginEnd="10dp">
<TextView
android:layout_width="20dp"
android:layout_height="20dp"
android:text="🔍"
android:textSize="14sp"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:id="@+id/btnSummarize"
android:layout_width="34dp"
android:layout_height="34dp"
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/button_quick_bg"
android:layout_marginEnd="10dp">
<TextView
android:layout_width="20dp"
android:layout_height="20dp"
android:text="📋"
android:textSize="14sp"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:id="@+id/btnTranslate"
android:layout_width="34dp"
android:layout_height="34dp"
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/button_quick_bg"
android:layout_marginEnd="10dp">
<TextView
android:layout_width="20dp"
android:layout_height="20dp"
android:text="🌐"
android:textSize="14sp"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:id="@+id/btnPolishing"
android:layout_width="34dp"
android:layout_height="34dp"
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/button_quick_bg">
<TextView
android:layout_width="20dp"
android:layout_height="20dp"
android:text="✨"
android:textSize="14sp"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
<!-- 提示词 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提示词"
android:textSize="12sp"
android:textColor="@color/text_hint"
android:textAllCaps="true"
android:letterSpacing="0.15"
android:layout_marginBottom="14dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/edittext_border"
android:padding="14dp"
android:layout_marginBottom="18dp">
<Spinner
android:id="@+id/promptSelector"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@android:color/transparent"
android:spinnerMode="dropdown"
android:padding="4dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divider"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"/>
<TextView
android:id="@+id/promptContentText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="@color/text_hint"
android:minLines="1"
android:maxLines="3"/>
</LinearLayout>
<!-- 优化结果 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="优化结果"
android:textSize="12sp"
android:textColor="@color/text_hint"
android:textAllCaps="true"
android:letterSpacing="0.15"
android:layout_marginBottom="14dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/result_card_bg"
android:padding="16dp">
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/primary"
android:layout_marginBottom="12dp"/>
<TextView
android:id="@+id/outputStatusLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="等待发送"
android:textSize="12sp"
android:textColor="@color/primary"
android:layout_marginBottom="8dp"/>
<TextView
android:id="@+id/outputTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minLines="3"
android:textSize="14sp"
android:text="发送消息后结果将在此显示"
android:textColor="@color/text_secondary"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="12dp">
<Button
android:id="@+id/btnCopyResult"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_weight="1"
android:text="复制结果"
android:textSize="12sp"
android:textColor="@color/primary"
android:background="@drawable/button_secondary_bg"
android:minWidth="0dp"
android:minHeight="0dp"
android:layout_marginEnd="8dp"/>
<Button
android:id="@+id/btnSaveNote"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_weight="1"
android:text="提交笔记"
android:textSize="12sp"
android:textColor="@color/primary"
android:background="@drawable/button_secondary_bg"
android:minWidth="0dp"
android:minHeight="0dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<!-- 输入区域 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/surface"
android:padding="16dp"
android:layout_marginTop="1dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提示词"
android:textSize="14sp"
android:textColor="@color/text_primary"
android:layout_marginBottom="8dp"/>
<Spinner
android:id="@+id/promptSelector"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/edittext_border"
android:spinnerMode="dropdown"
android:padding="8dp"/>
<!-- 提示词内容显示区域 -->
<TextView
android:id="@+id/promptContentText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:padding="4dp"
android:textSize="12sp"
android:textColor="@color/text_hint"
android:minLines="1"
android:maxLines="3"/>
</LinearLayout>
<!-- 输入区域 - 去掉圆角 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/surface"
android:padding="16dp"
android:layout_marginTop="1dp">
android:padding="20dp">
<EditText
android:id="@+id/inputEditText"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/edittext_border"
android:layout_height="48dp"
android:background="@drawable/input_bg"
android:hint="输入待发送内容…"
android:inputType="textMultiLine"
android:minLines="5"
android:padding="12dp"
android:textSize="16sp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:textSize="14sp"
android:textColor="@color/text_secondary"
android:textColorHint="@color/text_hint"
android:gravity="top|start"/>
@@ -119,31 +319,45 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="12dp">
<Button
android:id="@+id/sendButton"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:text="发送"
android:textSize="16sp"
android:textColor="@color/white"
android:layout_marginEnd="8dp"
android:background="@drawable/button_primary_bg"
android:minWidth="0dp"
android:minHeight="0dp"/>
android:layout_marginTop="12dp"
android:gravity="center_vertical">
<Button
android:id="@+id/stopButton"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:text="停止生成"
android:textSize="16sp"
android:textColor="@color/primary"
android:layout_marginStart="8dp"
android:background="@drawable/button_secondary_bg"
android:textSize="12sp"
android:textColor="@color/stop_generate"
android:background="@drawable/stop_button_bg"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:visibility="gone"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<TextView
android:id="@+id/tvCharCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0/4000"
android:textSize="11sp"
android:textColor="@color/text_hint"
android:layout_marginEnd="12dp"/>
<Button
android:id="@+id/sendButton"
android:layout_width="42dp"
android:layout_height="42dp"
android:text="➤"
android:textSize="18sp"
android:textColor="@color/white"
android:background="@drawable/send_button_bg"
android:minWidth="0dp"
android:minHeight="0dp"/>
@@ -151,58 +365,4 @@
</LinearLayout>
<!-- 输出区域 - 去掉圆角 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:background="@color/surface"
android:padding="16dp"
android:layout_marginTop="1dp">
<TextView
android:id="@+id/outputStatusLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="等待发送"
android:textSize="14sp"
android:textColor="@color/primary"
android:layout_marginBottom="8dp"/>
<TextView
android:id="@+id/outputTextView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/edittext_border"
android:padding="12dp"
android:textSize="16sp"
android:text="发送消息后结果将在此显示"
android:textColor="@color/text_secondary"/>
</LinearLayout>
<!-- 复制结果按钮 - 去掉圆角 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/surface"
android:padding="16dp"
android:layout_marginTop="1dp">
<Button
android:id="@+id/btnCopyResult"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="复制结果"
android:textSize="16sp"
android:textColor="@color/primary"
android:background="@drawable/button_secondary_bg"
android:minWidth="0dp"
android:minHeight="0dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -308,7 +308,138 @@
</LinearLayout>
</androidx.cardview.widget.CardView>
<!-- 4. 自定义提示词卡片 -->
<!-- 4. 笔记API配置卡片 -->
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
app:cardBackgroundColor="@color/surface"
app:cardCornerRadius="16dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- 卡片标题 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="笔记API配置"
android:textColor="@color/text_primary"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="配置第三方笔记应用API"
android:textColor="@color/text_hint"
android:textSize="14sp" />
<!-- API类型选择 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="API类型"
android:textColor="@color/text_secondary"
android:textSize="14sp" />
<Spinner
android:id="@+id/spNoteApiType"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="8dp"
android:background="@drawable/edittext_border"
android:spinnerMode="dropdown"
android:padding="12dp"/>
<!-- API URL -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="API地址"
android:textColor="@color/text_secondary"
android:textSize="14sp" />
<EditText
android:id="@+id/etNoteApiUrl"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="8dp"
android:background="@drawable/edittext_border"
android:hint="https://api.example.com/notes"
android:inputType="textUri"
android:padding="12dp"
android:textColor="@color/text_secondary"
android:textColorHint="@color/text_hint"
android:textSize="16sp" />
</LinearLayout>
<!-- API Key -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="API密钥"
android:textColor="@color/text_secondary"
android:textSize="14sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="8dp"
android:background="@drawable/edittext_border">
<EditText
android:id="@+id/etNoteApiKey"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:hint="API Key"
android:inputType="textPassword"
android:paddingStart="12dp"
android:paddingEnd="48dp"
android:textColor="@color/text_secondary"
android:textColorHint="@color/text_hint"
android:textSize="16sp" />
<ImageButton
android:id="@+id/btnToggleNoteApiKey"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentEnd="true"
android:layout_centerInParent="true"
android:layout_marginEnd="12dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="显示/隐藏"
android:src="@android:drawable/ic_lock_idle_lock"
app:tint="@color/text_hint" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<!-- 5. 自定义提示词卡片 -->
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@@ -1,38 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="foreground_color">#eFeFeF</color>
<color name="background_color">#333333</color>
<color name="gray_light">#CCCCCC</color>
<color name="semi_transparent_background">#19000000</color>
<!-- 核心色值 -->
<color name="primary">#42A5F5</color>
<color name="primary_variant">#1976D2</color>
<color name="secondary">#81C784</color>
<color name="secondary_variant">#4CAF50</color>
<color name="primary">#2DD4A8</color>
<color name="primary_variant">#1A1D27</color>
<color name="secondary">#2DD4A8</color>
<color name="secondary_variant">#1A1D27</color>
<!-- 中性-->
<color name="background">#F5F5F5</color>
<color name="surface">#FAFAFA</color>
<color name="surface_variant">#EEEEEE</color> <!-- 用于卡片阴影/边框 -->
<!-- 背景-->
<color name="background">#0F1117</color>
<color name="surface">#1A1D27</color>
<color name="surface_elevated">#232733</color>
<!-- 文本-->
<color name="text_primary">#212121</color>
<color name="text_secondary">#424242</color>
<color name="text_hint">#757575</color>
<color name="text_disabled">#BDBDBD</color>
<!-- 主强调-->
<color name="primary_light">#1A2DD4A8</color>
<!-- 文字层级 -->
<color name="text_primary">#F0F2F5</color>
<color name="text_secondary">#C8CDD5</color>
<color name="text_hint">#6B7280</color>
<color name="text_placeholder">#4B5260</color>
<!-- 四个操作按钮颜色 -->
<!-- 检查错别字 -->
<color name="btn_typos_bg">#0E38BDF8</color>
<color name="btn_typos_icon">#38BDF8</color>
<color name="btn_typos_border">#4D38BDF8</color>
<!-- 总结 -->
<color name="btn_summarize_bg">#0E2DD4A8</color>
<color name="btn_summarize_icon">#2DD4A8</color>
<color name="btn_summarize_border">#4D2DD4A8</color>
<!-- 翻译 -->
<color name="btn_translate_bg">#0EFBBF24</color>
<color name="btn_translate_icon">#FBBF24</color>
<color name="btn_translate_border">#4DFBBF24</color>
<!-- 润色 -->
<color name="btn_polish_bg">#0EF472B6</color>
<color name="btn_polish_icon">#F472B6</color>
<color name="btn_polish_border">#4DF472B6</color>
<!-- 功能色 -->
<color name="stop_generate">#F59E0B</color>
<color name="stop_generate_bg">#14F59E0B</color>
<color name="config_button_border">#402DD4A8</color>
<color name="divider">#0FFFFFFF</color>
<color name="card_border">#14FFFFFF</color>
<!-- 图标容器 -->
<color name="icon_container_bg">#0AFFFFFF</color>
<!-- 边框色 -->
<color name="border">#E0E0E0</color>
<color name="border_default">#14FFFFFF</color>
<color name="border_focused">#4D2DD4A8</color>
<color name="border_glow">#0F2DD4A8</color>
<!-- 状态色 -->
<!-- 其他 -->
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="success">#4CAF50</color>
<color name="warning">#FF9800</color>
<color name="error">#F44336</color>