From d083c9488b600d55a0991fba3c92e42e1b8c871b Mon Sep 17 00:00:00 2001 From: huanghaohao <759903577@qq.com> Date: Fri, 27 Nov 2026 17:14:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=8B=BE=E8=A7=81=E5=83=8F?= =?UTF-8?q?=E7=B4=A0=E5=8F=AF=E7=88=B1=E9=A3=8E=E7=95=8C=E9=9D=A2=E5=B9=B6?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9C=9F=E6=9C=BA=E9=AA=8C=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 4 +- .../main/java/com/jieliu/app/MainActivity.kt | 183 +++- app/src/main/res/drawable/ui_dropdown.xml | 20 + .../main/res/drawable/ui_dropdown_arrow.xml | 8 + app/src/main/res/drawable/ui_header.xml | 6 + .../main/res/drawable/ui_header_pixels.xml | 10 + .../main/res/drawable/ui_mascot_thumbnail.xml | 5 + app/src/main/res/drawable/ui_navigation.xml | 8 + app/src/main/res/layout/activity_main.xml | 68 +- app/src/main/res/values-v27/styles.xml | 2 +- app/src/main/res/values/colors.xml | 20 + app/src/main/res/values/styles.xml | 18 +- docs/ui-cute-preview.html | 844 ++++++++++++++++++ docs/ui-preview.html | 177 ++-- docs/开发进度.md | 15 +- 15 files changed, 1259 insertions(+), 129 deletions(-) create mode 100644 app/src/main/res/drawable/ui_dropdown.xml create mode 100644 app/src/main/res/drawable/ui_dropdown_arrow.xml create mode 100644 app/src/main/res/drawable/ui_header.xml create mode 100644 app/src/main/res/drawable/ui_header_pixels.xml create mode 100644 app/src/main/res/drawable/ui_mascot_thumbnail.xml create mode 100644 app/src/main/res/drawable/ui_navigation.xml create mode 100644 docs/ui-cute-preview.html diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c10ac65..5b6a839 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -13,8 +13,8 @@ android { applicationId = "com.jieliu.app" minSdk = 26 targetSdk = 35 - versionCode = 46 - versionName = "0.1.45" + versionCode = 47 + versionName = "0.1.46" } compileOptions { diff --git a/app/src/main/java/com/jieliu/app/MainActivity.kt b/app/src/main/java/com/jieliu/app/MainActivity.kt index d6d562d..6c4edc6 100644 --- a/app/src/main/java/com/jieliu/app/MainActivity.kt +++ b/app/src/main/java/com/jieliu/app/MainActivity.kt @@ -9,16 +9,20 @@ import android.content.res.ColorStateList import android.graphics.Color import android.graphics.Typeface import android.graphics.drawable.GradientDrawable +import android.graphics.drawable.LayerDrawable import android.graphics.drawable.RippleDrawable +import android.graphics.drawable.StateListDrawable import android.os.Build import android.os.Bundle import android.os.Handler import android.os.Looper import android.provider.Settings import android.text.InputType +import android.text.TextUtils import android.util.Log import android.view.Gravity import android.view.View +import android.view.ViewGroup import android.view.WindowInsets import android.view.inputmethod.InputMethodManager import android.widget.AdapterView @@ -52,6 +56,14 @@ import java.util.concurrent.FutureTask class MainActivity : Activity() { private enum class Tab { TASK, SETTINGS, LOGS } + private enum class ButtonStyle(val fill: Int, val text: Int) { + PRIMARY(R.color.ui_coral, R.color.ui_paper), + SECONDARY(R.color.ui_blue_tint, R.color.ui_blue), + DESTRUCTIVE(R.color.ui_coral_tint, R.color.ui_coral_pressed), + CONFIRM_DESTRUCTIVE(R.color.ui_coral_pressed, R.color.ui_paper), + TAB(R.color.ui_nav_surface, R.color.ui_blue), + SELECTED_TAB(R.color.ui_selected, R.color.ui_blue), + } private data class TaskView( val checkpoint: TaskCheckpoint?, val connected: Boolean, val step: String?, val notificationsOff: Boolean, @@ -110,6 +122,7 @@ class MainActivity : Activity() { } if (Build.VERSION.SDK_INT in 30..34) configureEdgeToEdge() setContentView(R.layout.activity_main) + findViewById(R.id.brand_mascot).clipToOutline = true val root = findViewById(R.id.root) if (Build.VERSION.SDK_INT >= 30) { root.setOnApplyWindowInsetsListener { view, insets -> @@ -234,7 +247,10 @@ class MainActivity : Activity() { currentFocus?.let { getSystemService(InputMethodManager::class.java).hideSoftInputFromWindow(it.windowToken, 0) } } selected = tab - tabs.forEachIndexed { index, button -> styleButton(button, index == selected.ordinal) } + tabs.forEachIndexed { index, button -> + button.isSelected = index == selected.ordinal + styleButton(button, if (button.isSelected) ButtonStyle.SELECTED_TAB else ButtonStyle.TAB) + } taskView = null logVersion = -1 content.removeAllViews() @@ -294,15 +310,16 @@ class MainActivity : Activity() { else -> "准备运行" } return column().apply { - addView(card(title).apply { + addView(card(title, status = true).apply { val modeLabel = bilibiliScope?.label ?: if (plan.replyMode == ReplyMode.BROWSE) ReplyMode.BROWSE.label else ReplyMode.TEMPLATES.label - addView(label("$platform · $modeLabel", 15)) + addView(label("$platform · $modeLabel", 15, bold = true)) addView(label(view.step ?: checkpoint?.message ?: "内容类型 ${searchTypes.size} 个 · 单次 ${plan.limit} 个$contentUnit", 15)) val limit = checkpoint?.plan?.limit ?: plan.limit addView(ProgressBar(this@MainActivity, null, android.R.attr.progressBarStyleHorizontal).apply { max = limit progress = completed - progressTintList = ColorStateList.valueOf(GREEN) + progressTintList = ColorStateList.valueOf(getColor(R.color.ui_green)) + progressBackgroundTintList = ColorStateList.valueOf(getColor(R.color.ui_grass_line)) contentDescription = "已处理 $completed 个$contentUnit,共 $limit 个" }, LinearLayout.LayoutParams(-1, dp(18))) addView(label("已处理$contentUnit $completed / $limit · $confirmedLabel ${checkpoint?.sentCount ?: 0} 条", 14)) @@ -360,22 +377,18 @@ class MainActivity : Activity() { private fun settingsPage() = column().apply { addView(guardedPage(::configPage)) addView(card("本机数据").apply { - addView(action("一键清除所有已保存数据", click = ::confirmClearSavedData).apply { - setTextColor(ALERT) - background = RippleDrawable(ColorStateList.valueOf(0x22863c15), rounded(0xffffeee6.toInt(), 12), null) - }) + (layoutParams as LinearLayout.LayoutParams).topMargin = dp(12) + addView(action("一键清除所有已保存数据", destructive = true, click = ::confirmClearSavedData)) }) } private fun confirmClearSavedData() { checkSavedDataCanBeCleared() - val dialog = AlertDialog.Builder(this) + showDialog(AlertDialog.Builder(this) .setTitle("清除所有已保存数据?") .setMessage("将清除拾见本机保存的配置、内容库、绑定图片、任务检查点和运行日志。DeepSeek 密钥会保留。清除后恢复默认设置,此操作无法撤销。") .setNegativeButton("取消", null) - .setPositiveButton("清除数据") { _, _ -> perform(::startSavedDataReset) } - .show() - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(ALERT) + .setPositiveButton("清除数据") { _, _ -> perform(::startSavedDataReset) }, destructive = true) } private fun checkSavedDataCanBeCleared() { @@ -719,7 +732,7 @@ class MainActivity : Activity() { Triple("移除图片", true, null), ) photoControls.addView(buttonRow(operations.map { (title, available, movedTo) -> - action(title) { + action(title, destructive = movedTo == null) { val latest = findPhrase(target) ?: return@action if (latest.photos != entries || photoImport != null) return@action val reordered = entries.toMutableList() @@ -742,21 +755,38 @@ class MainActivity : Activity() { private fun logsPage() = column().apply { val lines = store.recentLog() addView(card("运行日志").apply { - if (lines.isEmpty()) addView(label("启动任务后会在这里显示运行步骤。", 15)) - lines.forEach { addView(label(it, 14, color = if (" 异常 " in it) ALERT else INK)) } + if (lines.isEmpty()) addView(label("启动任务后会在这里显示运行步骤。", 15, color = getColor(R.color.ui_muted))) + lines.forEach { addView(logEntry(it)) } }) } + private fun logEntry(line: String) = column().apply { + val warning = " 异常 " in line + val dateEnd = line.indexOf(" ") + val fill = getColor(if (warning) R.color.ui_coral_tint else R.color.ui_grass_tint) + val border = getColor(if (warning) R.color.ui_coral_tint else R.color.ui_grass_line) + val text = getColor(if (warning) R.color.ui_coral_pressed else R.color.ui_ink) + background = rounded(fill, 10, border) + setPadding(dp(10), dp(6), dp(10), dp(6)) + layoutParams = LinearLayout.LayoutParams(-1, -2).apply { bottomMargin = dp(7) } + if (dateEnd >= 0) { + addView(label(line.substring(0, dateEnd), 12, color = getColor(R.color.ui_muted)).apply { setPadding(0, 0, 0, 0) }) + } + addView(label(line.substring(if (dateEnd >= 0) dateEnd + 2 else 0), 14, color = text).apply { setPadding(0, 0, 0, 0) }) + } + private fun photoPreview(photo: TemplatePhoto, index: Int) = column().apply { addView(label("图片 ${index + 1} · ${photo.displayName}", 14)) val bitmap = photos.thumbnail(photo) if (bitmap == null) { - addView(label("图片缺失或无法预览。", 14, color = ALERT)) + addView(label("图片缺失或无法预览。", 14, color = getColor(R.color.ui_coral_pressed))) } else { addView(ImageView(this@MainActivity).apply { setImageBitmap(bitmap) adjustViewBounds = true scaleType = ImageView.ScaleType.FIT_CENTER + background = rounded(getColor(R.color.ui_field), 9, getColor(R.color.ui_line)) + clipToOutline = true contentDescription = "第 ${index + 1} 张图片预览" }, LinearLayout.LayoutParams(dp(96), dp(76))) } @@ -773,7 +803,7 @@ class MainActivity : Activity() { photoCount > 1 -> "已在目标应用看到这条评论的文字和全部 $photoCount 张图片?" else -> "已在目标应用看到这条评论?" } - AlertDialog.Builder(this).setMessage(prompt) + showDialog(AlertDialog.Builder(this).setMessage(prompt) .setNegativeButton("返回", null) .setPositiveButton("确认") { _, _ -> perform { check(!TaskControl.inProgress) { "请先暂停任务。" } @@ -788,18 +818,18 @@ class MainActivity : Activity() { } store.appendLog(message) renderTask() - } }.show() + } }, destructive = outcome != Outcome.USER_CONFIRMED) } private fun abandon() { - AlertDialog.Builder(this).setMessage("放弃当前任务并清空这次的恢复进度?") + showDialog(AlertDialog.Builder(this).setMessage("放弃当前任务并清空这次的恢复进度?") .setNegativeButton("返回", null) .setPositiveButton("放弃") { _, _ -> perform { check(!TaskControl.inProgress && store.readCheckpoint()?.pending == null) { "请先核对待确认的评论。" } store.clearCheckpoint() store.appendLog("用户放弃了当前任务") renderTask() - } }.show() + } }, destructive = true) } private fun column() = LinearLayout(this).apply { @@ -807,14 +837,30 @@ class MainActivity : Activity() { isFocusableInTouchMode = true } - private fun card(title: String) = column().apply { - background = rounded(Color.WHITE, 18) + private fun card(title: String, status: Boolean = false) = column().apply { + val fill = getColor(if (status) R.color.ui_grass_card else R.color.ui_paper) + val border = getColor(if (status) R.color.ui_grass_line else R.color.ui_line) + val marker = getColor(if (status) R.color.ui_marker_green else R.color.ui_marker_blue) + background = rounded(fill, 19, border) + elevation = dp(1).toFloat() setPadding(dp(16), dp(12), dp(16), dp(14)) layoutParams = LinearLayout.LayoutParams(-1, -2).apply { bottomMargin = dp(12) } - addView(label(title, 19, bold = true)) + addView(LinearLayout(this@MainActivity).apply { + gravity = Gravity.CENTER_VERTICAL + addView(View(this@MainActivity).apply { + importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO + background = LayerDrawable(arrayOf(rounded(border, 0), rounded(marker, 0))).apply { + setLayerInset(0, dp(3), dp(3), 0, 0) + setLayerInset(1, 0, 0, dp(3), dp(3)) + } + }, LinearLayout.LayoutParams(dp(10), dp(10)).apply { marginEnd = dp(9) }) + addView(label(title, 18, bold = true, color = getColor(if (status) R.color.ui_green else R.color.ui_ink)).apply { + if (Build.VERSION.SDK_INT >= 28) isAccessibilityHeading = true + }, LinearLayout.LayoutParams(0, -2, 1f)) + }) } - private fun label(text: String, size: Int, bold: Boolean = false, color: Int = INK) = TextView(this).apply { + private fun label(text: String, size: Int, bold: Boolean = false, color: Int = getColor(R.color.ui_ink)) = TextView(this).apply { this.text = text textSize = size.toFloat() setTextColor(color) @@ -826,10 +872,21 @@ class MainActivity : Activity() { adapter = choiceAdapter(values) setSelection(selected) minimumHeight = dp(48) + setBackgroundResource(R.drawable.ui_dropdown) + setPaddingRelative(dp(12), 0, dp(34), 0) + setPopupBackgroundDrawable(rounded(getColor(R.color.ui_paper), 12, getColor(R.color.ui_line))) } - private fun choiceAdapter(values: List) = ArrayAdapter(this, android.R.layout.simple_spinner_item, values).apply { - setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) + private fun choiceAdapter(values: List) = object : ArrayAdapter(this, android.R.layout.simple_spinner_item, values) { + init { setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) } + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View = + (super.getView(position, convertView, parent) as TextView).apply { + setTextColor(getColor(R.color.ui_ink)) + textSize = 15f + ellipsize = TextUtils.TruncateAt.END + maxLines = 1 + } } private fun libraryChoices(entries: List>, selectedId: String?, placeholder: String, select: (String) -> Unit): Spinner = @@ -851,15 +908,17 @@ class MainActivity : Activity() { contentDescription = "编辑$entity" applyEnabled(hasSelection) }, - action("删除", click = delete).apply { + action("删除", destructive = true, click = delete).apply { contentDescription = "删除$entity" applyEnabled(hasSelection) }, )) private fun buttonRow(buttons: List + + + + +
+ + +
+ + + +
+
+
+ + +
+ + + +
+
+ + + +
+

本机数据

+ +
+ + + + + + +
+
日志
+
+

拾见

+
+
+

运行日志

+ +
    +
  •  运行 任务完成 · 处理 1 条 · 确认发送 1 条
  • +
  •  运行 第 1 条视频已确认 1/1 条回复
  • +
  •  异常 抖音评论未回读到完整内容或未看到唯一发送按钮
  • +
  •  运行 搜索内容类型 模型服务
  • +
  •  运行 开始任务 · 匹配评论并回复 · 上限 3 条
  • +
  •  运行 任务完成 · 处理 3 条 · 确认发送 0 条
  • +
  •  运行 观看第 3 条 · 7 秒
  • +
  •  运行 观看第 2 条 · 11 秒
  • +
  •  运行 观看第 1 条 · 8 秒
  • +
+
+
+ +
+
+ + + +
+

+ + + +
+ + +
+
+
+ +

+
+ + +
+
+ +

清除所有已保存数据?

+

将清除拾见本机保存的配置、内容库、绑定图片、任务检查点和运行日志。DeepSeek 密钥会保留。清除后恢复默认设置,此操作无法撤销。

+
+ + +
+
+ + + diff --git a/docs/ui-preview.html b/docs/ui-preview.html index 02c65c7..e157e20 100644 --- a/docs/ui-preview.html +++ b/docs/ui-preview.html @@ -8,25 +8,33 @@ 拾见 · 界面预览