完成文案改字;横屏分割线只分时间;置顶图标黑色bug修复恢复品牌蓝;完成删除线恢复,版本 1.7
This commit is contained in:
@@ -137,11 +137,30 @@ object LockOverlay {
|
||||
view.findViewById<TextView>(R.id.tvLockClock)?.text = clockFmt.format(cal.time)
|
||||
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
|
||||
view.findViewById<TextView>(R.id.tvLockTask)?.text =
|
||||
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) */
|
||||
private fun weekdayIndex(cal: Calendar): Int = (cal.get(Calendar.DAY_OF_WEEK) + 5) % 7
|
||||
}
|
||||
|
||||
@@ -156,10 +156,28 @@ class LockScreenActivity : AppCompatActivity() {
|
||||
tvClock.text = clockFmt.format(cal.time)
|
||||
tvCountdown.text = Dates.clock(now)
|
||||
|
||||
syncDivider()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
* 横屏排版里的分割线只分割两块大时间:高度对齐倒计时文字的实际渲染高度,
|
||||
* 不再盖住下方的任务名/日期行。竖屏布局没有这个控件,查找结果为 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) */
|
||||
private fun weekdayIndex(cal: Calendar): Int = (cal.get(Calendar.DAY_OF_WEEK) + 5) % 7
|
||||
}
|
||||
|
||||
@@ -539,6 +539,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "1.6"
|
||||
const val VERSION = "1.7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,16 +127,17 @@ class TaskAdapter(
|
||||
)
|
||||
}
|
||||
|
||||
tvTitle.text = title
|
||||
// 完成横线只画任务名本身(StrikethroughSpan 限定区间),
|
||||
// 后面的重要度/紧急度/置顶图标不跟着划线
|
||||
tvTitle.paintFlags = tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||
// 后面的重要度/紧急度/置顶图标不跟着划线。
|
||||
// 注意:span 必须在 tvTitle.text = title 之前挂好
|
||||
if (task.done) {
|
||||
title.setSpan(
|
||||
android.text.style.StrikethroughSpan(),
|
||||
0, task.title.length, 0,
|
||||
)
|
||||
}
|
||||
tvTitle.text = title
|
||||
tvTitle.paintFlags = tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
||||
tvTitle.setTextColor(ctx.col(if (task.done) R.color.text_tertiary else R.color.text))
|
||||
tvTitle.typeface = if (task.priority >= 2 && !task.done) Typeface.DEFAULT_BOLD else Typeface.DEFAULT
|
||||
|
||||
@@ -211,9 +212,10 @@ class TaskAdapter(
|
||||
* 置顶图标:圆圈内向上箭头。
|
||||
* 自绘而不是用字体字形——常用字体里没有"圆圈+箭头"的组合字符,
|
||||
* 画出来才能精确控制圆圈与箭头同色、且和重要度圆圈数字(0.85 倍字号)等高。
|
||||
* 颜色用品牌蓝(R.color.brand,深浅色主题各有一版),与之前的 ↑ 字符颜色一致。
|
||||
*/
|
||||
private class PinIconSpan(
|
||||
private val color: Int,
|
||||
private val iconColor: Int,
|
||||
private val size: Float,
|
||||
) : android.text.style.ReplacementSpan() {
|
||||
|
||||
@@ -239,12 +241,13 @@ private class PinIconSpan(
|
||||
val cx = x + s / 2f
|
||||
// 与 ①②③ 字形对齐:圆圈数字贴基线站立,圆心约在基线上方 0.5 个图标高
|
||||
val cy = baseline - s * 0.5f
|
||||
val p = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||
this.color = color
|
||||
style = Paint.Style.STROKE
|
||||
strokeWidth = s / 8f
|
||||
strokeCap = Paint.Cap.ROUND
|
||||
}
|
||||
// 不能用 apply { this.color = ... }:作用域里 color 会命中 Paint 自己的
|
||||
// color 属性(默认黑色),把外面的品牌蓝遮掉——就是那版"图标变黑"的原因
|
||||
val p = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||
p.color = iconColor
|
||||
p.style = Paint.Style.STROKE
|
||||
p.strokeWidth = s / 8f
|
||||
p.strokeCap = Paint.Cap.ROUND
|
||||
canvas.drawCircle(cx, cy, s / 2f - p.strokeWidth / 2f, p)
|
||||
|
||||
// 向上箭头:竖杆 + 两条斜线,整体落在圆内
|
||||
|
||||
Reference in New Issue
Block a user