8 Commits
v1.7 ... v2.1

7 changed files with 126 additions and 70 deletions

View File

@@ -1,8 +1,42 @@
# 变更记录 # 变更记录
## 2026-11-29 · 完成文案改字;横屏分割线只分时间;置顶图标黑色bug修复恢复品牌蓝;完成删除线恢复,版本 1.7 ## 2026-11-30 · 分割线降至92dp与时间等高;改项目时迁移系列实例与完成记录修复双项目重复;普通任务按重要+紧急总分排序,版本 2.1
- 同步源码更新 6 个文件(新增/修改 6,删除 0)。 - 同步源码更新 3 个文件(新增/修改 3,删除 0)。
## 2026-11-30 · 分割线降至与时间等高 + 改项目迁移关联任务 + 重要紧急排序(v2.1)
- 分割线:150dp 偏高,降到 92dp(≈130sp 粗体数字字面高度 0.71em×130),与左右时间视觉等高。
- 改项目重复 bug:编辑已有任务换项目时,只有当前行更新了 project_id,而周期系列的其他实例(origin_id=根id)和完成记录副本(origin_id=实例id)都还复制着旧项目,导致新旧项目各显示一份同名任务。现在 updateTask 检测到项目变化时,把根任务、系列实例、实例的完成记录副本一起迁移到新项目(带旧项目条件保证幂等);编辑完成记录副本本身则只移动该行、不牵连源任务。
- 普通任务排序:改为按重要度+紧急度总分降序(各 0低/1中/2高,总分 4→0 对应:最重要最紧急 → 最重要或最紧急 → 中重要中紧急 → 中重要或中紧急 → 低低),同分内再按有截止日优先/截止日升序/创建先后。置顶、逾期分组保持在前不变。
- 改动文件:layout-land/activity_lock_screen.xml、Store.kt、build.gradle.kts、build.sh、SettingsFragment.kt。
- 本地验证:构建通过,aapt 确认 versionCode 45 / versionName 2.1,签名 SHA-256 7bcbd511…cc8c83 不变。
- 升级说明:直接覆盖安装,无数据迁移。
## 2026-11-30 · 分割线恢复原始可见实现 + 逾期任务置顶后优先(v2.0)
- 起因:v1.9 分割线仍不可见(match_parent 结构化方案也失效);用户确认最初静态 View 方案可见,要求恢复原实现只调高度;另要求逾期任务排在列表前面、置顶之后。
- 分割线方案:横屏布局整体恢复最初可见版本的原始结构——静态 View(1dp 宽)直接放在左右两栏之间,固定 150dp 高(≈130sp 时间文字墨迹高度 1.17×130sp,仅分割时间不盖下方文字),零运行时代码。
- 逾期排序:Store.tasks 的 ORDER BY 增加逾期分组层,未完成任务顺序变为:①随时置顶 ②已逾期(due>0 且 due<今天0点,阈值由 Dates.todayStart() 在查询时算好)③其余按截止日/优先级不变;逾期只提升位置,组内顺序不变。
- 改动文件:layout-land/activity_lock_screen.xml、Store.kt、build.gradle.kts、build.sh、SettingsFragment.kt。
- 本地验证:构建通过,aapt 确认 versionCode 44 / versionName 2.0,签名 SHA-256 7bcbd511…cc8c83 不变。
- 升级说明:直接覆盖安装,无数据迁移。
## 2026-11-30 · 横屏分割线结构化对齐(v1.9)
- 起因:分割线高度连续两版用「运行时改 LayoutParams」(View.post / fontMetrics 计算后 requestLayout)都在锁屏/悬浮窗链路上失效,线不显示。
- 根因:运行时改高度依赖布局系统对特殊窗口的重新布局,链路不可靠。
- 方案:改为纯 XML 结构约束——横屏布局重排为上下两行:上行「倒计时 | 分割线 | 时钟」同行排布,分割线 layout_height=match_parent 直接继承行高(行高即 130sp 时间文字高度);下行「任务名 | 占位 | 日期」与上行两栏逐列对齐。删除 Activity 与 LockOverlay 里的 syncDivider 代码,零运行时逻辑。
- 改动文件:layout-land/activity_lock_screen.xml、LockScreenActivity.kt、LockOverlay.kt、build.gradle.kts、build.sh、SettingsFragment.kt。
- 本地验证:构建通过,aapt 确认 versionCode 43 / versionName 1.9,签名 SHA-256 7bcbd511…cc8c83 不变。
- 升级说明:直接覆盖安装,无数据迁移。
## 2026-11-29 · 分割线算法化/删除线居中/置顶图标对齐(v1.8)
- 横屏分割线消失修复:上一版用 View.post 等布局完成后取 height 再赋值,在锁屏/悬浮窗链路上时机不稳导致线整条消失;改为直接由 paint.fontMetrics 算出文字实际高度(includeFontPadding=false 时 TextView 高度即 ascent..descent 跨度),零时序依赖、立即生效(Activity 与悬浮窗两链路同步)
- 删除线视觉居中:系统 StrikethroughSpan 按「字体半高」定位(baseline + ascent/2),数字/汉字实际墨迹顶比字体 ascent 低,线看起来偏下;改为 MidStrikeSpan 自绘——按 getTextBounds 实际墨迹边界取垂直中点,线严格穿过文字中间,仍只划任务名不划图标
- 置顶图标对齐与粗细:圈线粗细改为 1/10 图标高(贴近重要度圆圈数字的描边),箭头细化为 1/15;圆心从基线上方 0.50 下移到 0.45 个图标高(圆圈数字底缘本就略过基线,底部对齐不再偏上)
- versionCode 42
## 2026-11-29 · 锁屏/通知/任务列表细节修复(v1.7) ## 2026-11-29 · 锁屏/通知/任务列表细节修复(v1.7)

View File

@@ -249,12 +249,17 @@ object Store {
args.add(projectId.toString()) args.add(projectId.toString())
} }
if (!includeDone) where.append(" AND done = 0") if (!includeDone) where.append(" AND done = 0")
// 已完成的按完成时间倒序(最近做完的排前面),未完成的按截止/优先级; // 已完成的按完成时间倒序(最近做完的排前面)。未完成分组依次是:
// 「随时」任务(repeat_type=4)排到未完成最前面,随时可以开始 // ①「随时」置顶(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 " + val sql = "SELECT $taskColumns FROM tasks WHERE $where " +
"ORDER BY done ASC, CASE WHEN done = 1 THEN done_at ELSE 0 END DESC, " + "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, " + "CASE WHEN done = 0 AND repeat_type = ${Repeat.ANYTIME} THEN 0 ELSE 1 END ASC, " +
"CASE WHEN due = 0 THEN 1 ELSE 0 END ASC, due ASC, priority DESC, _id DESC" "CASE WHEN done = 0 AND due > 0 AND due < $todayStart THEN 0 ELSE 1 END ASC, " +
"CASE WHEN done = 0 THEN priority + urgency ELSE 0 END DESC, " +
"CASE WHEN due = 0 THEN 1 ELSE 0 END ASC, due ASC, _id DESC"
val list = ArrayList<Task>() val list = ArrayList<Task>()
db.rawQuery(sql, args.toTypedArray()).use { c -> db.rawQuery(sql, args.toTypedArray()).use { c ->
while (c.moveToNext()) list.add(cursorToTask(c)) while (c.moveToNext()) list.add(cursorToTask(c))
@@ -300,6 +305,8 @@ object Store {
} }
fun updateTask(task: Task) { fun updateTask(task: Task) {
// 改动前先取旧行:判断项目是否变化、以及该行是不是"完成记录副本"
val old = task(task.id)
val cv = ContentValues().apply { val cv = ContentValues().apply {
put("title", task.title) put("title", task.title)
put("note", task.note) put("note", task.note)
@@ -313,6 +320,20 @@ object Store {
put("repeat_every", task.repeatEvery.coerceAtLeast(1)) put("repeat_every", task.repeatEvery.coerceAtLeast(1))
} }
db.update("tasks", cv, "_id = ?", arrayOf(task.id.toString())) db.update("tasks", cv, "_id = ?", arrayOf(task.id.toString()))
// 项目变了 → 关联行一起迁移,否则旧项目会残留同名任务:
// 周期系列的其他实例(origin_id=根id)和完成记录副本(origin_id=实例id)
// 都是创建时从当前行复制的旧项目。完成记录副本本身被编辑时不牵连源任务。
if (old != null && old.projectId != task.projectId &&
!(old.done && old.repeatType == Repeat.NONE && old.originId > 0)
) {
val root = if (old.originId > 0) old.originId else old.id
db.execSQL(
"UPDATE tasks SET project_id = ? WHERE project_id = ? AND (" +
"_id = ? OR origin_id = ? OR " +
"origin_id IN (SELECT _id FROM tasks WHERE origin_id = ?))",
arrayOf(task.projectId, old.projectId, root, root, root),
)
}
} }
/** /**

View File

@@ -137,30 +137,11 @@ object LockOverlay {
view.findViewById<TextView>(R.id.tvLockClock)?.text = clockFmt.format(cal.time) view.findViewById<TextView>(R.id.tvLockClock)?.text = clockFmt.format(cal.time)
view.findViewById<TextView>(R.id.tvLockCountdown)?.text = Dates.clock(now) view.findViewById<TextView>(R.id.tvLockCountdown)?.text = Dates.clock(now)
syncDivider(view)
val task = if (TimerCore.taskId > 0) Store.task(TimerCore.taskId)?.title else null val task = if (TimerCore.taskId > 0) Store.task(TimerCore.taskId)?.title else null
view.findViewById<TextView>(R.id.tvLockTask)?.text = view.findViewById<TextView>(R.id.tvLockTask)?.text =
task?.takeIf { it.isNotBlank() } ?: view.context.getString(R.string.notif_no_task) task?.takeIf { it.isNotBlank() } ?: view.context.getString(R.string.notif_no_task)
} }
/**
* 横屏排版里的分割线只分割两块大时间:高度对齐倒计时文字的实际渲染高度。
* 竖屏布局没有这个控件,查找结果为 null 直接跳过。
*/
private fun syncDivider(view: View) {
val divider = view.findViewById<View>(R.id.lockDivider) ?: return
val countdown = view.findViewById<TextView>(R.id.tvLockCountdown) ?: return
divider.post {
if (countdown.height > 0 && divider.layoutParams != null &&
divider.layoutParams.height != countdown.height
) {
divider.layoutParams.height = countdown.height
divider.requestLayout()
}
}
}
/** Calendar 的 DAY_OF_WEEK(周日=1)转成 weekdayShort 的下标(周一=0 … 周日=6) */ /** Calendar 的 DAY_OF_WEEK(周日=1)转成 weekdayShort 的下标(周一=0 … 周日=6) */
private fun weekdayIndex(cal: Calendar): Int = (cal.get(Calendar.DAY_OF_WEEK) + 5) % 7 private fun weekdayIndex(cal: Calendar): Int = (cal.get(Calendar.DAY_OF_WEEK) + 5) % 7
} }

View File

@@ -156,28 +156,10 @@ class LockScreenActivity : AppCompatActivity() {
tvClock.text = clockFmt.format(cal.time) tvClock.text = clockFmt.format(cal.time)
tvCountdown.text = Dates.clock(now) tvCountdown.text = Dates.clock(now)
syncDivider()
val task = if (TimerCore.taskId > 0) Store.task(TimerCore.taskId)?.title else null 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) tvTask.text = task?.takeIf { it.isNotBlank() } ?: getString(R.string.notif_no_task)
} }
/**
* 横屏排版里的分割线只分割两块大时间:高度对齐倒计时文字的实际渲染高度,
* 不再盖住下方的任务名/日期行。竖屏布局没有这个控件,查找结果为 null 直接跳过。
*/
private fun syncDivider() {
val divider = findViewById<View>(R.id.lockDivider) ?: return
divider.post {
if (tvCountdown.height > 0 && divider.layoutParams != null &&
divider.layoutParams.height != tvCountdown.height
) {
divider.layoutParams.height = tvCountdown.height
divider.requestLayout()
}
}
}
/** Calendar 的 DAY_OF_WEEK(周日=1)转成 weekdayShort 的下标(周一=0 … 周日=6) */ /** Calendar 的 DAY_OF_WEEK(周日=1)转成 weekdayShort 的下标(周一=0 … 周日=6) */
private fun weekdayIndex(cal: Calendar): Int = (cal.get(Calendar.DAY_OF_WEEK) + 5) % 7 private fun weekdayIndex(cal: Calendar): Int = (cal.get(Calendar.DAY_OF_WEEK) + 5) % 7
} }

View File

@@ -539,6 +539,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
} }
companion object { companion object {
const val VERSION = "1.7" const val VERSION = "2.1"
} }
} }

View File

@@ -127,14 +127,12 @@ class TaskAdapter(
) )
} }
// 完成横线只画任务名本身(StrikethroughSpan 限定区间), // 完成横线只画任务名本身(MidStrikeSpan 限定区间,且划线取文字墨迹
// 后面的重要度/紧急度/置顶图标不跟着划线。 // 的垂直中点——系统 StrikethroughSpan 用整字面半高定位,数字/汉字
// 会让线显得偏下)。重要度/紧急度/置顶图标不跟着划线。
// 注意:span 必须在 tvTitle.text = title 之前挂好 // 注意:span 必须在 tvTitle.text = title 之前挂好
if (task.done) { if (task.done) {
title.setSpan( title.setSpan(MidStrikeSpan(), 0, task.title.length, 0)
android.text.style.StrikethroughSpan(),
0, task.title.length, 0,
)
} }
tvTitle.text = title tvTitle.text = title
tvTitle.paintFlags = tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv() tvTitle.paintFlags = tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
@@ -208,6 +206,36 @@ class TaskAdapter(
} }
} }
/**
* 任务名删除线:系统 StrikethroughSpan 的划线位置按"字体半高"(baseline + ascent/2)
* 计算,但数字/汉字的实际墨迹顶比字体 ascent 低不少,划线视觉上偏下。
* 这里自绘:按实际墨迹边界(getTextBounds)取垂直中点,线严格穿过文字中间。
*/
private class MidStrikeSpan : android.text.style.ReplacementSpan() {
override fun getSize(
paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?,
): Int = paint.measureText(text, start, end).toInt()
override fun draw(
canvas: android.graphics.Canvas, text: CharSequence, start: Int, end: Int,
x: Float, top: Int, baseline: Int, bottom: Int, paint: Paint,
) {
// 先按原样式画字(无删除线标志)
canvas.drawText(text, start, end, x, baseline.toFloat(), paint)
val s = text.toString()
val bounds = android.graphics.Rect()
paint.getTextBounds(s, start, end, bounds)
// 墨迹垂直中点:bounds.top/bottom 相对基线的偏移(top 为负)
val lineY = baseline + (bounds.top + bounds.bottom) / 2f
val w = paint.measureText(text, start, end)
val line = Paint(Paint.ANTI_ALIAS_FLAG)
line.color = paint.color
line.strokeWidth = (paint.textSize / 28f).coerceAtLeast(1f)
canvas.drawLine(x, lineY, x + w, lineY, line)
}
}
/** /**
* 置顶图标:圆圈内向上箭头。 * 置顶图标:圆圈内向上箭头。
* 自绘而不是用字体字形——常用字体里没有"圆圈+箭头"的组合字符, * 自绘而不是用字体字形——常用字体里没有"圆圈+箭头"的组合字符,
@@ -238,24 +266,29 @@ private class PinIconSpan(
x: Float, top: Int, baseline: Int, bottom: Int, paint: Paint, x: Float, top: Int, baseline: Int, bottom: Int, paint: Paint,
) { ) {
val s = size val s = size
// 与 ①②③ 底部对齐:字体里的圆圈数字底缘略微越过基线(约 -0.05 个图标高),
// 圆心取基线上方 0.45 个图标高,比之前 0.50 略下移,底部不再"悬空"显偏上
val cx = x + s / 2f val cx = x + s / 2f
// 与 ①②③ 字形对齐:圆圈数字贴基线站立,圆心约在基线上方 0.5 个图标高 val cy = baseline - s * 0.45f
val cy = baseline - s * 0.5f // 圈线与重要度圆圈数字的描边粗细一致(约 1/10 图标高)
// 不能用 apply { this.color = ... }:作用域里 color 会命中 Paint 自己的 val ring = Paint(Paint.ANTI_ALIAS_FLAG)
// color 属性(默认黑色),把外面的品牌蓝遮掉——就是那版"图标变黑"的原因 ring.color = iconColor
val p = Paint(Paint.ANTI_ALIAS_FLAG) ring.style = Paint.Style.STROKE
p.color = iconColor ring.strokeWidth = s / 10f
p.style = Paint.Style.STROKE ring.strokeCap = Paint.Cap.ROUND
p.strokeWidth = s / 8f canvas.drawCircle(cx, cy, s / 2f - ring.strokeWidth / 2f, ring)
p.strokeCap = Paint.Cap.ROUND
canvas.drawCircle(cx, cy, s / 2f - p.strokeWidth / 2f, p)
// 向上箭头:竖杆 + 两条斜线,整体落在圆内 // 箭头比圈线更细(约 1/15 图标高),整体落在圆内
val head = s * 0.17f val arrow = Paint(Paint.ANTI_ALIAS_FLAG)
val yTop = cy - s * 0.15f arrow.color = iconColor
val yBot = cy + s * 0.19f arrow.style = Paint.Style.STROKE
canvas.drawLine(cx, yBot, cx, yTop, p) arrow.strokeWidth = s / 15f
canvas.drawLine(cx - head, yTop + head, cx, yTop, p) arrow.strokeCap = Paint.Cap.ROUND
canvas.drawLine(cx + head, yTop + head, cx, yTop, p) val head = s * 0.18f
val yTop = cy - s * 0.16f
val yBot = cy + s * 0.18f
canvas.drawLine(cx, yBot, cx, yTop, arrow)
canvas.drawLine(cx - head, yTop + head, cx, yTop, arrow)
canvas.drawLine(cx + head, yTop + head, cx, yTop, arrow)
} }
} }

View File

@@ -2,7 +2,12 @@
<!-- <!--
锁屏全屏倒计时·横屏专属排版(区别于竖屏的纯纵向堆叠): 锁屏全屏倒计时·横屏专属排版(区别于竖屏的纯纵向堆叠):
左右对称分栏——左侧倒计时(大)+ 任务名,右侧时钟(大)+ 日期星期, 左右对称分栏——左侧倒计时(大)+ 任务名,右侧时钟(大)+ 日期星期,
两侧主字号统一 96sp,视觉左右对应;无「工作中/休息中」提示。 两侧主字号统一 130sp,视觉左右对应;无「工作中/休息中」提示。
分割线:保持最初可见版本的原始实现——静态 View 直接放在两栏之间,
固定 dp 高度,无任何运行时改动(此前的 View.post / fontMetrics /
match_parent 结构化三版方案在锁屏/悬浮窗链路上全部失效)。
高度 150dp ≈ 130sp 时间文字的墨迹高度(1.17 × 130sp),仅分割两块大时间。
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lockRoot" android:id="@+id/lockRoot"
@@ -43,11 +48,11 @@
android:textSize="15sp" /> android:textSize="15sp" />
</LinearLayout> </LinearLayout>
<!-- 中:细分隔线(只分割两块大时间,高度运行时对齐倒计时文字的实际高度) --> <!-- 中:细分隔线(92dp≈130sp 粗体数字的字面高度 0.71em×130,与时间视觉等高) -->
<View <View
android:id="@+id/lockDivider" android:id="@+id/lockDivider"
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="180dp" android:layout_height="92dp"
android:background="#26FFFFFF" /> android:background="#26FFFFFF" />
<!-- 右:时钟(大)+ 日期星期在时钟下面 --> <!-- 右:时钟(大)+ 日期星期在时钟下面 -->