v3.18 按审查报告修缺陷:口径统一、生命周期补漏、读数与百分比修正

- 项目时长/次数改为按任务当前项目统计,与统计页分布一致
- 进度条不再把重复任务跑一轮算成完成
- 清空数据补清 t_task/t_project 等并解绑内存任务
- 进程被杀补记同时写完成记录;结束本轮清空暂存备注
- 通知「结束」先前台化再 stopSelf
- 正计时锁屏读数按需刷新;悬浮窗 addView 失败先 removeView
- 百分比统一 <1%、分布卡加大下界、清空后刷新专注页
- 删除死代码与 41 个未引用字符串,计时状态一次落盘
This commit is contained in:
XIGE
2026-12-02 10:59:52 +08:00
parent 5e882a77ad
commit 9eacf7d87b
21 changed files with 407 additions and 230 deletions

View File

@@ -2,9 +2,12 @@ package com.focusbox.app.ui.projects
import android.content.res.ColorStateList
import android.graphics.Paint
import android.graphics.Typeface
import android.text.Spannable
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import android.text.style.StrikethroughSpan
import android.text.style.StyleSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -82,16 +85,31 @@ class ProjectAdapter(
colorBar.background = ctx.roundBg(p.color, 2f)
// 项目页统计口径(全周期累计,不是今日,也没有时间上限):
// 类型 = 项目新增的类型标签(工作/学习/娱乐/提升或自定义),排在任务数前面,
// 用项目色加粗,与左侧色条呼应;未设置类型时不占位;
// 任务数 = 项目下创建的任务本体(不含重复实例/完成记录副本);
// 已完成 = 真实跑完的专注次数(sessions.completed = 1 的条数),
// 重复任务每完成一轮就 +1,和「累计时长」同源;
// 手动勾选完成、周期滚动时的自动完成都没有专注记录,不计入;
// 时长 = 该项目全部专注记录秒数之和。
val parts = ArrayList<String>(3)
val parts = ArrayList<String>(4)
val typeText = p.type.trim()
if (typeText.isNotEmpty()) parts.add(typeText)
parts.add(ctx.getString(R.string.project_tasks_total, p.totalTasks))
if (p.pomodoros > 0) parts.add(ctx.getString(R.string.project_tasks_done, p.pomodoros))
if (p.focusSeconds >= 60) parts.add(Dates.duration(p.focusSeconds))
meta.text = parts.joinToString(" · ")
val metaLine = SpannableString(parts.joinToString(" · "))
if (typeText.isNotEmpty()) {
metaLine.setSpan(
ForegroundColorSpan(p.color), 0, typeText.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
)
metaLine.setSpan(
StyleSpan(Typeface.BOLD), 0, typeText.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
)
}
meta.text = metaLine
progress.progress = (p.progress * 100).toInt()
progress.progressTintList = ColorStateList.valueOf(p.color)
@@ -156,7 +174,7 @@ class ProjectAdapter(
// 任务时间(专注时长)· 最近完成 · 累计次数与累计专注
val parts = ArrayList<String>(3)
parts.add("${task.focusMinutes}分钟")
parts.add(ctx.getString(R.string.minutes_value, task.focusMinutes))
if (row.lastDoneAt > 0) {
val whenText = "${Dates.md(row.lastDoneAt)}·${Dates.hm(row.lastDoneAt)}"
parts.add(ctx.getString(R.string.project_task_last_done, whenText))
@@ -167,7 +185,7 @@ class ProjectAdapter(
}
if (row.focusSeconds > 0) {
// 累计专注只写「数字分钟」,不加说明文案,也不留空格
totals.append(row.focusSeconds / 60).append("分钟")
totals.append(ctx.getString(R.string.minutes_value, row.focusSeconds / 60))
}
if (totals.isNotEmpty()) parts.add(totals.toString())
tvMeta.text = parts.joinToString(" · ")
@@ -213,10 +231,17 @@ class ProjectAdapter(
// 与任务页完成记录同格式:日期 周几 起-止 · 专注X;没有真实时长就只写完成时刻
tvMeta.text = if (record.seconds > 0) {
"${Dates.dateWithWeek(record.startAt)} ${Dates.hms(record.startAt)}" +
"-${Dates.hms(record.endAt)} · 专注${Dates.duration(record.seconds)}"
ctx.getString(
R.string.done_meta,
"${Dates.dateWithWeek(record.startAt)} ${Dates.hms(record.startAt)}" +
"-${Dates.hms(record.endAt)}",
Dates.duration(record.seconds),
)
} else {
"${Dates.dateWithWeek(record.endAt)} ${Dates.hms(record.endAt)}完成"
ctx.getString(
R.string.done_at_only,
"${Dates.dateWithWeek(record.endAt)} ${Dates.hms(record.endAt)}",
)
}
item.isClickable = false
item.setOnClickListener(null)