精简选任务弹层提示与项目行缩进;环图加粗留边距;通知图标常驻;统计标题样式统一

This commit is contained in:
XIGE
2026-11-28 07:54:05 +08:00
parent 0708569013
commit 1abf44296a
9 changed files with 56 additions and 22 deletions

View File

@@ -1,5 +1,9 @@
# 变更记录 # 变更记录
## 2026-11-28 · 精简选任务弹层提示与项目行缩进;环图加粗留边距;通知图标常驻;统计标题样式统一
- 同步源码更新 8 个文件(新增/修改 8,删除 0)。
## 2026-11-28 · v0.4.1:任务选择两步式、深色新增按钮、统计文案与热力图 ## 2026-11-28 · v0.4.1:任务选择两步式、深色新增按钮、统计文案与热力图
- **首页「选择任务」改为自绘底部弹层**(替代系统 AlertDialog): - **首页「选择任务」改为自绘底部弹层**(替代系统 AlertDialog):

View File

@@ -89,8 +89,8 @@ object Notif {
?: context.getString(R.string.notif_no_task) ?: context.getString(R.string.notif_no_task)
val b = NotificationCompat.Builder(context, CHANNEL_TIMER) val b = NotificationCompat.Builder(context, CHANNEL_TIMER)
// 透明小图标:状态栏与通知左侧不再出现应用图标 // 常驻可见的白色秒表图标:透明图标在 EMUI 上会时隐时现,不能保证状态栏一直有提示
.setSmallIcon(R.drawable.ic_notif_blank) .setSmallIcon(R.drawable.ic_notif)
.setContentIntent(contentIntent(context)) .setContentIntent(contentIntent(context))
.setOngoing(true) .setOngoing(true)
.setOnlyAlertOnce(true) .setOnlyAlertOnce(true)

View File

@@ -416,6 +416,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
val tvTitle = root.findViewById<TextView>(R.id.pickTitle) val tvTitle = root.findViewById<TextView>(R.id.pickTitle)
val tvStep = root.findViewById<TextView>(R.id.pickStep) val tvStep = root.findViewById<TextView>(R.id.pickStep)
val tvHint = root.findViewById<TextView>(R.id.pickHint) val tvHint = root.findViewById<TextView>(R.id.pickHint)
tvHint.visibility = View.GONE // 两步都只留标题与列表,不再占一行说明文字
val btnBack = root.findViewById<ImageView>(R.id.pickBack) val btnBack = root.findViewById<ImageView>(R.id.pickBack)
val btnClose = root.findViewById<ImageView>(R.id.pickClose) val btnClose = root.findViewById<ImageView>(R.id.pickClose)
val btnClear = root.findViewById<TextView>(R.id.pickClear) val btnClear = root.findViewById<TextView>(R.id.pickClear)
@@ -427,12 +428,15 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
meta: String, meta: String,
color: Int?, color: Int?,
selected: Boolean, selected: Boolean,
alignLeft: Boolean = false,
onClick: () -> Unit, onClick: () -> Unit,
) { ) {
val row = layoutInflater.inflate(R.layout.item_pick_row, list, false) val row = layoutInflater.inflate(R.layout.item_pick_row, list, false)
row.findViewById<View>(R.id.rowDot).apply { val dot = row.findViewById<View>(R.id.rowDot)
visible(color != null) dot.visible(!alignLeft && color != null)
if (color != null) background = ctx.circleBg(color) 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.rowTitle).text = title
row.findViewById<TextView>(R.id.rowMeta).text = meta row.findViewById<TextView>(R.id.rowMeta).text = meta
@@ -452,7 +456,6 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
val project = Store.project(projectId) val project = Store.project(projectId)
tvTitle.text = project?.name ?: getString(R.string.inbox) tvTitle.text = project?.name ?: getString(R.string.inbox)
tvStep.text = getString(R.string.pick_step, 2) tvStep.text = getString(R.string.pick_step, 2)
tvHint.text = getString(R.string.pick_task_hint)
btnBack.visibility = View.VISIBLE btnBack.visibility = View.VISIBLE
btnClear.visibility = View.VISIBLE btnClear.visibility = View.VISIBLE
list.removeAllViews() list.removeAllViews()
@@ -490,7 +493,6 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
fun showProjects() { fun showProjects() {
tvTitle.text = getString(R.string.pick_project) tvTitle.text = getString(R.string.pick_project)
tvStep.text = getString(R.string.pick_step, 1) tvStep.text = getString(R.string.pick_step, 1)
tvHint.text = getString(R.string.pick_project_hint)
btnBack.visibility = View.INVISIBLE btnBack.visibility = View.INVISIBLE
btnClear.visibility = View.GONE btnClear.visibility = View.GONE
list.removeAllViews() list.removeAllViews()
@@ -501,6 +503,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
meta = getString(R.string.pick_project_meta, p.openTasks), meta = getString(R.string.pick_project_meta, p.openTasks),
color = p.color, color = p.color,
selected = p.id == currentPid, selected = p.id == currentPid,
alignLeft = true, // 项目列表不要左侧色点缩进,名称贴左对齐
) { showTasks(p.id) } ) { showTasks(p.id) }
} }
scroll.scrollTo(0, 0) scroll.scrollTo(0, 0)

View File

@@ -53,7 +53,7 @@ class LabelDonutView @JvmOverloads constructor(
/** 最多画几条引线标注,多出来的合并成「其他」,避免标注挤成一团 */ /** 最多画几条引线标注,多出来的合并成「其他」,避免标注挤成一团 */
var maxLabels: Int = 6 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 { private val arcPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
style = Paint.Style.STROKE style = Paint.Style.STROKE
@@ -66,7 +66,7 @@ class LabelDonutView @JvmOverloads constructor(
color = context.col(R.color.ring_track) color = context.col(R.color.ring_track)
} }
private val pctPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { private val pctPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
textSize = context.spf(10f) textSize = context.spf(11f)
textAlign = Paint.Align.CENTER textAlign = Paint.Align.CENTER
isFakeBoldText = true isFakeBoldText = true
} }
@@ -137,18 +137,21 @@ class LabelDonutView @JvmOverloads constructor(
canvas.drawArc(box, start + gapDeg / 2f, (sweep - gapDeg).coerceAtLeast(0.5f), false, arcPaint) canvas.drawArc(box, start + gapDeg / 2f, (sweep - gapDeg).coerceAtLeast(0.5f), false, arcPaint)
val arcLen = sweep / 360f * (2 * Math.PI.toFloat() * r) 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 rad = Math.toRadians(midDeg.toDouble())
val px = cx + r * cos(rad).toFloat() val px = cx + r * cos(rad).toFloat()
val py = cy + r * sin(rad).toFloat() val py = cy + r * sin(rad).toFloat()
pctPaint.color = readableOn(s.color) pctPaint.color = readableOn(s.color)
val fm = pctPaint.fontMetrics val fm = pctPaint.fontMetrics
canvas.drawText( canvas.drawText(pct, px, py - (fm.ascent + fm.descent) / 2f, pctPaint)
"${(s.seconds * 100f / total).toInt().coerceAtLeast(1)}%",
px,
py - (fm.ascent + fm.descent) / 2f,
pctPaint,
)
} }
// 太薄的扇区不牵线,否则几条线会叠在同一个点上 // 太薄的扇区不牵线,否则几条线会叠在同一个点上
@@ -220,7 +223,8 @@ class LabelDonutView @JvmOverloads constructor(
val color = tag.slice.color val color = tag.slice.color
val dotR = context.dpf(2.6f) val dotR = context.dpf(2.6f)
val dotX = if (side > 0) width - context.dpf(3f) - dotR else context.dpf(3f) + dotR 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 cosA = cos(radians(tag.midDeg)).toFloat()
val sinA = sin(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) canvas.drawCircle(dotX, tag.y, dotR, dotPaint)
val textX = dotX - side * context.dpf(9f) 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)) .coerceAtLeast(context.dpf(20f))
tagValuePaint.color = color tagValuePaint.color = color

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
状态栏小图标:Android 5.0+ 会把非透明像素统一染白,
这里用实心秒表轮廓,保证 EMUI 状态栏常驻可见,不再时有时无。
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,2a10,10 0 1,0 0,20a10,10 0 1,0 0,-20zM12,4.5a7.5,7.5 0 1,1 0,15a7.5,7.5 0 0,1 0,-15zM12,6.5h1.8v6.3l4.2,2.5 -0.9,1.5 -5.1,-3.1z" />
</vector>

View File

@@ -189,7 +189,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/trend_title" android:text="@string/trend_title"
style="@style/T.Section" /> style="@style/T.CardTitle" />
<TextView <TextView
android:id="@+id/tvTrendTotal" android:id="@+id/tvTrendTotal"
@@ -225,7 +225,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/heatmap_title" android:text="@string/heatmap_title"
style="@style/T.Section" /> style="@style/T.CardTitle" />
<TextView <TextView
android:id="@+id/tvHeatHint" android:id="@+id/tvHeatHint"
@@ -277,7 +277,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/summary_title" android:text="@string/summary_title"
style="@style/T.Section" /> style="@style/T.CardTitle" />
<LinearLayout <LinearLayout
android:id="@+id/summaryGrid" android:id="@+id/summaryGrid"

View File

@@ -17,6 +17,7 @@
android:layout_height="10dp" /> android:layout_height="10dp" />
<LinearLayout <LinearLayout
android:id="@+id/rowInfo"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"

View File

@@ -111,7 +111,7 @@
<string name="goal_progress">今日目标 %1$d%%</string> <string name="goal_progress">今日目标 %1$d%%</string>
<string name="goal_short">%1$dM</string> <string name="goal_short">%1$dM</string>
<string name="trend_title">专注趋势</string> <string name="trend_title">专注趋势</string>
<string name="heatmap_title">打卡热力图</string> <string name="heatmap_title">专注频率</string>
<string name="distribution_title">项目分布</string> <string name="distribution_title">项目分布</string>
<string name="task_distribution_title">任务分布</string> <string name="task_distribution_title">任务分布</string>
<string name="task_share">任务占比</string> <string name="task_share">任务占比</string>

View File

@@ -31,6 +31,14 @@
<item name="android:includeFontPadding">false</item> <item name="android:includeFontPadding">false</item>
</style> </style>
<!-- 统计页卡片标题:与 PeriodDistributionCard 自绘的标题完全一致 -->
<style name="T.CardTitle">
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/title</item>
<item name="android:textStyle">bold</item>
<item name="android:includeFontPadding">false</item>
</style>
<style name="T.Section"> <style name="T.Section">
<item name="android:textSize">13sp</item> <item name="android:textSize">13sp</item>
<item name="android:textColor">@color/text_secondary</item> <item name="android:textColor">@color/text_secondary</item>