完成任务删除线只画任务名;置顶改圆圈箭头图标;饼图中心删小字居中;悬浮窗权限已开启不可点;每日目标可输入去上限,版本 1.6

This commit is contained in:
XIGE
2026-11-29 23:09:39 +08:00
parent 1d355693be
commit e7089ae76b
6 changed files with 190 additions and 51 deletions

View File

@@ -116,23 +116,26 @@ class TaskAdapter(
)
title.setSpan(RelativeSizeSpan(0.95f), title.length - stars.length, title.length, 0)
// 「随时」任务:标题后带品牌蓝上箭头表示置顶,列表里排在未完成最前面。
// ↑ 字形窄、两侧留白大,全角空格会显得左边距比五角星宽,
// 改用细空格(U+2009)让两侧间隙与星标一致。
// 「随时」任务:标题后带品牌蓝圆圈上箭头表示置顶,列表里排在未完成最前面。
// 图标与重要度圆圈数字同规格(0.85 倍字号,圆圈里画向上箭头),
// 圆圈与箭头同色(品牌蓝);前面的细空格(U+2009)保持与星标的间距一致。
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
title.append("\u2009↑")
title.append("\u2009 ")
title.setSpan(
android.text.style.ForegroundColorSpan(ctx.col(R.color.brand)),
title.length - 2, title.length, 0
PinIconSpan(ctx.col(R.color.brand), tvTitle.textSize * 0.85f),
title.length - 1, title.length, 0,
)
title.setSpan(RelativeSizeSpan(0.85f), title.length - 2, title.length, 0)
}
tvTitle.text = title
tvTitle.paintFlags = if (task.done) {
tvTitle.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
} else {
tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
// 完成横线只画任务名本身(StrikethroughSpan 限定区间),
// 后面的重要度/紧急度/置顶图标不跟着划线
tvTitle.paintFlags = tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
if (task.done) {
title.setSpan(
android.text.style.StrikethroughSpan(),
0, task.title.length, 0,
)
}
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
@@ -203,3 +206,53 @@ class TaskAdapter(
private const val TYPE_FOOTER = 1
}
}
/**
* 置顶图标:圆圈内向上箭头。
* 自绘而不是用字体字形——常用字体里没有"圆圈+箭头"的组合字符,
* 画出来才能精确控制圆圈与箭头同色、且和重要度圆圈数字(0.85 倍字号)等高。
*/
private class PinIconSpan(
private val color: Int,
private val size: Float,
) : 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 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
}
canvas.drawCircle(cx, cy, s / 2f - p.strokeWidth / 2f, p)
// 向上箭头:竖杆 + 两条斜线,整体落在圆内
val head = s * 0.17f
val yTop = cy - s * 0.15f
val yBot = cy + s * 0.19f
canvas.drawLine(cx, yBot, cx, yTop, p)
canvas.drawLine(cx - head, yTop + head, cx, yTop, p)
canvas.drawLine(cx + head, yTop + head, cx, yTop, p)
}
}