精简选任务弹层提示与项目行缩进;环图加粗留边距;通知图标常驻;统计标题样式统一
This commit is contained in:
@@ -89,8 +89,8 @@ object Notif {
|
||||
?: context.getString(R.string.notif_no_task)
|
||||
|
||||
val b = NotificationCompat.Builder(context, CHANNEL_TIMER)
|
||||
// 透明小图标:状态栏与通知左侧不再出现应用图标
|
||||
.setSmallIcon(R.drawable.ic_notif_blank)
|
||||
// 常驻可见的白色秒表图标:透明图标在 EMUI 上会时隐时现,不能保证状态栏一直有提示
|
||||
.setSmallIcon(R.drawable.ic_notif)
|
||||
.setContentIntent(contentIntent(context))
|
||||
.setOngoing(true)
|
||||
.setOnlyAlertOnce(true)
|
||||
|
||||
@@ -416,6 +416,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
||||
val tvTitle = root.findViewById<TextView>(R.id.pickTitle)
|
||||
val tvStep = root.findViewById<TextView>(R.id.pickStep)
|
||||
val tvHint = root.findViewById<TextView>(R.id.pickHint)
|
||||
tvHint.visibility = View.GONE // 两步都只留标题与列表,不再占一行说明文字
|
||||
val btnBack = root.findViewById<ImageView>(R.id.pickBack)
|
||||
val btnClose = root.findViewById<ImageView>(R.id.pickClose)
|
||||
val btnClear = root.findViewById<TextView>(R.id.pickClear)
|
||||
@@ -427,12 +428,15 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
||||
meta: String,
|
||||
color: Int?,
|
||||
selected: Boolean,
|
||||
alignLeft: Boolean = false,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
val row = layoutInflater.inflate(R.layout.item_pick_row, list, false)
|
||||
row.findViewById<View>(R.id.rowDot).apply {
|
||||
visible(color != null)
|
||||
if (color != null) background = ctx.circleBg(color)
|
||||
val dot = row.findViewById<View>(R.id.rowDot)
|
||||
dot.visible(!alignLeft && color != null)
|
||||
if (color != null) dot.background = ctx.circleBg(color)
|
||||
(row.findViewById<View>(R.id.rowInfo).layoutParams as LinearLayout.LayoutParams).apply {
|
||||
marginStart = if (alignLeft || color == null) 0 else dpi(12f)
|
||||
}
|
||||
row.findViewById<TextView>(R.id.rowTitle).text = title
|
||||
row.findViewById<TextView>(R.id.rowMeta).text = meta
|
||||
@@ -452,7 +456,6 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
||||
val project = Store.project(projectId)
|
||||
tvTitle.text = project?.name ?: getString(R.string.inbox)
|
||||
tvStep.text = getString(R.string.pick_step, 2)
|
||||
tvHint.text = getString(R.string.pick_task_hint)
|
||||
btnBack.visibility = View.VISIBLE
|
||||
btnClear.visibility = View.VISIBLE
|
||||
list.removeAllViews()
|
||||
@@ -490,7 +493,6 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
||||
fun showProjects() {
|
||||
tvTitle.text = getString(R.string.pick_project)
|
||||
tvStep.text = getString(R.string.pick_step, 1)
|
||||
tvHint.text = getString(R.string.pick_project_hint)
|
||||
btnBack.visibility = View.INVISIBLE
|
||||
btnClear.visibility = View.GONE
|
||||
list.removeAllViews()
|
||||
@@ -501,6 +503,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
||||
meta = getString(R.string.pick_project_meta, p.openTasks),
|
||||
color = p.color,
|
||||
selected = p.id == currentPid,
|
||||
alignLeft = true, // 项目列表不要左侧色点缩进,名称贴左对齐
|
||||
) { showTasks(p.id) }
|
||||
}
|
||||
scroll.scrollTo(0, 0)
|
||||
|
||||
@@ -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