精简选任务弹层提示与项目行缩进;环图加粗留边距;通知图标常驻;统计标题样式统一
This commit is contained in:
@@ -53,7 +53,7 @@ class LabelDonutView @JvmOverloads constructor(
|
||||
/** 最多画几条引线标注,多出来的合并成「其他」,避免标注挤成一团 */
|
||||
var maxLabels: Int = 6
|
||||
|
||||
private val strokeW = context.dpf(15f)
|
||||
private val strokeW = context.dpf(22f)
|
||||
|
||||
private val arcPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||
style = Paint.Style.STROKE
|
||||
@@ -66,7 +66,7 @@ class LabelDonutView @JvmOverloads constructor(
|
||||
color = context.col(R.color.ring_track)
|
||||
}
|
||||
private val pctPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||
textSize = context.spf(10f)
|
||||
textSize = context.spf(11f)
|
||||
textAlign = Paint.Align.CENTER
|
||||
isFakeBoldText = true
|
||||
}
|
||||
@@ -137,18 +137,21 @@ class LabelDonutView @JvmOverloads constructor(
|
||||
canvas.drawArc(box, start + gapDeg / 2f, (sweep - gapDeg).coerceAtLeast(0.5f), false, arcPaint)
|
||||
|
||||
val arcLen = sweep / 360f * (2 * Math.PI.toFloat() * r)
|
||||
if (arcLen >= context.dpf(20f)) {
|
||||
val pct = "${(s.seconds * 100f / total).toInt().coerceAtLeast(1)}%"
|
||||
// 环加粗后百分比必须完整落在色带里:按实测字宽缩字号,左右各留 3dp 边距
|
||||
var pctSize = 11f
|
||||
pctPaint.textSize = context.spf(pctSize)
|
||||
while (pctPaint.measureText(pct) > arcLen - context.dpf(6f) && pctSize > 8f) {
|
||||
pctSize -= 0.5f
|
||||
pctPaint.textSize = context.spf(pctSize)
|
||||
}
|
||||
if (arcLen >= pctPaint.measureText(pct) + context.dpf(4f)) {
|
||||
val rad = Math.toRadians(midDeg.toDouble())
|
||||
val px = cx + r * cos(rad).toFloat()
|
||||
val py = cy + r * sin(rad).toFloat()
|
||||
pctPaint.color = readableOn(s.color)
|
||||
val fm = pctPaint.fontMetrics
|
||||
canvas.drawText(
|
||||
"${(s.seconds * 100f / total).toInt().coerceAtLeast(1)}%",
|
||||
px,
|
||||
py - (fm.ascent + fm.descent) / 2f,
|
||||
pctPaint,
|
||||
)
|
||||
canvas.drawText(pct, px, py - (fm.ascent + fm.descent) / 2f, pctPaint)
|
||||
}
|
||||
|
||||
// 太薄的扇区不牵线,否则几条线会叠在同一个点上
|
||||
@@ -220,7 +223,8 @@ class LabelDonutView @JvmOverloads constructor(
|
||||
val color = tag.slice.color
|
||||
val dotR = context.dpf(2.6f)
|
||||
val dotX = if (side > 0) width - context.dpf(3f) - dotR else context.dpf(3f) + dotR
|
||||
val kneeX = cx + side * (r + context.dpf(13f))
|
||||
// 折点落在环外缘再往外 10dp,环加粗后引线不会压在色带上
|
||||
val kneeX = cx + side * (r + strokeW / 2f + context.dpf(10f))
|
||||
|
||||
val cosA = cos(radians(tag.midDeg)).toFloat()
|
||||
val sinA = sin(radians(tag.midDeg)).toFloat()
|
||||
@@ -237,7 +241,7 @@ class LabelDonutView @JvmOverloads constructor(
|
||||
canvas.drawCircle(dotX, tag.y, dotR, dotPaint)
|
||||
|
||||
val textX = dotX - side * context.dpf(9f)
|
||||
val maxW = (kotlin.math.abs(textX - (cx + side * (r + strokeW))) - context.dpf(6f))
|
||||
val maxW = (kotlin.math.abs(textX - (cx + side * (r + strokeW / 2f))) - context.dpf(8f))
|
||||
.coerceAtLeast(context.dpf(20f))
|
||||
|
||||
tagValuePaint.color = color
|
||||
|
||||
Reference in New Issue
Block a user