通知完成卡文案更新;已完成显示紧急度;饼图标注对称;热力图标签间距;重要度改竖线图标;重复新增随时置顶(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

@@ -1,5 +1,9 @@
# 变更记录 # 变更记录
## 2026-11-29 · 通知完成卡文案更新;已完成显示紧急度;饼图标注对称;热力图标签间距;重要度改竖线图标;重复新增随时置顶(v0.9)
- 同步源码更新 9 个文件(新增/修改 9,删除 0)。
## 2026-11-29 · 修复:移除常驻通知底部模板按钮;提前完成只留带备注记录、隐藏无备注源任务行(v0.8) ## 2026-11-29 · 修复:移除常驻通知底部模板按钮;提前完成只留带备注记录、隐藏无备注源任务行(v0.8)
- Notif:删除常驻通知底部的模板兜底 Action(暂停/继续、结束)——自定义布局右侧已有按钮,模板按钮会在通知下方重复画一排 - Notif:删除常驻通知底部的模板兜底 Action(暂停/继续、结束)——自定义布局右侧已有按钮,模板按钮会在通知下方重复画一排

View File

@@ -225,9 +225,11 @@ object Store {
args.add(projectId.toString()) args.add(projectId.toString())
} }
if (!includeDone) where.append(" AND done = 0") if (!includeDone) where.append(" AND done = 0")
// 已完成的按完成时间倒序(最近做完的排前面),未完成的按截止/优先级 // 已完成的按完成时间倒序(最近做完的排前面),未完成的按截止/优先级;
// 「随时」任务(repeat_type=4)排到未完成最前面,随时可以开始
val sql = "SELECT $taskColumns FROM tasks WHERE $where " + val sql = "SELECT $taskColumns FROM tasks WHERE $where " +
"ORDER BY done ASC, CASE WHEN done = 1 THEN done_at ELSE 0 END DESC, " + "ORDER BY done ASC, CASE WHEN done = 1 THEN done_at ELSE 0 END DESC, " +
"CASE WHEN done = 0 AND repeat_type = ${Repeat.ANYTIME} THEN 0 ELSE 1 END ASC, " +
"CASE WHEN due = 0 THEN 1 ELSE 0 END ASC, due ASC, priority DESC, _id DESC" "CASE WHEN due = 0 THEN 1 ELSE 0 END ASC, due ASC, priority DESC, _id DESC"
val list = ArrayList<Task>() val list = ArrayList<Task>()
db.rawQuery(sql, args.toTypedArray()).use { c -> db.rawQuery(sql, args.toTypedArray()).use { c ->
@@ -412,7 +414,8 @@ object Store {
val today = Dates.todayStart() val today = Dates.todayStart()
val all = ArrayList<Task>() val all = ArrayList<Task>()
db.rawQuery( db.rawQuery(
"SELECT $taskColumns FROM tasks WHERE repeat_type > 0 AND repeat_every > 0", // 只滚真正的周期重复(1-3);「随时」(4) 与不重复 (0) 不参与
"SELECT $taskColumns FROM tasks WHERE repeat_type IN (1, 2, 3) AND repeat_every > 0",
null, null,
).use { c -> ).use { c ->
while (c.moveToNext()) all.add(cursorToTask(c)) while (c.moveToNext()) all.add(cursorToTask(c))

View File

@@ -22,6 +22,12 @@ object Repeat {
const val DAY = 1 const val DAY = 1
const val WEEK = 2 const val WEEK = 2
const val MONTH = 3 const val MONTH = 3
/**
* 随时:不设截止日、不按周期滚动,未完成列表里置顶,
* 标题后带置顶图标。必须大于 NONE 但不能进周期滚动(rollRepeatingTasks 只认 1-3)。
*/
const val ANYTIME = 4
} }
data class Task( data class Task(
@@ -45,7 +51,8 @@ data class Task(
/** 仅在完成记录上有效:这一轮的专注秒数,配合 createdAt/doneAt 显示真实起止 */ /** 仅在完成记录上有效:这一轮的专注秒数,配合 createdAt/doneAt 显示真实起止 */
val logSeconds: Int = 0, val logSeconds: Int = 0,
) { ) {
val repeating: Boolean get() = repeatType != Repeat.NONE && repeatEvery > 0 /** 「随时」只是置顶标记,不算周期重复,不参与跨零点滚动 */
val repeating: Boolean get() = repeatType in Repeat.DAY..Repeat.MONTH && repeatEvery > 0
} }
/** 一条专注记录的起止时刻与实际秒数,用于在已完成任务上显示真实工作时段。 */ /** 一条专注记录的起止时刻与实际秒数,用于在已完成任务上显示真实工作时段。 */

View File

@@ -179,7 +179,7 @@ object Notif {
if (focusDone) R.string.notif_focus_done else R.string.notif_break_done if (focusDone) R.string.notif_focus_done else R.string.notif_break_done
) )
val text = if (focusDone) { val text = if (focusDone) {
context.getString(R.string.notif_focus_done_text, breakMinutes) context.getString(R.string.notif_focus_done_text)
} else { } else {
context.getString(R.string.notif_break_done_text) context.getString(R.string.notif_break_done_text)
} }

View File

@@ -373,6 +373,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
} }
companion object { 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 task = row.task
val ctx = itemView.context val ctx = itemView.context
// 紧急度五角星直接拼在标题后:紧急三颗红 / 中两颗绿 / 不急一颗灰; // 标题右侧的属性图标,未完成与已完成都显示:
// 完成任务不再显示。用 spannable 保证星星紧贴标题而不是被推到行尾。 // 重要度竖线(高3/中2/低1,颜色与紧急度同色系)→ 紧急度五角星 → 随时图钉。
// 用 spannable 保证图标紧贴标题而不是被推到行尾。
val title = SpannableStringBuilder(task.title) val title = SpannableStringBuilder(task.title)
if (!task.done) {
val (stars, color) = when (task.urgency) { val (bars, barColor) = when (task.priority) {
2 -> " ★★★" to R.color.urgent_high 2 -> " ▏▏▏" to R.color.urgent_high
1 -> " ★★" to R.color.urgent_mid 1 -> " ▏▏" to R.color.urgent_mid
else -> " ★" to R.color.urgent_low 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)
} }
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.text = title
tvTitle.paintFlags = if (task.done) { tvTitle.paintFlags = if (task.done) {
tvTitle.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG tvTitle.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
@@ -156,7 +175,7 @@ class TaskAdapter(
val label = Dates.dueLabel(task.due) val label = Dates.dueLabel(task.due)
parts.add(if (row.overdue) ctx.getString(R.string.task_meta_overdue, label) else label) 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(" · ") return parts.joinToString(" · ")
} }
} }

View File

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

View File

@@ -145,7 +145,8 @@ class HeatmapView @JvmOverloads constructor(
override fun onDraw(canvas: Canvas) { override fun onDraw(canvas: Canvas) {
if (days.isEmpty()) return if (days.isEmpty()) return
val labelW = context.dpf(18f) // 标签列加宽到 24dp,文字右缘离第一列图块 8dp,行名与色块不再贴在一起
val labelW = context.dpf(24f)
val gap = context.dpf(3f) val gap = context.dpf(3f)
val firstMs = Dates.dayStartOfKey(days.first().key) val firstMs = Dates.dayStartOfKey(days.first().key)
val startCol = weekdayIndex(firstMs) // 第一列从周一算起,前面留空 val startCol = weekdayIndex(firstMs) // 第一列从周一算起,前面留空
@@ -175,7 +176,7 @@ class HeatmapView @JvmOverloads constructor(
val baseline = cell / 2f + context.spf(10f) * 0.35f val baseline = cell / 2f + context.spf(10f) * 0.35f
for (row in listOf(0, 2, 4, 6)) { for (row in listOf(0, 2, 4, 6)) {
val y = top + row * (cell + gap) + baseline val y = top + row * (cell + gap) + baseline
canvas.drawText(Dates.weekdayShort(row), labelW - context.dpf(3f), y, textPaint) canvas.drawText(Dates.weekdayShort(row), labelW - context.dpf(8f), y, textPaint)
} }
} }
} }

View File

@@ -254,8 +254,13 @@ class LabelDonutView @JvmOverloads constructor(
tag.slice.name, tagNamePaint, maxW, TextUtils.TruncateAt.END, tag.slice.name, tagNamePaint, maxW, TextUtils.TruncateAt.END,
).toString() ).toString()
canvas.drawText(value, textX, tag.y - context.dpf(3f), tagValuePaint) // 时间与任务名分别落在引线上、下方,两段间隙取同一值(4dp),
canvas.drawText(name, textX, tag.y + context.dpf(13f), tagNamePaint) // 按各自字体的 descent / ascent 反推基线,保证视觉上下对称
val gap = context.dpf(4f)
val vfm = tagValuePaint.fontMetrics
val nfm = tagNamePaint.fontMetrics
canvas.drawText(value, textX, tag.y - gap - vfm.descent, tagValuePaint)
canvas.drawText(name, textX, tag.y + gap - nfm.ascent, tagNamePaint)
} }
/** 环上的百分比文字:底色偏亮时改黑字,否则看不出来 */ /** 环上的百分比文字:底色偏亮时改黑字,否则看不出来 */

View File

@@ -102,6 +102,7 @@
<string name="minutes_value">%1$d 分钟</string> <string name="minutes_value">%1$d 分钟</string>
<string name="repeat">重复</string> <string name="repeat">重复</string>
<string name="repeat_none">不重复</string> <string name="repeat_none">不重复</string>
<string name="repeat_anytime">随时</string>
<string name="repeat_day">天</string> <string name="repeat_day">天</string>
<string name="repeat_week">周</string> <string name="repeat_week">周</string>
<string name="repeat_month">月</string> <string name="repeat_month">月</string>
@@ -208,8 +209,8 @@
<string name="notif_action_resume">继续</string> <string name="notif_action_resume">继续</string>
<string name="notif_action_stop">结束</string> <string name="notif_action_stop">结束</string>
<string name="notif_no_task">未选择任务</string> <string name="notif_no_task">未选择任务</string>
<string name="notif_focus_done">本轮完成</string> <string name="notif_focus_done">任务完成</string>
<string name="notif_focus_done_text">休息一下,%1$d 分钟后继续</string> <string name="notif_focus_done_text">恭喜你,再接再厉,休息下再继续</string>
<string name="notif_break_done">休息结束</string> <string name="notif_break_done">休息结束</string>
<string name="notif_break_done_text">准备好就开始下一轮</string> <string name="notif_break_done_text">准备好就开始下一轮</string>