图标间距减半与逾期任务过滤(v3.3)
This commit is contained in:
@@ -242,7 +242,17 @@ object Store {
|
||||
"_id, title, note, project_id, priority, focus_min, done_pomodoros, due, done, done_at, " +
|
||||
"created_at, sort, repeat_type, repeat_every, origin_id, log_seconds, urgency"
|
||||
|
||||
fun tasks(projectId: Long = 0L, includeDone: Boolean = true): List<Task> {
|
||||
/**
|
||||
* @param includeOverdue 是否包含「已逾期」(有截止日且早于今天零点)的行,
|
||||
* 与任务页的 overdue 判定一致,完成与否都算。任务页传 true(逾期仍要显示,
|
||||
* 且排在「随时」之后);专注页选任务传 false,只留当前可专注的任务。
|
||||
*/
|
||||
fun tasks(
|
||||
projectId: Long = 0L,
|
||||
includeDone: Boolean = true,
|
||||
includeOverdue: Boolean = true,
|
||||
): List<Task> {
|
||||
val todayStart = Dates.todayStart()
|
||||
val where = StringBuilder("1 = 1")
|
||||
val args = ArrayList<String>()
|
||||
if (projectId > 0) {
|
||||
@@ -250,11 +260,13 @@ object Store {
|
||||
args.add(projectId.toString())
|
||||
}
|
||||
if (!includeDone) where.append(" AND done = 0")
|
||||
if (!includeOverdue) {
|
||||
where.append(" AND NOT (due > 0 AND due < $todayStart)")
|
||||
}
|
||||
// 已完成的按完成时间倒序(最近做完的排前面)。未完成分组依次是:
|
||||
// ①「随时」置顶(repeat_type=4)②已逾期(有截止日且早于今天 0 点)
|
||||
// ③普通任务按重要+紧急总分排(各 0低/1中/2高:4=最重要最紧急、3=最重要或
|
||||
// 最紧急、2=中重要中紧急、1=中重要或中紧急、0=低低),同分再按截止日/先后
|
||||
val todayStart = com.focusbox.app.util.Dates.todayStart()
|
||||
val sql = "SELECT $taskColumns FROM tasks WHERE $where " +
|
||||
"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, " +
|
||||
@@ -276,12 +288,15 @@ object Store {
|
||||
* origin_id>0 识别;DB v3 之前的老记录 origin_id 默认为 0,改用「同一次
|
||||
* 专注的 session 起止时刻与该行 created_at/done_at 完全一致」兜底识别,
|
||||
* 否则同一个任务会重复出现 N 行;
|
||||
* - 保留已完成的任务本体(用户要求"只要不删除就一直保留在这里"),
|
||||
* - 排除「已逾期」的行(有截止日且早于今天零点,完成与否都算):周期任务
|
||||
* 跨零点生成的旧实例会沉淀成多条逾期行,只在任务页列出;项目展开不显示,
|
||||
* 避免同一任务重复;
|
||||
* - 保留未逾期、已完成的任务本体(用户要求"只要不删除就一直保留在这里"),
|
||||
* 任务页默认把这类行隐藏,这里不隐藏。
|
||||
*
|
||||
* 完成次数直接取 tasks.done_pomodoros(每次完成的 session 都 +1),
|
||||
* 最近完成时刻取 sessions 里该任务最近一次完成,与次数口径一致。
|
||||
* 排序沿用任务页:未完成在前 → 置顶 → 逾期 → 重要+紧急 → 截止日。
|
||||
* 排序沿用任务页:未完成在前 → 置顶 → 重要+紧急 → 截止日(逾期行已被过滤)。
|
||||
*/
|
||||
fun projectTaskRows(projectId: Long): List<ProjectTaskStat> {
|
||||
val todayStart = Dates.todayStart()
|
||||
@@ -296,6 +311,7 @@ object Store {
|
||||
), 0) AS focus_sec
|
||||
FROM tasks t
|
||||
WHERE t.project_id = ?
|
||||
AND NOT (t.due > 0 AND t.due < $todayStart)
|
||||
AND NOT (
|
||||
t.done = 1 AND t.repeat_type = ${Repeat.NONE} AND (
|
||||
t.origin_id > 0
|
||||
|
||||
@@ -543,7 +543,8 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
||||
btnBack.visibility = View.VISIBLE
|
||||
btnClear.visibility = View.VISIBLE
|
||||
list.removeAllViews()
|
||||
val tasks = Store.tasks(projectId, includeDone = false)
|
||||
// 与项目展开同口径:逾期任务只在任务页出现,选任务列表只列当前可专注的
|
||||
val tasks = Store.tasks(projectId, includeDone = false, includeOverdue = false)
|
||||
if (tasks.isEmpty()) {
|
||||
list.addView(TextView(ctx).apply {
|
||||
text = getString(R.string.pick_task_empty)
|
||||
|
||||
@@ -539,6 +539,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "3.2"
|
||||
const val VERSION = "3.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,15 @@ class TaskAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 标题与图标之间的间距:旧版用三个空格,视觉偏宽。
|
||||
* 改用无字形占位,宽度精确等于三个空格的一半,避免随字体变化忽大忽小。
|
||||
*/
|
||||
private fun appendIconGap(title: SpannableStringBuilder) {
|
||||
title.append(" ")
|
||||
title.setSpan(IconGapSpan(), title.length - 1, title.length, 0)
|
||||
}
|
||||
|
||||
private inner class TaskViewHolder(v: View) : RecyclerView.ViewHolder(v) {
|
||||
private val tvTitle: TextView = v.findViewById(R.id.tvTitle)
|
||||
private val tvMeta: TextView = v.findViewById(R.id.tvMeta)
|
||||
@@ -93,7 +102,7 @@ class TaskAdapter(
|
||||
|
||||
// 置顶图标前移到重要度圆圈之前(品牌蓝圆圈内向上箭头)
|
||||
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
|
||||
title.append(" ")
|
||||
appendIconGap(title)
|
||||
title.setSpan(
|
||||
PinIconSpan(ctx.col(R.color.brand), iconSize),
|
||||
title.length - 1, title.length, 0,
|
||||
@@ -106,8 +115,8 @@ class TaskAdapter(
|
||||
1 -> "2" to R.color.urgent_mid
|
||||
else -> "1" to R.color.urgent_low
|
||||
}
|
||||
// 与标题、与置顶圆圈各留两个可见空格的间距,避免图标贴在一起
|
||||
title.append(" ")
|
||||
// 与标题、与置顶圆圈各留半个旧间距,避免图标贴在一起又不显得散
|
||||
appendIconGap(title)
|
||||
title.setSpan(
|
||||
PriorityBadgeSpan(ctx.col(badgeColor), iconSize, digit),
|
||||
title.length - 1, title.length, 0,
|
||||
@@ -205,6 +214,22 @@ class TaskAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 图标间距占位:宽度等于旧版三个空格的一半,且不绘制任何字形。
|
||||
* 用 ReplacementSpan 而不是固定 dp,间距会随字号等比缩放。
|
||||
*/
|
||||
private class IconGapSpan : android.text.style.ReplacementSpan() {
|
||||
|
||||
override fun getSize(
|
||||
paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?,
|
||||
): Int = (paint.measureText(" ") / 2f).toInt().coerceAtLeast(1)
|
||||
|
||||
override fun draw(
|
||||
canvas: android.graphics.Canvas, text: CharSequence, start: Int, end: Int,
|
||||
x: Float, top: Int, baseline: Int, bottom: Int, paint: Paint,
|
||||
) = Unit
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务名删除线:系统 StrikethroughSpan 的划线位置按"字体半高"(baseline + ascent/2)
|
||||
* 计算,但数字/汉字的实际墨迹顶比字体 ascent 低不少,划线视觉上偏下。
|
||||
|
||||
Reference in New Issue
Block a user