From bebcd0edef5f14ace0d97c9786d57486667f0bef Mon Sep 17 00:00:00 2001 From: XIGE <710062962@qq.com> Date: Sun, 29 Nov 2026 11:30:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A5=BC=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E6=B3=A8=E9=87=8D=E5=8F=A0=EF=BC=9A=E5=91=A8=E6=9C=88=E5=B9=B4?= =?UTF-8?q?=E5=88=87=E7=89=87=E5=A4=9A=E6=97=B6=E9=97=B4=E8=B7=9D=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8E=8B=E7=BC=A9=EF=BC=8C=E4=B8=8D=E5=86=8D=E6=96=87?= =?UTF-8?q?=E5=AD=97=E6=95=B0=E5=AD=97=E9=87=8D=E5=90=88=EF=BC=88v0.14?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 +++ .../app/ui/settings/SettingsFragment.kt | 2 +- .../com/focusbox/app/widget/LabelDonutView.kt | 32 +++++++++++++++---- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1d097c..781f094 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # 变更记录 +## 2026-11-29 · 修复饼图标注重叠:周月年切片多时间距自动压缩,不再文字数字重合(v0.14) + +- 同步源码更新 2 个文件(新增/修改 2,删除 0)。 + ## 2026-11-29 · 常驻通知渠道改默认重要度(修复状态栏图标不显示);箭头细空格对齐;饼图标注墨迹对称(v0.13) - Notif:常驻渠道由 IMPORTANCE_LOW 换新 ID(timer_ongoing_v2)重建为 IMPORTANCE_DEFAULT 并删除旧渠道——低重要度通知在 Android 8+ 不显示状态栏顶部图标,渠道重要度创建后不可改;声音与振动仍全关 diff --git a/src/main/java/com/focusbox/app/ui/settings/SettingsFragment.kt b/src/main/java/com/focusbox/app/ui/settings/SettingsFragment.kt index 6dbb091..22f80fa 100644 --- a/src/main/java/com/focusbox/app/ui/settings/SettingsFragment.kt +++ b/src/main/java/com/focusbox/app/ui/settings/SettingsFragment.kt @@ -373,6 +373,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) { } companion object { - const val VERSION = "0.13" + const val VERSION = "0.14" } } diff --git a/src/main/java/com/focusbox/app/widget/LabelDonutView.kt b/src/main/java/com/focusbox/app/widget/LabelDonutView.kt index 1403e99..fda6930 100644 --- a/src/main/java/com/focusbox/app/widget/LabelDonutView.kt +++ b/src/main/java/com/focusbox/app/widget/LabelDonutView.kt @@ -199,22 +199,40 @@ class LabelDonutView @JvmOverloads constructor( /** 同侧标签按落点排序后做最小间距夹逼,再整体收回可视区 */ private fun layoutTags(tags: List) { - val minGap = context.dpf(29f) - // 上下留出两行字的高度:时间在 y 上方、名称在 y 下方,压到边界会被裁掉 val top = context.dpf(15f) val bottom = height - context.dpf(17f) + val avail = (bottom - top).coerceAtLeast(0f) + val ideal = context.dpf(29f) for (side in intArrayOf(-1, 1)) { val group = tags.filter { it.side == side }.sortedBy { it.anchorY } if (group.isEmpty()) continue + + // 理想间距 29dp;周/月/年切片多时一侧放不下, + // 按可用高度压缩间距(间距 = 可用高度 / 间隔数), + // 保证相邻标签永不重叠——原先"溢出整体上移+钳回边界" + // 会把多个标签压到同一 y,文字数字叠在一起。 + val minGap = if (group.size > 1) { + minOf(ideal, avail / (group.size - 1)) + } else ideal + group.forEachIndexed { i, t -> t.y = if (i == 0) maxOf(t.anchorY, top) else maxOf(t.anchorY, group[i - 1].y + minGap) } + // 少量溢出(间距未压缩仍超界):整体上移,首端不低于 top val overflow = group.last().y - bottom - if (overflow > 0f) group.forEach { it.y -= overflow } - // 极端情况下(标注多、控件矮)再压回上界,宁可间距略小也不出画布 - val lo = minOf(top, bottom) - val hi = maxOf(top, bottom) - group.forEach { it.y = it.y.coerceIn(lo, hi) } + if (overflow > 0f) { + group.forEach { it.y -= overflow } + if (group.first().y < top) { + // 上下都顶住仍放不下(极端小控件):在 [top, bottom] 内均匀铺开 + val n = group.size + if (n == 1) { + group[0].y = top + } else { + val step = avail / (n - 1) + group.forEachIndexed { i, t -> t.y = top + i * step } + } + } + } } }