Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ad5441ba4 | ||
|
|
9c8e2eb534 | ||
|
|
eb3d961b0a | ||
|
|
9fdecfb1b9 | ||
|
|
a8446bcf51 | ||
|
|
54df5b398c | ||
|
|
8a1f41ca9d | ||
|
|
4a648669ea |
31
CHANGELOG.md
31
CHANGELOG.md
@@ -1,5 +1,36 @@
|
||||
# 变更记录
|
||||
|
||||
## 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)
|
||||
|
||||
- 起因:用户报告竖屏专注时间变小(回归)。v2.6 的 CountdownFit 等宽缩号在锁屏页与悬浮窗两条链路都接入,竖屏被波及——该工具只要倒计时文字比时钟宽几像素(鸿蒙字体数字非严格等宽时必然发生)就缩小倒计时,前提错误。
|
||||
- 处理(回退):LockScreenActivity.kt、LockOverlay.kt 从 v2.3 提交 2dd7f8b 原样恢复(md5 校验一致);删除 util/CountdownFit.kt。
|
||||
- 全量比对:app/src 树与 v2.3 完全一致,仅 SettingsFragment.kt 版本号字符串不同;横竖屏布局 XML 本轮零改动。
|
||||
- 版本:versionCode 51 / versionName 2.7(Android 禁止 versionCode 降级,无法回退到 45),签名 SHA-256 7bcbd511…cc8c83 不变,直接覆盖安装,无数据迁移。装上后锁屏/悬浮窗行为与确认正常的 v2.3 一致。
|
||||
- 横屏线与左右数字的间距问题本轮未动,待截图实测后另行处理。
|
||||
|
||||
## 2026-11-30 · 回退 v2.3 布局基线 + 倒计时等宽缩号(v2.6)
|
||||
|
||||
- 起因:v2.5 的 autoSize 方案在锁屏/悬浮窗特殊窗口上渲染异常(时间缩小居中、高度只显示约三分之一),判定 autoSize 在该链路不可靠,彻底放弃。按用户要求回退到 v2.3(确认"高度对齐成功"的版本)重新修。
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.database.sqlite.SQLiteOpenHelper
|
||||
import com.focusbox.app.model.DayPoint
|
||||
import com.focusbox.app.model.Project
|
||||
import com.focusbox.app.model.ProjectSlice
|
||||
import com.focusbox.app.model.ProjectTaskStat
|
||||
import com.focusbox.app.model.Repeat
|
||||
import com.focusbox.app.model.SessionSpan
|
||||
import com.focusbox.app.model.Task
|
||||
@@ -267,6 +268,56 @@ object Store {
|
||||
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? {
|
||||
db.rawQuery("SELECT $taskColumns FROM tasks WHERE _id = ?", arrayOf(id.toString())).use { c ->
|
||||
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)
|
||||
|
||||
/**
|
||||
* 项目卡展开后的一条任务行:任务本体 + 三项统计。
|
||||
* 仅用于项目页展开列表,任务页的 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 落备注的实际专注信息 */
|
||||
data class FocusFinish(
|
||||
val taskId: Long,
|
||||
|
||||
@@ -12,7 +12,6 @@ import android.view.WindowManager
|
||||
import android.widget.TextView
|
||||
import com.focusbox.app.R
|
||||
import com.focusbox.app.data.Store
|
||||
import com.focusbox.app.util.CountdownFit
|
||||
import com.focusbox.app.util.Dates
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
@@ -135,14 +134,8 @@ object LockOverlay {
|
||||
val cal = Calendar.getInstance()
|
||||
view.findViewById<TextView>(R.id.tvLockDate)?.text =
|
||||
"${Dates.mdLong(cal.timeInMillis)} 星期${Dates.weekdayShort(weekdayIndex(cal))}"
|
||||
val tvClock = view.findViewById<TextView>(R.id.tvLockClock)
|
||||
val tvCountdown = view.findViewById<TextView>(R.id.tvLockCountdown)
|
||||
tvClock?.text = clockFmt.format(cal.time)
|
||||
tvCountdown?.text = Dates.clock(now)
|
||||
// 倒计时 6 位数(≥100 分钟)时缩到与时钟等宽,保证左右间隙相等;5 位恢复 130sp
|
||||
if (tvClock != null && tvCountdown != null) {
|
||||
CountdownFit.fit(tvCountdown, tvClock, tvCountdown.text.toString(), tvClock.text.toString())
|
||||
}
|
||||
view.findViewById<TextView>(R.id.tvLockClock)?.text = clockFmt.format(cal.time)
|
||||
view.findViewById<TextView>(R.id.tvLockCountdown)?.text = Dates.clock(now)
|
||||
|
||||
val task = if (TimerCore.taskId > 0) Store.task(TimerCore.taskId)?.title else null
|
||||
view.findViewById<TextView>(R.id.tvLockTask)?.text =
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.focusbox.app.R
|
||||
import com.focusbox.app.data.Store
|
||||
import com.focusbox.app.service.Notif
|
||||
import com.focusbox.app.service.TimerCore
|
||||
import com.focusbox.app.util.CountdownFit
|
||||
import com.focusbox.app.util.Dates
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
@@ -156,8 +155,6 @@ class LockScreenActivity : AppCompatActivity() {
|
||||
tvDate.text = "${Dates.mdLong(cal.timeInMillis)} 星期${Dates.weekdayShort(weekdayIndex(cal))}"
|
||||
tvClock.text = clockFmt.format(cal.time)
|
||||
tvCountdown.text = Dates.clock(now)
|
||||
// 倒计时 6 位数(≥100 分钟)时缩到与时钟等宽,保证左右间隙相等;5 位恢复 130sp
|
||||
CountdownFit.fit(tvCountdown, tvClock, tvCountdown.text.toString(), tvClock.text.toString())
|
||||
|
||||
val task = if (TimerCore.taskId > 0) Store.task(TimerCore.taskId)?.title else null
|
||||
tvTask.text = task?.takeIf { it.isNotBlank() } ?: getString(R.string.notif_no_task)
|
||||
|
||||
@@ -1,30 +1,44 @@
|
||||
package com.focusbox.app.ui.projects
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Paint
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.focusbox.app.R
|
||||
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.col
|
||||
import com.focusbox.app.util.roundBg
|
||||
import com.focusbox.app.util.tint
|
||||
import com.focusbox.app.util.visible
|
||||
|
||||
/**
|
||||
* 项目列表:点击项目头就地展开该项目下的任务,不再跳转任务页。
|
||||
* 展开区只展示统计,交互只有右侧「开始」——编辑/勾选仍走原任务页,任务页逻辑不动。
|
||||
*/
|
||||
class ProjectAdapter(
|
||||
private val onClick: (Project) -> Unit,
|
||||
private val onToggleExpand: (Project) -> Unit,
|
||||
private val onLongClick: (Project) -> Unit,
|
||||
private val onMore: (Project) -> Unit,
|
||||
private val onStart: (Task) -> Unit,
|
||||
) : RecyclerView.Adapter<ProjectAdapter.VH>() {
|
||||
|
||||
private var items: List<Project> = emptyList()
|
||||
private var expandedId: Long = -1L
|
||||
private var stats: Map<Long, List<ProjectTaskStat>> = emptyMap()
|
||||
|
||||
fun submit(list: List<Project>) {
|
||||
fun submit(list: List<Project>, expanded: Long, taskStats: Map<Long, List<ProjectTaskStat>>) {
|
||||
items = list
|
||||
expandedId = expanded
|
||||
stats = taskStats
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
@@ -41,13 +55,16 @@ class ProjectAdapter(
|
||||
private val progress: ProgressBar = v.findViewById(R.id.progress)
|
||||
private val colorBar: View = v.findViewById(R.id.colorBar)
|
||||
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) {
|
||||
val ctx = itemView.context
|
||||
name.text = p.name
|
||||
colorBar.background = ctx.roundBg(p.color, 2f)
|
||||
|
||||
// 只看任务与时长,不再显示番茄数
|
||||
// 只看任务与时长,不再显示番茄数(与改动前一致)
|
||||
val parts = ArrayList<String>(3)
|
||||
parts.add("${p.openTasks} 待办")
|
||||
if (p.doneTasks > 0) parts.add("${p.doneTasks} 已完成")
|
||||
@@ -61,11 +78,58 @@ class ProjectAdapter(
|
||||
more.tint(ctx.col(R.color.text_tertiary))
|
||||
more.setOnClickListener { onMore(p) }
|
||||
|
||||
itemView.setOnClickListener { onClick(p) }
|
||||
itemView.setOnLongClickListener {
|
||||
header.setOnClickListener { onToggleExpand(p) }
|
||||
header.setOnLongClickListener {
|
||||
onLongClick(p)
|
||||
true
|
||||
}
|
||||
|
||||
val expanded = expandedId == p.id
|
||||
val rows = if (expanded) stats[p.id].orEmpty() else emptyList()
|
||||
taskList.visible(expanded && rows.isNotEmpty())
|
||||
tvTaskEmpty.visible(expanded && rows.isEmpty())
|
||||
if (!expanded) return
|
||||
|
||||
taskList.removeAllViews()
|
||||
rows.forEach { row ->
|
||||
val item = LayoutInflater.from(ctx)
|
||||
.inflate(R.layout.item_project_task, taskList, false)
|
||||
bindTaskRow(item, row, p)
|
||||
taskList.addView(item)
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
if (row.doneCount > 0) {
|
||||
parts.add(ctx.getString(R.string.project_task_done_count, row.doneCount))
|
||||
}
|
||||
tvMeta.text = parts.joinToString(" · ")
|
||||
|
||||
btnPlay.visible(!task.done)
|
||||
btnPlay.tint(ctx.col(R.color.brand))
|
||||
btnPlay.setOnClickListener { onStart(task) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.focusbox.app.R
|
||||
import com.focusbox.app.data.Store
|
||||
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.SheetDialog
|
||||
import com.focusbox.app.util.col
|
||||
@@ -25,6 +27,10 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
|
||||
|
||||
private var showArchived = false
|
||||
|
||||
/** 当前展开的项目 id;-1 表示全部收起。只展开一个,避免列表过长 */
|
||||
private var expandedProjectId = -1L
|
||||
private var taskStats: Map<Long, List<ProjectTaskStat>> = emptyMap()
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
recycler = view.findViewById(R.id.recycler)
|
||||
@@ -33,9 +39,13 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
|
||||
btnArchived = view.findViewById(R.id.btnArchived)
|
||||
|
||||
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) },
|
||||
onMore = { p -> showActions(p) },
|
||||
onStart = { t -> (activity as? MainActivity)?.startFocusOn(t) },
|
||||
)
|
||||
recycler.layoutManager = LinearLayoutManager(requireContext())
|
||||
recycler.adapter = adapter
|
||||
@@ -68,7 +78,12 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
|
||||
val archived = all.filter { it.archived }
|
||||
|
||||
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)
|
||||
|
||||
tvSummary.text = getString(
|
||||
R.string.project_summary, active.size, active.sumOf { it.openTasks }
|
||||
|
||||
@@ -539,6 +539,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "2.6"
|
||||
const val VERSION = "3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.focusbox.app.util
|
||||
|
||||
import android.util.TypedValue
|
||||
import android.widget.TextView
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
* 倒计时等宽缩号:倒计时 ≥100 分钟时为 6 位数(如 120:00),比右侧时钟
|
||||
* (恒 5 位 HH:mm)宽出整整一个数字。锁屏横屏是居中布局,左边文字更宽
|
||||
* 会把左侧间隙压小、甚至越过分割线——表现为「右边距离比左边大」。
|
||||
*
|
||||
* 对策:按实际字体测量(Paint.measureText,不依赖任何估算的字体参数),
|
||||
* 把倒计时文字宽度缩到与时钟完全等宽 → 居中布局下左右间隙天然相等;
|
||||
* 回到 5 位时恢复基准字号(130sp,越大越好不变)。
|
||||
*
|
||||
* 竖向对齐不受影响:时间列结构为「时间 + 10dp + 小字」且整体居中,
|
||||
* 时间的垂直中心 = 列中心 − (10dp+小字)/2,与时间自身字号无关,
|
||||
* 缩号后分割线仍与两侧时间上下对齐。
|
||||
*/
|
||||
object CountdownFit {
|
||||
|
||||
/** 每个 TextView 的基准字号(px),首次调用时捕获(来自布局 130sp) */
|
||||
private val baseSizes = HashMap<TextView, Float>()
|
||||
|
||||
/** 应用等宽缩号。调用前提:clockText 已先行设置到 clock 上 */
|
||||
fun fit(countdown: TextView, clock: TextView, countdownText: String, clockText: String) {
|
||||
val base = baseSizes.getOrPut(countdown) { countdown.textSize }
|
||||
// 先复位到基准,再按基准度量宽度(paint 的 textSize 在 setTextSize 后同步生效)
|
||||
if (countdown.textSize != base) {
|
||||
countdown.setTextSize(TypedValue.COMPLEX_UNIT_PX, base)
|
||||
}
|
||||
val cdW = countdown.paint.measureText(countdownText)
|
||||
val clockW = clock.paint.measureText(clockText)
|
||||
if (cdW > clockW) {
|
||||
val target = base * clockW / cdW
|
||||
if (abs(countdown.textSize - target) > 0.5f) {
|
||||
countdown.setTextSize(TypedValue.COMPLEX_UNIT_PX, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,49 +56,7 @@
|
||||
android:textSize="15sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 中:细分隔线(92dp≈130sp 粗体数字的字面高度 0.71em×130,与时间视觉等高)
|
||||
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>
|
||||
<!-- 中列分割线已按用户要求移除(v2.9):左右两栏各占一半宽度,文字各自居中 -->
|
||||
|
||||
<!-- 右:时钟(大)+ 日期星期在时钟下面 -->
|
||||
<LinearLayout
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
<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:orientation="vertical"
|
||||
android:background="@drawable/bg_card"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
@@ -13,6 +12,15 @@
|
||||
android:paddingTop="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
|
||||
android:id="@+id/colorBar"
|
||||
android:layout_width="4dp"
|
||||
@@ -63,4 +71,25 @@
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_more"
|
||||
android:contentDescription="@string/edit" />
|
||||
</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,9 @@
|
||||
<string name="delete_project_confirm">删除项目「%1$s」?项目下的任务会移到收件箱。</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_summary">%1$d 个项目 · %2$d 个待办</string>
|
||||
<string name="add_project">新建项目</string>
|
||||
<string name="project_name_hint">项目名称</string>
|
||||
|
||||
Reference in New Issue
Block a user