项目任务行恢复统计口径与完成记录对齐任务页(v3.9)
This commit is contained in:
@@ -555,11 +555,8 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
||||
})
|
||||
}
|
||||
tasks.forEach { t ->
|
||||
val meta = if (t.due > 0) {
|
||||
"${Dates.dueLabel(t.due)}截止"
|
||||
} else {
|
||||
getString(R.string.time_anytime)
|
||||
}
|
||||
// 行内只写任务时间(专注时长),不挂截止/随时、也不标完成或逾期
|
||||
val meta = "${t.focusMinutes}分钟"
|
||||
addRow(
|
||||
title = t.title,
|
||||
meta = meta,
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.focusbox.app.ui.projects
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Paint
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.style.StrikethroughSpan
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -140,20 +143,29 @@ class ProjectAdapter(
|
||||
val btnPlay: ImageView = item.findViewById(R.id.btnTaskPlay)
|
||||
item.findViewById<View>(R.id.taskColorBar).background = ctx.roundBg(p.color, 2f)
|
||||
|
||||
// 顶部是「创建了就一直在」的任务清单:不划线、不变灰;
|
||||
// 完成与否只体现在下面的完成记录里
|
||||
tvTitle.text = task.title
|
||||
tvTitle.setTextColor(ctx.col(if (task.done) R.color.text_tertiary else R.color.text))
|
||||
tvTitle.paintFlags = if (task.done) {
|
||||
tvTitle.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
|
||||
} else {
|
||||
tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||
}
|
||||
tvTitle.setTextColor(ctx.col(R.color.text))
|
||||
tvTitle.paintFlags = tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||
|
||||
// 任务名称下面的时间:只有截止时间(无截止写「随时」),不挂完成与逾期状态
|
||||
tvMeta.text = if (task.due > 0) {
|
||||
"${Dates.dueLabel(task.due)}截止"
|
||||
} else {
|
||||
ctx.getString(R.string.time_anytime)
|
||||
// 任务时间(专注时长)· 最近完成 · 累计次数与累计专注
|
||||
val parts = ArrayList<String>(3)
|
||||
parts.add("${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))
|
||||
}
|
||||
val totals = StringBuilder()
|
||||
if (row.doneCount > 0) {
|
||||
totals.append(ctx.getString(R.string.project_task_done_count, row.doneCount))
|
||||
}
|
||||
if (row.focusSeconds > 0) {
|
||||
// 累计专注只写「数字分钟」,不加说明文案,也不留空格
|
||||
totals.append(row.focusSeconds / 60).append("分钟")
|
||||
}
|
||||
if (totals.isNotEmpty()) parts.add(totals.toString())
|
||||
tvMeta.text = parts.joinToString(" · ")
|
||||
|
||||
btnPlay.visible(!task.done)
|
||||
btnPlay.tint(ctx.col(R.color.brand))
|
||||
@@ -173,19 +185,31 @@ class ProjectAdapter(
|
||||
val btnPlay: ImageView = item.findViewById(R.id.btnTaskPlay)
|
||||
btnPlay.visible(false)
|
||||
|
||||
tvTitle.text = if (record.note.isBlank()) {
|
||||
// 完成记录与任务页底部一致:任务名划线,完成原因跟在后面但不划线
|
||||
val noteText = record.note.replace('\n', ' ')
|
||||
val titleText = if (noteText.isBlank()) {
|
||||
record.taskTitle
|
||||
} else {
|
||||
"${record.taskTitle} · ${record.note.replace('\n', ' ')}"
|
||||
"${record.taskTitle} · $noteText"
|
||||
}
|
||||
val line = SpannableString(titleText)
|
||||
if (record.taskTitle.isNotEmpty()) {
|
||||
line.setSpan(
|
||||
StrikethroughSpan(), 0, record.taskTitle.length,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
|
||||
)
|
||||
}
|
||||
tvTitle.text = line
|
||||
tvTitle.setTextColor(ctx.col(R.color.text_secondary))
|
||||
tvTitle.paintFlags = tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||
|
||||
// 完成记录与任务页同口径:显示完成时刻;有真实专注时长才追加时长
|
||||
val metaText = StringBuilder()
|
||||
metaText.append("${Dates.md(record.endAt)}·${Dates.hm(record.endAt)}完成")
|
||||
if (record.seconds > 0) metaText.append(" · 专注${Dates.duration(record.seconds)}")
|
||||
tvMeta.text = metaText.toString()
|
||||
// 与任务页完成记录同格式:日期 周几 起-止 · 专注X;没有真实时长就只写完成时刻
|
||||
tvMeta.text = if (record.seconds > 0) {
|
||||
"${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)}完成"
|
||||
}
|
||||
item.isClickable = false
|
||||
item.setOnClickListener(null)
|
||||
taskList.addView(item)
|
||||
|
||||
@@ -539,6 +539,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "3.8"
|
||||
const val VERSION = "3.9"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user