图标间距减半与逾期任务过滤(v3.3)
This commit is contained in:
@@ -71,6 +71,15 @@ class TaskAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 标题与图标之间的间距:旧版用三个空格,视觉偏宽。
|
||||
* 改用无字形占位,宽度精确等于三个空格的一半,避免随字体变化忽大忽小。
|
||||
*/
|
||||
private fun appendIconGap(title: SpannableStringBuilder) {
|
||||
title.append(" ")
|
||||
title.setSpan(IconGapSpan(), title.length - 1, title.length, 0)
|
||||
}
|
||||
|
||||
private inner class TaskViewHolder(v: View) : RecyclerView.ViewHolder(v) {
|
||||
private val tvTitle: TextView = v.findViewById(R.id.tvTitle)
|
||||
private val tvMeta: TextView = v.findViewById(R.id.tvMeta)
|
||||
@@ -93,7 +102,7 @@ class TaskAdapter(
|
||||
|
||||
// 置顶图标前移到重要度圆圈之前(品牌蓝圆圈内向上箭头)
|
||||
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
|
||||
title.append(" ")
|
||||
appendIconGap(title)
|
||||
title.setSpan(
|
||||
PinIconSpan(ctx.col(R.color.brand), iconSize),
|
||||
title.length - 1, title.length, 0,
|
||||
@@ -106,8 +115,8 @@ class TaskAdapter(
|
||||
1 -> "2" to R.color.urgent_mid
|
||||
else -> "1" to R.color.urgent_low
|
||||
}
|
||||
// 与标题、与置顶圆圈各留两个可见空格的间距,避免图标贴在一起
|
||||
title.append(" ")
|
||||
// 与标题、与置顶圆圈各留半个旧间距,避免图标贴在一起又不显得散
|
||||
appendIconGap(title)
|
||||
title.setSpan(
|
||||
PriorityBadgeSpan(ctx.col(badgeColor), iconSize, digit),
|
||||
title.length - 1, title.length, 0,
|
||||
@@ -205,6 +214,22 @@ class TaskAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 图标间距占位:宽度等于旧版三个空格的一半,且不绘制任何字形。
|
||||
* 用 ReplacementSpan 而不是固定 dp,间距会随字号等比缩放。
|
||||
*/
|
||||
private class IconGapSpan : android.text.style.ReplacementSpan() {
|
||||
|
||||
override fun getSize(
|
||||
paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?,
|
||||
): Int = (paint.measureText(" ") / 2f).toInt().coerceAtLeast(1)
|
||||
|
||||
override fun draw(
|
||||
canvas: android.graphics.Canvas, text: CharSequence, start: Int, end: Int,
|
||||
x: Float, top: Int, baseline: Int, bottom: Int, paint: Paint,
|
||||
) = Unit
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务名删除线:系统 StrikethroughSpan 的划线位置按"字体半高"(baseline + ascent/2)
|
||||
* 计算,但数字/汉字的实际墨迹顶比字体 ascent 低不少,划线视觉上偏下。
|
||||
|
||||
Reference in New Issue
Block a user