4 Commits
v1.7 ... v1.9

6 changed files with 158 additions and 113 deletions

View File

@@ -1,8 +1,24 @@
# 变更记录 # 变更记录
## 2026-11-29 · 完成文案改字;横屏分割线只分时间;置顶图标黑色bug修复恢复品牌蓝;完成删除线恢复,版本 1.7 ## 2026-11-30 · 横屏分割线改纯XML结构化对齐(match_parent继承时间行高),删除运行时高度代码,版本 1.9
- 同步源码更新 6 个文件(新增/修改 6,删除 0)。 - 同步源码更新 4 个文件(新增/修改 4,删除 0)。
## 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

@@ -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 = "1.9"
} }
} }

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

@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
锁屏全屏倒计时·横屏专属排版(区别于竖屏的纯纵向堆叠): 锁屏全屏倒计时·横屏专属排版(区别于竖屏的纯纵向堆叠):
左右对称分栏 —— 左侧倒计时(大)+ 任务名,右侧时钟(大)+ 日期星期, 上行是主行:倒计时 | 分割线 | 时钟,三者在同一行内,
两侧主字号统一 96sp,视觉左右对应;无「工作中/休息中」提示。 分割线高度用 match_parent 直接继承行高——行高由两侧 130sp 大时间撑起,
所以线高天然与时间文字一致,纯 XML 结构保证,不依赖任何运行时代码
(此前两版运行时改高度的方案在锁屏/悬浮窗链路上都失效了)。
下行是副行:任务名 | 占位 | 日期星期,与上行两栏逐列对齐。
--> -->
<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"
@@ -11,69 +14,99 @@
android:background="@android:color/black" android:background="@android:color/black"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:gravity="center_vertical" android:gravity="center"
android:orientation="horizontal"> android:orientation="vertical">
<!-- 左:倒计时 + 任务名 --> <!-- 上行:倒计时 | 分割线 | 时钟(分割线高度=本行高度=时间文字高度) -->
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:orientation="horizontal">
android:gravity="center"
android:orientation="vertical">
<TextView <LinearLayout
android:id="@+id/tvLockCountdown" android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:includeFontPadding="false" android:layout_weight="1"
android:textColor="#FFFFFF" android:gravity="center"
android:textSize="130sp" android:orientation="vertical">
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tvLockTask" android:id="@+id/tvLockCountdown"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:textColor="#FFFFFF"
android:textSize="130sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:id="@+id/lockDivider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#26FFFFFF" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_weight="1"
android:ellipsize="end" android:gravity="center"
android:maxWidth="320dp" android:orientation="vertical">
android:maxLines="1"
android:textColor="#99FFFFFF" <TextView
android:textSize="15sp" /> android:id="@+id/tvLockClock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:textColor="#FFFFFF"
android:textSize="130sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<!-- 中:细分隔线(只分割两块大时间,高度运行时对齐倒计时文字的实际高度) --> <!-- 下行:任务名 | 占位(与分割线同宽,保持两栏对齐) | 日期星期 -->
<View
android:id="@+id/lockDivider"
android:layout_width="1dp"
android:layout_height="180dp"
android:background="#26FFFFFF" />
<!-- 右:时钟(大)+ 日期星期在时钟下面 -->
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_marginTop="10dp"
android:gravity="center" android:orientation="horizontal">
android:orientation="vertical">
<TextView <LinearLayout
android:id="@+id/tvLockClock" android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:includeFontPadding="false" android:layout_weight="1"
android:textColor="#FFFFFF" android:gravity="center"
android:textSize="130sp" android:orientation="vertical">
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tvLockDate" android:id="@+id/tvLockTask"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxWidth="320dp"
android:maxLines="1"
android:textColor="#99FFFFFF"
android:textSize="15sp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_weight="1"
android:textColor="#99FFFFFF" android:gravity="center"
android:textSize="15sp" /> android:orientation="vertical">
<TextView
android:id="@+id/tvLockDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#99FFFFFF"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>