Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a7147b299 | ||
|
|
47294f4fcf | ||
|
|
8ad5441ba4 | ||
|
|
9c8e2eb534 | ||
|
|
eb3d961b0a | ||
|
|
9fdecfb1b9 | ||
|
|
a8446bcf51 | ||
|
|
54df5b398c |
31
CHANGELOG.md
31
CHANGELOG.md
@@ -1,5 +1,36 @@
|
|||||||
# 变更记录
|
# 变更记录
|
||||||
|
|
||||||
|
## 2026-12-01 · 统计补全、任务行编辑弹窗、图标对齐与完成记录折叠(v3.1)
|
||||||
|
|
||||||
|
- 项目展开行统计:在「累计 N 次」后空一格追加累计专注分钟数,只写「数字 分钟」,不加说明文案。
|
||||||
|
- 项目展开行点击复用任务页同款 `TaskSheet`,可直接编辑或删除该任务,保存/删除后刷新项目页。
|
||||||
|
- 任务列表置顶图标前移到重要度圆圈之前;重要度圆圈改为自绘圆环+数字,与置顶圆圈共用同一绘制函数(0.85 倍字号、s/10 描边),两者粗细与高度严格一致。
|
||||||
|
- 项目展开区已完成任务默认折叠,在已完成记录前新增「展开完成记录(N)/ 收起完成记录(N)」开关,避免历史记录越积越长。
|
||||||
|
- 数据层与任务页逻辑不变;versionCode 55 / versionName 3.1,签名不变。
|
||||||
|
|
||||||
|
## 2026-12-01 · 项目列表点击就地展开任务与统计(v3.0)
|
||||||
|
|
||||||
|
- 项目列表点击项目不再跳转任务页,改为就地展开该项目下的任务列表;只展开一个项目,再次点击收起。
|
||||||
|
- 口径:项目下添加过的任务只要没删除都保留(含已完成);排除每次专注生成的完成记录副本(否则一个任务重复 N 行)。
|
||||||
|
- 展开行参考任务列表但不显示分类(项目名),meta 为「单轮时长 · 最近完成时间 · 累计完成次数」;右侧保留开始按钮。
|
||||||
|
- 新增只读查询 Store.projectTaskRows + ProjectTaskStat 模型;累计次数取 done_pomodoros,最近完成取 sessions 中 completed=1 的最近 end_at,口径一致;排序沿用任务页。
|
||||||
|
- **任务页零改动**:TasksFragment / TaskAdapter / fragment_tasks / item_task / MainActivity 与 v2.9 逐字节一致,现有逻辑不变。
|
||||||
|
- versionCode 54 / versionName 3.0,签名不变(7bcbd511…cc8c83),覆盖安装,无数据迁移。
|
||||||
|
|
||||||
|
## 2026-11-30 · 回退字体改动,删除横屏分割线(v2.9)
|
||||||
|
|
||||||
|
- v2.8 打包字体在鸿蒙锁屏/悬浮窗上渲染异常(时间乱铺),按用户要求回退并移除分割线。
|
||||||
|
- layout-land 从 v2.3 提交恢复后仅删除中列(锚点+分割线+占位),删除 res/font;其余代码与 v2.3 一致。
|
||||||
|
- 最终形态:横屏左右两栏各半、时间居中、无分割线;竖屏不变。
|
||||||
|
- versionCode 53 / versionName 2.9,签名不变(7bcbd511…cc8c83),覆盖安装,无数据迁移。
|
||||||
|
|
||||||
|
## 2026-11-30 · 横屏大时间换用 Source Code Pro Bold,修分割线左右间隙不等(v2.8)
|
||||||
|
|
||||||
|
- 诊断(基于用户 4 张锁屏照片的程序实测):右间距恒 36px、左间距 20~27px 随秒数变化;数字 advance 等宽(≈95px)但"1"墨迹仅 65px → 系统字体墨迹边距不均;分割线在 advance 中点,布局本身对称无问题。间隙差来自字形墨迹:右钟以"0"开头(墨迹内缩)、左倒计时以 7/3/4/8 结尾(墨迹顶边)。
|
||||||
|
- 选型(渲染位图实测各候选字体的墨迹间隙差):Source Code Pro Bold 最优(最坏 4.9dp vs 现状 ~15dp),其"1"带衬线脚、墨迹近满宽、各数字边距最均匀。
|
||||||
|
- 改动(纯静态 XML):新增 res/font/sourcecodepro_bold.ttf;layout-land 仅给 3 个 130sp 文本(左右时间+中列锚点)加 fontFamily,其余与 v2.3 逐行一致。竖屏与 Kotlin 代码零改动。
|
||||||
|
- 版本:versionCode 52 / versionName 2.8,签名不变(7bcbd511…cc8c83),覆盖安装,无数据迁移。数字字形略有变化("1"多一个衬线脚,类翻页钟样式),字号 130sp 不变。
|
||||||
|
|
||||||
## 2026-11-30 · 删除 CountdownFit,竖屏恢复 v2.3 行为(v2.7)
|
## 2026-11-30 · 删除 CountdownFit,竖屏恢复 v2.3 行为(v2.7)
|
||||||
|
|
||||||
- 起因:用户报告竖屏专注时间变小(回归)。v2.6 的 CountdownFit 等宽缩号在锁屏页与悬浮窗两条链路都接入,竖屏被波及——该工具只要倒计时文字比时钟宽几像素(鸿蒙字体数字非严格等宽时必然发生)就缩小倒计时,前提错误。
|
- 起因:用户报告竖屏专注时间变小(回归)。v2.6 的 CountdownFit 等宽缩号在锁屏页与悬浮窗两条链路都接入,竖屏被波及——该工具只要倒计时文字比时钟宽几像素(鸿蒙字体数字非严格等宽时必然发生)就缩小倒计时,前提错误。
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import android.database.sqlite.SQLiteOpenHelper
|
|||||||
import com.focusbox.app.model.DayPoint
|
import com.focusbox.app.model.DayPoint
|
||||||
import com.focusbox.app.model.Project
|
import com.focusbox.app.model.Project
|
||||||
import com.focusbox.app.model.ProjectSlice
|
import com.focusbox.app.model.ProjectSlice
|
||||||
|
import com.focusbox.app.model.ProjectTaskStat
|
||||||
import com.focusbox.app.model.Repeat
|
import com.focusbox.app.model.Repeat
|
||||||
import com.focusbox.app.model.SessionSpan
|
import com.focusbox.app.model.SessionSpan
|
||||||
import com.focusbox.app.model.Task
|
import com.focusbox.app.model.Task
|
||||||
@@ -267,6 +268,56 @@ object Store {
|
|||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目卡展开用:该项目下"添加过的任务 + 统计"。
|
||||||
|
*
|
||||||
|
* 与任务页的唯一差别在筛选口径:
|
||||||
|
* - 排除每次专注生成的完成记录副本(done=1 且 repeat_type=0 且 origin_id>0),
|
||||||
|
* 它们是历史流水而非用户添加的任务,否则同一个任务会重复出现 N 行;
|
||||||
|
* - 保留已完成的任务本体(用户要求"只要不删除就一直保留在这里"),
|
||||||
|
* 任务页默认把这类行隐藏,这里不隐藏。
|
||||||
|
*
|
||||||
|
* 完成次数直接取 tasks.done_pomodoros(每次完成的 session 都 +1),
|
||||||
|
* 最近完成时刻取 sessions 里该任务最近一次完成,与次数口径一致。
|
||||||
|
* 排序沿用任务页:未完成在前 → 置顶 → 逾期 → 重要+紧急 → 截止日。
|
||||||
|
*/
|
||||||
|
fun projectTaskRows(projectId: Long): List<ProjectTaskStat> {
|
||||||
|
val todayStart = Dates.todayStart()
|
||||||
|
val sql = """
|
||||||
|
SELECT $taskColumns,
|
||||||
|
COALESCE((
|
||||||
|
SELECT MAX(s.end_at) FROM sessions s
|
||||||
|
WHERE s.task_id = t._id AND s.completed = 1
|
||||||
|
), 0) AS last_done,
|
||||||
|
COALESCE((
|
||||||
|
SELECT SUM(s.seconds) FROM sessions s WHERE s.task_id = t._id
|
||||||
|
), 0) AS focus_sec
|
||||||
|
FROM tasks t
|
||||||
|
WHERE t.project_id = ?
|
||||||
|
AND NOT (t.done = 1 AND t.repeat_type = ${Repeat.NONE} AND t.origin_id > 0)
|
||||||
|
ORDER BY t.done ASC,
|
||||||
|
CASE WHEN t.done = 1 THEN t.done_at ELSE 0 END DESC,
|
||||||
|
CASE WHEN t.done = 0 AND t.repeat_type = ${Repeat.ANYTIME} THEN 0 ELSE 1 END ASC,
|
||||||
|
CASE WHEN t.done = 0 AND t.due > 0 AND t.due < $todayStart THEN 0 ELSE 1 END ASC,
|
||||||
|
CASE WHEN t.done = 0 THEN t.priority + t.urgency ELSE 0 END DESC,
|
||||||
|
CASE WHEN t.due = 0 THEN 1 ELSE 0 END ASC, t.due ASC, t._id DESC
|
||||||
|
""".trimIndent()
|
||||||
|
val list = ArrayList<ProjectTaskStat>()
|
||||||
|
db.rawQuery(sql, arrayOf(projectId.toString())).use { c ->
|
||||||
|
while (c.moveToNext()) {
|
||||||
|
list.add(
|
||||||
|
ProjectTaskStat(
|
||||||
|
task = cursorToTask(c),
|
||||||
|
lastDoneAt = c.getLong(17),
|
||||||
|
doneCount = c.getInt(6),
|
||||||
|
focusSeconds = c.getInt(18),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
fun task(id: Long): Task? {
|
fun task(id: Long): Task? {
|
||||||
db.rawQuery("SELECT $taskColumns FROM tasks WHERE _id = ?", arrayOf(id.toString())).use { c ->
|
db.rawQuery("SELECT $taskColumns FROM tasks WHERE _id = ?", arrayOf(id.toString())).use { c ->
|
||||||
return if (c.moveToFirst()) cursorToTask(c) else null
|
return if (c.moveToFirst()) cursorToTask(c) else null
|
||||||
|
|||||||
@@ -62,6 +62,20 @@ data class Task(
|
|||||||
/** 一条专注记录的起止时刻与实际秒数,用于在已完成任务上显示真实工作时段。 */
|
/** 一条专注记录的起止时刻与实际秒数,用于在已完成任务上显示真实工作时段。 */
|
||||||
data class SessionSpan(val startAt: Long, val endAt: Long, val seconds: Int = 0)
|
data class SessionSpan(val startAt: Long, val endAt: Long, val seconds: Int = 0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目卡展开后的一条任务行:任务本体 + 三项统计。
|
||||||
|
* 仅用于项目页展开列表,任务页的 Task 口径不变。
|
||||||
|
*/
|
||||||
|
data class ProjectTaskStat(
|
||||||
|
val task: Task,
|
||||||
|
/** 最近一次完成时刻(源任务 done_at 与该任务 sessions 最近 end_at 取大),0 表示未完成过 */
|
||||||
|
val lastDoneAt: Long,
|
||||||
|
/** 累计完成次数(sessions 里 completed=1 的条数) */
|
||||||
|
val doneCount: Int,
|
||||||
|
/** 累计专注秒数(sessions 里该任务的 seconds 之和) */
|
||||||
|
val focusSeconds: Int,
|
||||||
|
)
|
||||||
|
|
||||||
/** 提前完成时交给 UI 落备注的实际专注信息 */
|
/** 提前完成时交给 UI 落备注的实际专注信息 */
|
||||||
data class FocusFinish(
|
data class FocusFinish(
|
||||||
val taskId: Long,
|
val taskId: Long,
|
||||||
|
|||||||
@@ -1,30 +1,54 @@
|
|||||||
package com.focusbox.app.ui.projects
|
package com.focusbox.app.ui.projects
|
||||||
|
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
|
import android.graphics.Paint
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import android.widget.LinearLayout
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.focusbox.app.R
|
import com.focusbox.app.R
|
||||||
import com.focusbox.app.model.Project
|
import com.focusbox.app.model.Project
|
||||||
|
import com.focusbox.app.model.ProjectTaskStat
|
||||||
|
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.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
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目列表:点击项目头就地展开该项目下的任务,不再跳转任务页。
|
||||||
|
* 展开行显示统计、右侧保留开始按钮;点击行复用任务页同款编辑/删除弹窗。
|
||||||
|
* 已完成任务默认折叠,用「展开/收起完成记录」开关控制,避免历史越积越长。
|
||||||
|
*/
|
||||||
class ProjectAdapter(
|
class ProjectAdapter(
|
||||||
private val onClick: (Project) -> Unit,
|
private val onToggleExpand: (Project) -> Unit,
|
||||||
private val onLongClick: (Project) -> Unit,
|
private val onLongClick: (Project) -> Unit,
|
||||||
private val onMore: (Project) -> Unit,
|
private val onMore: (Project) -> Unit,
|
||||||
|
private val onStart: (Task) -> Unit,
|
||||||
|
private val onEdit: (Task) -> Unit,
|
||||||
|
private val onToggleDone: () -> Unit,
|
||||||
) : RecyclerView.Adapter<ProjectAdapter.VH>() {
|
) : RecyclerView.Adapter<ProjectAdapter.VH>() {
|
||||||
|
|
||||||
private var items: List<Project> = emptyList()
|
private var items: List<Project> = emptyList()
|
||||||
|
private var expandedId: Long = -1L
|
||||||
|
private var stats: Map<Long, List<ProjectTaskStat>> = emptyMap()
|
||||||
|
private var showDone: Boolean = false
|
||||||
|
|
||||||
fun submit(list: List<Project>) {
|
fun submit(
|
||||||
|
list: List<Project>,
|
||||||
|
expanded: Long,
|
||||||
|
taskStats: Map<Long, List<ProjectTaskStat>>,
|
||||||
|
showDoneRows: Boolean,
|
||||||
|
) {
|
||||||
items = list
|
items = list
|
||||||
|
expandedId = expanded
|
||||||
|
stats = taskStats
|
||||||
|
showDone = showDoneRows
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,13 +65,16 @@ class ProjectAdapter(
|
|||||||
private val progress: ProgressBar = v.findViewById(R.id.progress)
|
private val progress: ProgressBar = v.findViewById(R.id.progress)
|
||||||
private val colorBar: View = v.findViewById(R.id.colorBar)
|
private val colorBar: View = v.findViewById(R.id.colorBar)
|
||||||
private val more: ImageView = v.findViewById(R.id.btnMore)
|
private val more: ImageView = v.findViewById(R.id.btnMore)
|
||||||
|
private val header: View = v.findViewById(R.id.projectHeader)
|
||||||
|
private val taskList: LinearLayout = v.findViewById(R.id.taskList)
|
||||||
|
private val tvTaskEmpty: TextView = v.findViewById(R.id.tvTaskEmpty)
|
||||||
|
|
||||||
fun bind(p: Project) {
|
fun bind(p: Project) {
|
||||||
val ctx = itemView.context
|
val ctx = itemView.context
|
||||||
name.text = p.name
|
name.text = p.name
|
||||||
colorBar.background = ctx.roundBg(p.color, 2f)
|
colorBar.background = ctx.roundBg(p.color, 2f)
|
||||||
|
|
||||||
// 只看任务与时长,不再显示番茄数
|
// 只看任务与时长,不再显示番茄数(与改动前一致)
|
||||||
val parts = ArrayList<String>(3)
|
val parts = ArrayList<String>(3)
|
||||||
parts.add("${p.openTasks} 待办")
|
parts.add("${p.openTasks} 待办")
|
||||||
if (p.doneTasks > 0) parts.add("${p.doneTasks} 已完成")
|
if (p.doneTasks > 0) parts.add("${p.doneTasks} 已完成")
|
||||||
@@ -61,11 +88,86 @@ class ProjectAdapter(
|
|||||||
more.tint(ctx.col(R.color.text_tertiary))
|
more.tint(ctx.col(R.color.text_tertiary))
|
||||||
more.setOnClickListener { onMore(p) }
|
more.setOnClickListener { onMore(p) }
|
||||||
|
|
||||||
itemView.setOnClickListener { onClick(p) }
|
header.setOnClickListener { onToggleExpand(p) }
|
||||||
itemView.setOnLongClickListener {
|
header.setOnLongClickListener {
|
||||||
onLongClick(p)
|
onLongClick(p)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val expanded = expandedId == p.id
|
||||||
|
val rows = if (expanded) stats[p.id].orEmpty() else emptyList()
|
||||||
|
val openRows = rows.filter { !it.task.done }
|
||||||
|
val doneRows = rows.filter { it.task.done }
|
||||||
|
taskList.visible(expanded && rows.isNotEmpty())
|
||||||
|
tvTaskEmpty.visible(expanded && rows.isEmpty())
|
||||||
|
if (!expanded) return
|
||||||
|
|
||||||
|
fun addTaskRow(row: ProjectTaskStat) {
|
||||||
|
val item = LayoutInflater.from(ctx)
|
||||||
|
.inflate(R.layout.item_project_task, taskList, false)
|
||||||
|
bindTaskRow(item, row, p)
|
||||||
|
taskList.addView(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
taskList.removeAllViews()
|
||||||
|
openRows.forEach { addTaskRow(it) }
|
||||||
|
|
||||||
|
// 已完成任务默认折叠:开关行永远紧贴在已完成记录之前
|
||||||
|
if (doneRows.isNotEmpty()) {
|
||||||
|
val toggle = LayoutInflater.from(ctx)
|
||||||
|
.inflate(R.layout.item_footer, taskList, false)
|
||||||
|
val tv = toggle.findViewById<TextView>(R.id.tvFooter)
|
||||||
|
tv.text = ctx.getString(
|
||||||
|
if (showDone) R.string.project_collapse_done else R.string.project_expand_done,
|
||||||
|
doneRows.size,
|
||||||
|
)
|
||||||
|
tv.setTextColor(ctx.col(R.color.brand))
|
||||||
|
toggle.setOnClickListener { onToggleDone() }
|
||||||
|
taskList.addView(toggle)
|
||||||
|
if (showDone) doneRows.forEach { addTaskRow(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun bindTaskRow(item: View, row: ProjectTaskStat, p: Project) {
|
||||||
|
val ctx = item.context
|
||||||
|
val task = row.task
|
||||||
|
val tvTitle: TextView = item.findViewById(R.id.tvTaskTitle)
|
||||||
|
val tvMeta: TextView = item.findViewById(R.id.tvTaskMeta)
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 统计:单轮时长 · 最近完成时间 · 累计次数+累计专注分钟;不显示分类(项目名)
|
||||||
|
val parts = ArrayList<String>(3)
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
val totals = StringBuilder()
|
||||||
|
if (row.doneCount > 0) {
|
||||||
|
totals.append(ctx.getString(R.string.project_task_done_count, row.doneCount))
|
||||||
|
}
|
||||||
|
if (row.focusSeconds > 0) {
|
||||||
|
// 累计专注只写「数字 分钟」,不加任何说明文案;紧跟在累计次数后一个空格
|
||||||
|
if (totals.isNotEmpty()) totals.append(' ')
|
||||||
|
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))
|
||||||
|
btnPlay.setOnClickListener { onStart(task) }
|
||||||
|
// 与任务页一致:点行打开编辑/删除弹窗
|
||||||
|
item.setOnClickListener { onEdit(task) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.focusbox.app.R
|
import com.focusbox.app.R
|
||||||
import com.focusbox.app.data.Store
|
import com.focusbox.app.data.Store
|
||||||
import com.focusbox.app.model.Project
|
import com.focusbox.app.model.Project
|
||||||
|
import com.focusbox.app.model.ProjectTaskStat
|
||||||
|
import com.focusbox.app.model.Task
|
||||||
import com.focusbox.app.ui.MainActivity
|
import com.focusbox.app.ui.MainActivity
|
||||||
import com.focusbox.app.ui.SheetDialog
|
import com.focusbox.app.ui.SheetDialog
|
||||||
|
import com.focusbox.app.ui.tasks.TaskSheet
|
||||||
import com.focusbox.app.util.col
|
import com.focusbox.app.util.col
|
||||||
import com.focusbox.app.util.visible
|
import com.focusbox.app.util.visible
|
||||||
|
|
||||||
@@ -25,6 +28,12 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
|
|||||||
|
|
||||||
private var showArchived = false
|
private var showArchived = false
|
||||||
|
|
||||||
|
/** 当前展开的项目 id;-1 表示全部收起。只展开一个,避免列表过长 */
|
||||||
|
private var expandedProjectId = -1L
|
||||||
|
private var taskStats: Map<Long, List<ProjectTaskStat>> = emptyMap()
|
||||||
|
/** 展开区内已完成记录默认折叠,避免历史记录越积越长 */
|
||||||
|
private var showDoneInProject = false
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
recycler = view.findViewById(R.id.recycler)
|
recycler = view.findViewById(R.id.recycler)
|
||||||
@@ -33,9 +42,18 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
|
|||||||
btnArchived = view.findViewById(R.id.btnArchived)
|
btnArchived = view.findViewById(R.id.btnArchived)
|
||||||
|
|
||||||
adapter = ProjectAdapter(
|
adapter = ProjectAdapter(
|
||||||
onClick = { p -> (activity as? MainActivity)?.openProjectTasks(p.id) },
|
onToggleExpand = { p ->
|
||||||
|
expandedProjectId = if (expandedProjectId == p.id) -1L else p.id
|
||||||
|
reload()
|
||||||
|
},
|
||||||
onLongClick = { p -> showActions(p) },
|
onLongClick = { p -> showActions(p) },
|
||||||
onMore = { p -> showActions(p) },
|
onMore = { p -> showActions(p) },
|
||||||
|
onStart = { t -> (activity as? MainActivity)?.startFocusOn(t) },
|
||||||
|
onEdit = { t -> TaskSheet(requireContext(), t, 0L) { reload() }.show() },
|
||||||
|
onToggleDone = {
|
||||||
|
showDoneInProject = !showDoneInProject
|
||||||
|
reload()
|
||||||
|
},
|
||||||
)
|
)
|
||||||
recycler.layoutManager = LinearLayoutManager(requireContext())
|
recycler.layoutManager = LinearLayoutManager(requireContext())
|
||||||
recycler.adapter = adapter
|
recycler.adapter = adapter
|
||||||
@@ -68,7 +86,12 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
|
|||||||
val archived = all.filter { it.archived }
|
val archived = all.filter { it.archived }
|
||||||
|
|
||||||
val shown = if (showArchived) all else active
|
val shown = if (showArchived) all else active
|
||||||
adapter.submit(shown)
|
// 展开态只在可见项目上加载统计;项目被删/归档后自动收起,不留悬空 id
|
||||||
|
if (expandedProjectId != -1L && shown.none { it.id == expandedProjectId }) {
|
||||||
|
expandedProjectId = -1L
|
||||||
|
}
|
||||||
|
taskStats = shown.associate { it.id to Store.projectTaskRows(it.id) }
|
||||||
|
adapter.submit(shown, expandedProjectId, taskStats, showDoneInProject)
|
||||||
|
|
||||||
tvSummary.text = getString(
|
tvSummary.text = getString(
|
||||||
R.string.project_summary, active.size, active.sumOf { it.openTasks }
|
R.string.project_summary, active.size, active.sumOf { it.openTasks }
|
||||||
|
|||||||
@@ -539,6 +539,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val VERSION = "2.7"
|
const val VERSION = "3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,23 +85,32 @@ class TaskAdapter(
|
|||||||
val ctx = itemView.context
|
val ctx = itemView.context
|
||||||
|
|
||||||
// 标题右侧的属性图标,未完成与已完成都显示:
|
// 标题右侧的属性图标,未完成与已完成都显示:
|
||||||
// 重要度圆圈数字(③ 高 / ② 中 / ① 普通,颜色与紧急度同色系)→
|
// 置顶圆圈箭头(「随时」未完成任务)→ 重要度圆圈数字 → 紧急度五角星。
|
||||||
// 紧急度五角星 → 随时上箭头。
|
// 置顶与重要度两个圆圈统一自绘:同一尺寸(0.85 倍字号)、同一描边(s/10),
|
||||||
// 各字形在字体里的字面尺寸不同:以圆圈数字 0.85 为基准,
|
// 保证粗细与高度完全一致;五角星仍用字形,0.95 倍不作参照。
|
||||||
// 上箭头与圆圈同高;五角星 0.95 不作参照
|
|
||||||
val title = SpannableStringBuilder(task.title)
|
val title = SpannableStringBuilder(task.title)
|
||||||
|
val iconSize = tvTitle.textSize * 0.85f
|
||||||
|
|
||||||
val (badge, badgeColor) = when (task.priority) {
|
// 置顶图标前移到重要度圆圈之前(品牌蓝圆圈内向上箭头)
|
||||||
2 -> " ③" to R.color.urgent_high
|
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
|
||||||
1 -> " ②" to R.color.urgent_mid
|
title.append("\u2009")
|
||||||
else -> " ①" to R.color.urgent_low
|
|
||||||
}
|
|
||||||
title.append(badge)
|
|
||||||
title.setSpan(
|
title.setSpan(
|
||||||
android.text.style.ForegroundColorSpan(ctx.col(badgeColor)),
|
PinIconSpan(ctx.col(R.color.brand), iconSize),
|
||||||
title.length - badge.length, title.length, 0
|
title.length - 1, title.length, 0,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重要度圆圈:3 高 / 2 中 / 1 普通,颜色与紧急度同色系
|
||||||
|
val (digit, badgeColor) = when (task.priority) {
|
||||||
|
2 -> "3" to R.color.urgent_high
|
||||||
|
1 -> "2" to R.color.urgent_mid
|
||||||
|
else -> "1" to R.color.urgent_low
|
||||||
|
}
|
||||||
|
title.append(" ")
|
||||||
|
title.setSpan(
|
||||||
|
PriorityBadgeSpan(ctx.col(badgeColor), iconSize, digit),
|
||||||
|
title.length - 1, title.length, 0,
|
||||||
)
|
)
|
||||||
title.setSpan(RelativeSizeSpan(0.85f), title.length - badge.length, title.length, 0)
|
|
||||||
|
|
||||||
// 紧急度五角星:紧急三颗红 / 中两颗绿 / 不急一颗灰
|
// 紧急度五角星:紧急三颗红 / 中两颗绿 / 不急一颗灰
|
||||||
val (stars, starColor) = when (task.urgency) {
|
val (stars, starColor) = when (task.urgency) {
|
||||||
@@ -116,17 +125,6 @@ class TaskAdapter(
|
|||||||
)
|
)
|
||||||
title.setSpan(RelativeSizeSpan(0.95f), title.length - stars.length, title.length, 0)
|
title.setSpan(RelativeSizeSpan(0.95f), title.length - stars.length, title.length, 0)
|
||||||
|
|
||||||
// 「随时」任务:标题后带品牌蓝圆圈上箭头表示置顶,列表里排在未完成最前面。
|
|
||||||
// 图标与重要度圆圈数字同规格(0.85 倍字号,圆圈里画向上箭头),
|
|
||||||
// 圆圈与箭头同色(品牌蓝);前面的细空格(U+2009)保持与星标的间距一致。
|
|
||||||
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
|
|
||||||
title.append("\u2009 ")
|
|
||||||
title.setSpan(
|
|
||||||
PinIconSpan(ctx.col(R.color.brand), tvTitle.textSize * 0.85f),
|
|
||||||
title.length - 1, title.length, 0,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 完成横线只画任务名本身(MidStrikeSpan 限定区间,且划线取文字墨迹
|
// 完成横线只画任务名本身(MidStrikeSpan 限定区间,且划线取文字墨迹
|
||||||
// 的垂直中点——系统 StrikethroughSpan 用整字面半高定位,数字/汉字
|
// 的垂直中点——系统 StrikethroughSpan 用整字面半高定位,数字/汉字
|
||||||
// 会让线显得偏下)。重要度/紧急度/置顶图标不跟着划线。
|
// 会让线显得偏下)。重要度/紧急度/置顶图标不跟着划线。
|
||||||
@@ -236,6 +234,61 @@ private class MidStrikeSpan : android.text.style.ReplacementSpan() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 置顶与重要度共用的圆环绘制:同尺寸、同描边(s/10),保证两个圆圈粗细一致。 */
|
||||||
|
private fun drawBadgeRing(
|
||||||
|
canvas: android.graphics.Canvas, cx: Float, cy: Float, size: Float, ringColor: Int,
|
||||||
|
) {
|
||||||
|
val ring = android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
|
this.color = ringColor
|
||||||
|
style = android.graphics.Paint.Style.STROKE
|
||||||
|
strokeWidth = size / 10f
|
||||||
|
strokeCap = android.graphics.Paint.Cap.ROUND
|
||||||
|
}
|
||||||
|
canvas.drawCircle(cx, cy, size / 2f - ring.strokeWidth / 2f, ring)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重要度圆圈数字:自绘圆环 + 数字,与置顶圆圈共用 drawBadgeRing,
|
||||||
|
* 高度(0.85 倍字号)与描边(s/10)严格一致,不再依赖系统字形 ①②③ 的墨迹差异。
|
||||||
|
*/
|
||||||
|
private class PriorityBadgeSpan(
|
||||||
|
private val badgeColor: Int,
|
||||||
|
private val size: Float,
|
||||||
|
private val digit: String,
|
||||||
|
) : android.text.style.ReplacementSpan() {
|
||||||
|
|
||||||
|
override fun getSize(
|
||||||
|
paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?,
|
||||||
|
): Int {
|
||||||
|
val s = size.toInt()
|
||||||
|
if (fm != null) {
|
||||||
|
fm.ascent = -s
|
||||||
|
fm.descent = 0
|
||||||
|
fm.top = fm.ascent
|
||||||
|
fm.bottom = fm.descent
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun draw(
|
||||||
|
canvas: android.graphics.Canvas, text: CharSequence, start: Int, end: Int,
|
||||||
|
x: Float, top: Int, baseline: Int, bottom: Int, paint: Paint,
|
||||||
|
) {
|
||||||
|
val s = size
|
||||||
|
val cy = baseline - s * 0.45f
|
||||||
|
val cx = x + s / 2f
|
||||||
|
drawBadgeRing(canvas, cx, cy, s, badgeColor)
|
||||||
|
val num = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
|
this.color = badgeColor
|
||||||
|
textSize = s * 0.60f
|
||||||
|
typeface = Typeface.DEFAULT
|
||||||
|
textAlign = Paint.Align.CENTER
|
||||||
|
}
|
||||||
|
val fm = num.fontMetrics
|
||||||
|
canvas.drawText(digit, cx, cy - (fm.ascent + fm.descent) / 2f, num)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 置顶图标:圆圈内向上箭头。
|
* 置顶图标:圆圈内向上箭头。
|
||||||
* 自绘而不是用字体字形——常用字体里没有"圆圈+箭头"的组合字符,
|
* 自绘而不是用字体字形——常用字体里没有"圆圈+箭头"的组合字符,
|
||||||
@@ -270,13 +323,8 @@ private class PinIconSpan(
|
|||||||
// 圆心取基线上方 0.45 个图标高,比之前 0.50 略下移,底部不再"悬空"显偏上
|
// 圆心取基线上方 0.45 个图标高,比之前 0.50 略下移,底部不再"悬空"显偏上
|
||||||
val cx = x + s / 2f
|
val cx = x + s / 2f
|
||||||
val cy = baseline - s * 0.45f
|
val cy = baseline - s * 0.45f
|
||||||
// 圈线与重要度圆圈数字的描边粗细一致(约 1/10 图标高)
|
// 与重要度圆圈共用同一绘制函数:同尺寸、同 1/10 描边,粗细与高度严格一致
|
||||||
val ring = Paint(Paint.ANTI_ALIAS_FLAG)
|
drawBadgeRing(canvas, cx, cy, s, iconColor)
|
||||||
ring.color = iconColor
|
|
||||||
ring.style = Paint.Style.STROKE
|
|
||||||
ring.strokeWidth = s / 10f
|
|
||||||
ring.strokeCap = Paint.Cap.ROUND
|
|
||||||
canvas.drawCircle(cx, cy, s / 2f - ring.strokeWidth / 2f, ring)
|
|
||||||
|
|
||||||
// 箭头比圈线更细(约 1/15 图标高),整体落在圆内
|
// 箭头比圈线更细(约 1/15 图标高),整体落在圆内
|
||||||
val arrow = Paint(Paint.ANTI_ALIAS_FLAG)
|
val arrow = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
|||||||
@@ -56,49 +56,7 @@
|
|||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 中:细分隔线(92dp≈130sp 粗体数字的字面高度 0.71em×130,与时间视觉等高)
|
<!-- 中列分割线已按用户要求移除(v2.9):左右两栏各占一半宽度,文字各自居中 -->
|
||||||
v2.3 中列完整镜像左右两栏:上方 1dp FrameLayout 内放与时间同规格的 130sp
|
|
||||||
不可见锚点文字(maxLines=1,防止 1dp 宽度触发折行撑高),分割线在其中
|
|
||||||
center;下方补一段与侧栏小字同规格(15sp、marginTop 10dp)的不可见占位,
|
|
||||||
使中列总高与左右两栏一致。三列同高且都被 center_vertical 居中 → 同顶,
|
|
||||||
锚点中心严格等于时间文字中心。(v2.2 只放了锚点没补占位,中列比侧栏矮
|
|
||||||
一截,居中后中心仍落在屏幕中心,与旧版位置相同,故无效) -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="1dp"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:includeFontPadding="false"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:visibility="invisible"
|
|
||||||
android:text="00:00"
|
|
||||||
android:textSize="130sp"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/lockDivider"
|
|
||||||
android:layout_width="1dp"
|
|
||||||
android:layout_height="92dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="#26FFFFFF" />
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:visibility="invisible"
|
|
||||||
android:text="0"
|
|
||||||
android:textSize="15sp" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!-- 右:时钟(大)+ 日期星期在时钟下面 -->
|
<!-- 右:时钟(大)+ 日期星期在时钟下面 -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:background="@drawable/bg_card"
|
android:background="@drawable/bg_card"
|
||||||
android:layout_marginStart="20dp"
|
android:layout_marginStart="20dp"
|
||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="20dp"
|
||||||
@@ -13,6 +12,15 @@
|
|||||||
android:paddingTop="14dp"
|
android:paddingTop="14dp"
|
||||||
android:paddingBottom="14dp">
|
android:paddingBottom="14dp">
|
||||||
|
|
||||||
|
<!-- 项目头:点击整行展开/收起任务列表 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/projectHeader"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/colorBar"
|
android:id="@+id/colorBar"
|
||||||
android:layout_width="4dp"
|
android:layout_width="4dp"
|
||||||
@@ -64,3 +72,24 @@
|
|||||||
android:src="@drawable/ic_more"
|
android:src="@drawable/ic_more"
|
||||||
android:contentDescription="@string/edit" />
|
android:contentDescription="@string/edit" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- 展开区:该项目下添加过的任务(含已完成),默认收起 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/taskList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvTaskEmpty"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="18dp"
|
||||||
|
android:paddingEnd="12dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:text="@string/project_no_tasks"
|
||||||
|
android:textColor="@color/text_tertiary"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</LinearLayout>
|
||||||
|
|||||||
56
src/main/res/layout/item_project_task.xml
Normal file
56
src/main/res/layout/item_project_task.xml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 项目卡展开后的任务行:结构与任务列表一致,但不显示分类(项目名),
|
||||||
|
meta 改为「单轮时长 · 最近完成时间 · 累计完成次数」,右侧保留开始按钮。 -->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:paddingStart="18dp"
|
||||||
|
android:paddingEnd="10dp"
|
||||||
|
android:paddingTop="9dp"
|
||||||
|
android:paddingBottom="9dp">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/taskColorBar"
|
||||||
|
android:layout_width="3dp"
|
||||||
|
android:layout_height="30dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginStart="11dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvTaskTitle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:ellipsize="end" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvTaskMeta"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:ellipsize="end"
|
||||||
|
style="@style/T.Caption" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btnTaskPlay"
|
||||||
|
android:layout_width="34dp"
|
||||||
|
android:layout_height="34dp"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:padding="9dp"
|
||||||
|
android:background="@drawable/bg_play_circle"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:src="@drawable/ic_play"
|
||||||
|
android:contentDescription="@string/start" />
|
||||||
|
</LinearLayout>
|
||||||
@@ -126,6 +126,11 @@
|
|||||||
<string name="delete_project_confirm">删除项目「%1$s」?项目下的任务会移到收件箱。</string>
|
<string name="delete_project_confirm">删除项目「%1$s」?项目下的任务会移到收件箱。</string>
|
||||||
|
|
||||||
<string name="projects_title">项目</string>
|
<string name="projects_title">项目</string>
|
||||||
|
<string name="project_no_tasks">还没有添加任务</string>
|
||||||
|
<string name="project_task_last_done">最近 %1$s 完成</string>
|
||||||
|
<string name="project_task_done_count">累计 %1$d 次</string>
|
||||||
|
<string name="project_expand_done">展开完成记录(%1$d)</string>
|
||||||
|
<string name="project_collapse_done">收起完成记录(%1$d)</string>
|
||||||
<string name="project_summary">%1$d 个项目 · %2$d 个待办</string>
|
<string name="project_summary">%1$d 个项目 · %2$d 个待办</string>
|
||||||
<string name="add_project">新建项目</string>
|
<string name="add_project">新建项目</string>
|
||||||
<string name="project_name_hint">项目名称</string>
|
<string name="project_name_hint">项目名称</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user