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 } + } + } + } } }