任务页筛选头按压态补圆角;专注页选任务项目行照搬项目页统计
This commit is contained in:
@@ -32,6 +32,7 @@ import com.focusbox.app.util.Prefs
|
||||
import com.focusbox.app.util.circleBg
|
||||
import com.focusbox.app.util.col
|
||||
import com.focusbox.app.util.dpi
|
||||
import com.focusbox.app.util.projectMetaLine
|
||||
import com.focusbox.app.util.roundBg
|
||||
import com.focusbox.app.util.tint
|
||||
import com.focusbox.app.util.visible
|
||||
@@ -583,7 +584,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
||||
|
||||
fun addRow(
|
||||
title: String,
|
||||
meta: String,
|
||||
meta: CharSequence,
|
||||
color: Int?,
|
||||
selected: Boolean,
|
||||
alignLeft: Boolean = false,
|
||||
@@ -666,7 +667,8 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
||||
Store.projects().forEach { p ->
|
||||
addRow(
|
||||
title = p.name,
|
||||
meta = getString(R.string.pick_project_meta, p.totalTasks),
|
||||
// 与项目页卡片同一套统计:类型 · N个任务 · 已完成M次 · 累计时长
|
||||
meta = ctx.projectMetaLine(p),
|
||||
color = p.color,
|
||||
selected = p.id == currentPid,
|
||||
alignLeft = true, // 项目列表不要左侧色点缩进,名称贴左对齐
|
||||
|
||||
@@ -2,12 +2,9 @@ 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
|
||||
@@ -23,6 +20,7 @@ import com.focusbox.app.model.ProjectTaskStat
|
||||
import com.focusbox.app.model.Task
|
||||
import com.focusbox.app.util.Dates
|
||||
import com.focusbox.app.util.col
|
||||
import com.focusbox.app.util.projectMetaLine
|
||||
import com.focusbox.app.util.roundBg
|
||||
import com.focusbox.app.util.tint
|
||||
import com.focusbox.app.util.visible
|
||||
@@ -84,35 +82,8 @@ class ProjectAdapter(
|
||||
name.text = p.name
|
||||
colorBar.background = ctx.roundBg(p.color, 2f)
|
||||
|
||||
// 项目页统计口径(全周期累计,不是今日,也没有时间上限):
|
||||
// 类型 = 项目新增的类型标签(工作/学习/娱乐/提升或自定义),排在任务数前面,
|
||||
// 用项目色加粗,与左侧色条呼应;未设置类型时不占位;
|
||||
// 任务数 = 项目下创建的任务本体(不含重复实例/完成记录副本);
|
||||
// 已完成 = 真实跑完的专注次数(sessions.completed = 1 的条数),
|
||||
// 重复任务每完成一轮就 +1,和「累计时长」同源;
|
||||
// 手动勾选完成、周期滚动时的自动完成都没有专注记录,不计入;
|
||||
// 时长 = 该项目全部专注记录秒数之和。
|
||||
val parts = ArrayList<String>(4)
|
||||
// 类型名过长会把后面的「N个任务 / 时长」挤出屏幕(meta 行是单行省略),
|
||||
// 所以先按字符数截断类型名,保证计数始终可见
|
||||
val typeRaw = p.type.trim()
|
||||
val typeText = if (typeRaw.length > 6) typeRaw.take(6) + "…" else typeRaw
|
||||
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))
|
||||
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
|
||||
// 统计行组装已提取为共享函数(项目页与专注页选任务第一步同一口径),见 Ui.projectMetaLine
|
||||
meta.text = ctx.projectMetaLine(p)
|
||||
|
||||
progress.progress = (p.progress * 100).toInt()
|
||||
progress.progressTintList = ColorStateList.valueOf(p.color)
|
||||
|
||||
@@ -780,6 +780,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "3.4"
|
||||
const val VERSION = "3.41"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user