任务页筛选头按压态补圆角;专注页选任务项目行照搬项目页统计
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# 变更记录
|
# 变更记录
|
||||||
|
|
||||||
|
## 2026-12-03 · 任务页筛选头按压态补圆角;专注页选任务项目行照搬项目页统计
|
||||||
|
|
||||||
|
- 同步源码更新 8 个文件(新增/修改 7,删除 1)。
|
||||||
|
|
||||||
## 2026-12-03 11:06:38 · 发布 3.4:版本号 3.4 / versionCode 82
|
## 2026-12-03 11:06:38 · 发布 3.4:版本号 3.4 / versionCode 82
|
||||||
|
|
||||||
本次是 v3.3 之后的汇总发布,覆盖内部迭代 3.16~3.25 的全部改动:任务页显示规则重写(一个任务一行、完成即闭环、默认时间今天)、重复任务改成「不重复」不再复活、正计时右侧按钮改「结束」、项目卡新增「新建任务」、复查报告缺陷全量修复(口径统一、生命周期补漏、DB v11 索引、关闭系统备份 + 新增导出数据、类型存储改 JSON)、设置页与统计页文案排版微调。逐条明细见下方各次记录,面向使用者的汇总说明见 Gitea Release 页面。
|
本次是 v3.3 之后的汇总发布,覆盖内部迭代 3.16~3.25 的全部改动:任务页显示规则重写(一个任务一行、完成即闭环、默认时间今天)、重复任务改成「不重复」不再复活、正计时右侧按钮改「结束」、项目卡新增「新建任务」、复查报告缺陷全量修复(口径统一、生命周期补漏、DB v11 索引、关闭系统备份 + 新增导出数据、类型存储改 JSON)、设置页与统计页文案排版微调。逐条明细见下方各次记录,面向使用者的汇总说明见 Gitea Release 页面。
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ import com.focusbox.app.util.Prefs
|
|||||||
import com.focusbox.app.util.circleBg
|
import com.focusbox.app.util.circleBg
|
||||||
import com.focusbox.app.util.col
|
import com.focusbox.app.util.col
|
||||||
import com.focusbox.app.util.dpi
|
import com.focusbox.app.util.dpi
|
||||||
|
import com.focusbox.app.util.projectMetaLine
|
||||||
import com.focusbox.app.util.roundBg
|
import com.focusbox.app.util.roundBg
|
||||||
import com.focusbox.app.util.tint
|
import com.focusbox.app.util.tint
|
||||||
import com.focusbox.app.util.visible
|
import com.focusbox.app.util.visible
|
||||||
@@ -583,7 +584,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
|
|
||||||
fun addRow(
|
fun addRow(
|
||||||
title: String,
|
title: String,
|
||||||
meta: String,
|
meta: CharSequence,
|
||||||
color: Int?,
|
color: Int?,
|
||||||
selected: Boolean,
|
selected: Boolean,
|
||||||
alignLeft: Boolean = false,
|
alignLeft: Boolean = false,
|
||||||
@@ -666,7 +667,8 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
Store.projects().forEach { p ->
|
Store.projects().forEach { p ->
|
||||||
addRow(
|
addRow(
|
||||||
title = p.name,
|
title = p.name,
|
||||||
meta = getString(R.string.pick_project_meta, p.totalTasks),
|
// 与项目页卡片同一套统计:类型 · N个任务 · 已完成M次 · 累计时长
|
||||||
|
meta = ctx.projectMetaLine(p),
|
||||||
color = p.color,
|
color = p.color,
|
||||||
selected = p.id == currentPid,
|
selected = p.id == currentPid,
|
||||||
alignLeft = true, // 项目列表不要左侧色点缩进,名称贴左对齐
|
alignLeft = true, // 项目列表不要左侧色点缩进,名称贴左对齐
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ package com.focusbox.app.ui.projects
|
|||||||
|
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
import android.graphics.Typeface
|
|
||||||
import android.text.Spannable
|
import android.text.Spannable
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.style.ForegroundColorSpan
|
|
||||||
import android.text.style.StrikethroughSpan
|
import android.text.style.StrikethroughSpan
|
||||||
import android.text.style.StyleSpan
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -23,6 +20,7 @@ import com.focusbox.app.model.ProjectTaskStat
|
|||||||
import com.focusbox.app.model.Task
|
import com.focusbox.app.model.Task
|
||||||
import com.focusbox.app.util.Dates
|
import com.focusbox.app.util.Dates
|
||||||
import com.focusbox.app.util.col
|
import com.focusbox.app.util.col
|
||||||
|
import com.focusbox.app.util.projectMetaLine
|
||||||
import com.focusbox.app.util.roundBg
|
import com.focusbox.app.util.roundBg
|
||||||
import com.focusbox.app.util.tint
|
import com.focusbox.app.util.tint
|
||||||
import com.focusbox.app.util.visible
|
import com.focusbox.app.util.visible
|
||||||
@@ -84,35 +82,8 @@ class ProjectAdapter(
|
|||||||
name.text = p.name
|
name.text = p.name
|
||||||
colorBar.background = ctx.roundBg(p.color, 2f)
|
colorBar.background = ctx.roundBg(p.color, 2f)
|
||||||
|
|
||||||
// 项目页统计口径(全周期累计,不是今日,也没有时间上限):
|
// 统计行组装已提取为共享函数(项目页与专注页选任务第一步同一口径),见 Ui.projectMetaLine
|
||||||
// 类型 = 项目新增的类型标签(工作/学习/娱乐/提升或自定义),排在任务数前面,
|
meta.text = ctx.projectMetaLine(p)
|
||||||
// 用项目色加粗,与左侧色条呼应;未设置类型时不占位;
|
|
||||||
// 任务数 = 项目下创建的任务本体(不含重复实例/完成记录副本);
|
|
||||||
// 已完成 = 真实跑完的专注次数(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
|
|
||||||
|
|
||||||
progress.progress = (p.progress * 100).toInt()
|
progress.progress = (p.progress * 100).toInt()
|
||||||
progress.progressTintList = ColorStateList.valueOf(p.color)
|
progress.progressTintList = ColorStateList.valueOf(p.color)
|
||||||
|
|||||||
@@ -780,6 +780,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val VERSION = "3.4"
|
const val VERSION = "3.41"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package com.focusbox.app.util
|
package com.focusbox.app.util
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.graphics.Typeface
|
||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
|
import android.text.Spannable
|
||||||
|
import android.text.SpannableString
|
||||||
|
import android.text.style.ForegroundColorSpan
|
||||||
|
import android.text.style.StyleSpan
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
@@ -9,6 +14,8 @@ import android.widget.TextView
|
|||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.graphics.drawable.DrawableCompat
|
import androidx.core.graphics.drawable.DrawableCompat
|
||||||
|
import com.focusbox.app.R
|
||||||
|
import com.focusbox.app.model.Project
|
||||||
|
|
||||||
fun Context.dpf(v: Float): Float = v * resources.displayMetrics.density
|
fun Context.dpf(v: Float): Float = v * resources.displayMetrics.density
|
||||||
|
|
||||||
@@ -95,3 +102,38 @@ fun View.pad(h: Float, v: Float) {
|
|||||||
fun TextView.setAlphaCompat(a: Float) {
|
fun TextView.setAlphaCompat(a: Float) {
|
||||||
alpha = a
|
alpha = a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目统计行文案,项目页卡片与专注页「选任务」第一步共用,口径必须一致:
|
||||||
|
* 类型(项目色加粗,超 6 字截断) · N个任务 · 已完成M次 · 累计时长
|
||||||
|
*
|
||||||
|
* 统计口径(全周期累计,不是今日,也没有时间上限):
|
||||||
|
* 任务数 = 项目下创建的任务本体(不含重复实例/完成记录副本);
|
||||||
|
* 已完成 = 真实跑完的专注次数(sessions.completed = 1 的条数),
|
||||||
|
* 手动勾选完成、周期滚动时的自动完成都没有专注记录,不计入;
|
||||||
|
* 时长 = 该项目全部专注记录秒数之和,不足 1 分钟不显示。
|
||||||
|
* 未设置类型时不占位。
|
||||||
|
*/
|
||||||
|
fun Context.projectMetaLine(p: Project): CharSequence {
|
||||||
|
// 类型名过长会把后面的「N个任务 / 已完成 / 时长」挤出屏幕(meta 行是单行省略),
|
||||||
|
// 所以先按字符数截断类型名,保证计数始终可见
|
||||||
|
val typeRaw = p.type.trim()
|
||||||
|
val typeText = if (typeRaw.length > 6) typeRaw.take(6) + "…" else typeRaw
|
||||||
|
val parts = ArrayList<String>(4)
|
||||||
|
if (typeText.isNotEmpty()) parts.add(typeText)
|
||||||
|
parts.add(getString(R.string.project_tasks_total, p.totalTasks))
|
||||||
|
if (p.pomodoros > 0) parts.add(getString(R.string.project_tasks_done, p.pomodoros))
|
||||||
|
if (p.focusSeconds >= 60) parts.add(Dates.duration(p.focusSeconds))
|
||||||
|
val line = SpannableString(parts.joinToString(" · "))
|
||||||
|
if (typeText.isNotEmpty()) {
|
||||||
|
line.setSpan(
|
||||||
|
ForegroundColorSpan(p.color), 0, typeText.length,
|
||||||
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
|
||||||
|
)
|
||||||
|
line.setSpan(
|
||||||
|
StyleSpan(Typeface.BOLD), 0, typeText.length,
|
||||||
|
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return line
|
||||||
|
}
|
||||||
|
|||||||
11
src/main/res/drawable/bg_filter_header.xml
Normal file
11
src/main/res/drawable/bg_filter_header.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 筛选卡片头部的按压态:圆角与 bg_card(18dp)一致,
|
||||||
|
否则点击摘要行时水波纹是直角,会盖出卡片圆角以外的区域 -->
|
||||||
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:color="?attr/colorControlHighlight">
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<corners android:radius="18dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
android:paddingEnd="12dp"
|
android:paddingEnd="12dp"
|
||||||
android:paddingTop="10dp"
|
android:paddingTop="10dp"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
android:background="?attr/selectableItemBackground">
|
android:background="@drawable/bg_filter_header">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvFilterSummary"
|
android:id="@+id/tvFilterSummary"
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
<string name="pick_project">选择项目</string>
|
<string name="pick_project">选择项目</string>
|
||||||
<string name="pick_back">返回上一步</string>
|
<string name="pick_back">返回上一步</string>
|
||||||
<string name="pick_step">第 %1$d 步 / 共 2 步</string>
|
<string name="pick_step">第 %1$d 步 / 共 2 步</string>
|
||||||
<string name="pick_project_meta">%1$d个任务</string>
|
|
||||||
<string name="pick_task_empty">这个项目还没有任务,点返回换个项目</string>
|
<string name="pick_task_empty">这个项目还没有任务,点返回换个项目</string>
|
||||||
|
|
||||||
<string name="tasks_title">任务</string>
|
<string name="tasks_title">任务</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user