通知完成卡文案更新;已完成显示紧急度;饼图标注对称;热力图标签间距;重要度改竖线图标;重复新增随时置顶(v0.9)

This commit is contained in:
XIGE
2026-11-29 09:49:18 +08:00
parent cac0fc66f4
commit e5111fdf79
10 changed files with 91 additions and 31 deletions

View File

@@ -373,6 +373,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
}
companion object {
const val VERSION = "0.8"
const val VERSION = "0.9"
}
}

View File

@@ -84,22 +84,41 @@ class TaskAdapter(
val task = row.task
val ctx = itemView.context
// 紧急度五角星直接拼在标题后:紧急三颗红 / 中两颗绿 / 不急一颗灰;
// 完成任务不再显示。用 spannable 保证星星紧贴标题而不是被推到行尾。
// 标题右侧的属性图标,未完成与已完成都显示:
// 重要度竖线(高3/中2/低1,颜色与紧急度同色系)→ 紧急度五角星 → 随时图钉。
// 用 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)
val (bars, barColor) = when (task.priority) {
2 -> " ▏▏▏" to R.color.urgent_high
1 -> " ▏▏" to R.color.urgent_mid
else -> " ▏" to R.color.urgent_low
}
title.append(bars)
title.setSpan(
android.text.style.ForegroundColorSpan(ctx.col(barColor)),
title.length - bars.length, title.length, 0
)
title.setSpan(RelativeSizeSpan(0.95f), title.length - bars.length, title.length, 0)
// 紧急度五角星:紧急三颗红 / 中两颗绿 / 不急一颗灰
val (stars, starColor) = when (task.urgency) {
2 -> " ★★★" to R.color.urgent_high
1 -> " ★★" to R.color.urgent_mid
else -> " ★" to R.color.urgent_low
}
title.append(stars)
title.setSpan(
android.text.style.ForegroundColorSpan(ctx.col(starColor)),
title.length - stars.length, title.length, 0
)
title.setSpan(RelativeSizeSpan(0.95f), title.length - stars.length, title.length, 0)
// 「随时」任务:标题后带置顶图钉,列表里排在未完成最前面
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
title.append(" 📌")
}
tvTitle.text = title
tvTitle.paintFlags = if (task.done) {
tvTitle.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
@@ -156,7 +175,7 @@ class TaskAdapter(
val label = Dates.dueLabel(task.due)
parts.add(if (row.overdue) ctx.getString(R.string.task_meta_overdue, label) else label)
}
if (task.priority >= 2) parts.add(ctx.getString(R.string.task_priority_high))
// 重要度已改为标题后的竖线图标,meta 里不再重复「高优先」文字
return parts.joinToString(" · ")
}
}

View File

@@ -172,12 +172,13 @@ class TaskSheet(
tvFocus.text = context.getString(R.string.minutes_value, focusMin)
}
/** 重复单位四选一;选了非"不重复"才露出间隔步进器 */
/** 重复单位五选一;只有真正的周期重复(天/周/月)才露出间隔步进器 */
private fun renderRepeat() {
val ctx = context
repeatRow.removeAllViews()
val labels = listOf(
Repeat.NONE to R.string.repeat_none,
Repeat.ANYTIME to R.string.repeat_anytime,
Repeat.DAY to R.string.repeat_day,
Repeat.WEEK to R.string.repeat_week,
Repeat.MONTH to R.string.repeat_month,
@@ -190,7 +191,7 @@ class TaskSheet(
}
repeatRow.addView(chip)
}
val repeating = repeatType != Repeat.NONE
val repeating = repeatType in Repeat.DAY..Repeat.MONTH
repeatEveryRow.visible(repeating)
if (repeating) {
val unit = ctx.getString(
@@ -202,9 +203,22 @@ class TaskSheet(
)
tvEvery.text = "$repeatEvery $unit"
}
// 「随时」没有日期概念:日期按钮置灰禁用
if (repeatType == Repeat.ANYTIME) {
btnDue.isEnabled = false
}
updateDue()
}
private fun updateDue() {
if (repeatType == Repeat.ANYTIME) {
// 随时任务不设日期,日期按钮禁用、清除按钮隐藏
btnDue.text = context.getString(R.string.repeat_anytime)
btnDue.setTextColor(context.col(R.color.text_secondary))
btnClearDue.visible(false)
return
}
btnDue.isEnabled = true
btnDue.text = if (due > 0) Dates.mdLong(due) else context.getString(R.string.no_due)
btnDue.setTextColor(context.col(if (due > 0) R.color.text else R.color.text_secondary))
btnClearDue.visible(due > 0)
@@ -235,9 +249,15 @@ class TaskSheet(
return
}
val note = etNote.text.toString().trim()
val every = if (repeatType == Repeat.NONE) 1 else repeatEvery.coerceAtLeast(1)
// 重复任务必须有日期作为节奏起点,否则既进不了「今日」,也无法按间隔滚动
val effectiveDue = if (repeatType != Repeat.NONE && due <= 0) Dates.todayStart() else due
val periodic = repeatType in Repeat.DAY..Repeat.MONTH
val every = if (!periodic) 1 else repeatEvery.coerceAtLeast(1)
// 周期重复必须有日期作为节奏起点,否则既进不了「今日」,也无法按间隔滚动;
// 「随时」正好相反:不设日期,靠置顶排序呈现
val effectiveDue = when {
repeatType == Repeat.ANYTIME -> 0L
periodic && due <= 0 -> Dates.todayStart()
else -> due
}
if (existing == null) {
Store.addTask(title, note, projectId, priority, focusMin, effectiveDue, repeatType, every, urgency)
} else {