列表星标紧贴标题、开始按钮圆底自动开跑;主题弹窗圆角化与版权V化

This commit is contained in:
XIGE
2026-11-28 17:40:00 +08:00
parent edde6e84fc
commit d319eb1d10
7 changed files with 148 additions and 62 deletions

View File

@@ -2,6 +2,8 @@ package com.focusbox.app.ui.tasks
import android.graphics.Paint
import android.graphics.Typeface
import android.text.SpannableStringBuilder
import android.text.style.RelativeSizeSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -67,7 +69,6 @@ class TaskAdapter(
private inner class TaskViewHolder(v: View) : RecyclerView.ViewHolder(v) {
private val tvTitle: TextView = v.findViewById(R.id.tvTitle)
private val tvStars: TextView = v.findViewById(R.id.tvStars)
private val tvMeta: TextView = v.findViewById(R.id.tvMeta)
private val tvNote: TextView = v.findViewById(R.id.tvNote)
private val checkCircle: View = v.findViewById(R.id.checkCircle)
@@ -79,7 +80,23 @@ class TaskAdapter(
val task = row.task
val ctx = itemView.context
tvTitle.text = task.title
// 紧急度五角星直接拼在标题后:紧急三颗红 / 中两颗绿 / 不急一颗灰;
// 完成任务不再显示。用 spannable 保证星星紧贴标题而不是被推到行尾。
val title = SpannableStringBuilder(task.title)
if (!task.done) {
val (stars, color) = when (task.urgency) {
2 -> " ★★★" to R.color.urgent_high
1 -> " ★★" to R.color.urgent_mid
else -> " ★" to R.color.urgent_low
}
val start = title.length
title.append(stars)
title.setSpan(
android.text.style.ForegroundColorSpan(ctx.col(color)), start, title.length, 0
)
title.setSpan(RelativeSizeSpan(0.95f), start, title.length, 0)
}
tvTitle.text = title
tvTitle.paintFlags = if (task.done) {
tvTitle.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
} else {
@@ -88,20 +105,6 @@ class TaskAdapter(
tvTitle.setTextColor(ctx.col(if (task.done) R.color.text_tertiary else R.color.text))
tvTitle.typeface = if (task.priority >= 2 && !task.done) Typeface.DEFAULT_BOLD else Typeface.DEFAULT
// 紧急度五角星:紧急三颗红 / 中两颗绿 / 不急一颗灰;完成任务不再显示
if (!task.done) {
val (stars, color) = when (task.urgency) {
2 -> "★★★" to R.color.urgent_high
1 -> "★★" to R.color.urgent_mid
else -> "★" to R.color.urgent_low
}
tvStars.text = stars
tvStars.setTextColor(ctx.col(color))
tvStars.visible(true)
} else {
tvStars.visible(false)
}
if (task.done) {
checkCircle.background = ctx.circleBg(ctx.col(R.color.brand))
checkMark.visible(true)
@@ -128,7 +131,7 @@ class TaskAdapter(
tvNote.visible(task.note.isNotBlank())
btnPlay.visible(!task.done)
btnPlay.tint(ctx.col(R.color.text_tertiary))
btnPlay.tint(ctx.col(R.color.brand))
checkWrap.setOnClickListener { onToggle(task) }
itemView.setOnClickListener { onEdit(task) }