常驻通知渠道改默认重要度(修复状态栏图标不显示);箭头细空格对齐;饼图标注墨迹对称(v0.13)
This commit is contained in:
@@ -24,7 +24,11 @@ import com.focusbox.app.util.Dates
|
||||
*/
|
||||
object Notif {
|
||||
|
||||
const val CHANNEL_TIMER = "timer_ongoing"
|
||||
// v2:旧渠道 timer_ongoing 建成了 IMPORTANCE_LOW(静默),Android 8 起低重要度
|
||||
// 通知不在状态栏显示顶部图标、只进抽屉;渠道重要度创建后不可修改,
|
||||
// 只能换新 ID 重建并删除旧渠道。
|
||||
const val CHANNEL_TIMER = "timer_ongoing_v2"
|
||||
private const val LEGACY_CHANNEL_TIMER = "timer_ongoing"
|
||||
const val CHANNEL_ALERT = "timer_alert"
|
||||
|
||||
const val ID_ONGOING = 1001
|
||||
@@ -34,10 +38,14 @@ object Notif {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
|
||||
val nm = context.getSystemService(NotificationManager::class.java) ?: return
|
||||
|
||||
// 删掉旧的低重要度渠道(它导致状态栏顶部图标不显示)
|
||||
nm.deleteNotificationChannel(LEGACY_CHANNEL_TIMER)
|
||||
|
||||
// 默认重要度:状态栏图标常驻;声音与振动仍全关,不会打扰
|
||||
val ongoing = NotificationChannel(
|
||||
CHANNEL_TIMER,
|
||||
context.getString(R.string.notif_channel),
|
||||
NotificationManager.IMPORTANCE_LOW,
|
||||
NotificationManager.IMPORTANCE_DEFAULT,
|
||||
).apply {
|
||||
description = context.getString(R.string.notif_channel_desc)
|
||||
setShowBadge(false)
|
||||
@@ -94,9 +102,8 @@ object Notif {
|
||||
.setContentIntent(contentIntent(context))
|
||||
.setOngoing(true)
|
||||
.setOnlyAlertOnce(true)
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
.setSilent(true)
|
||||
// 系统模板的"应用名 + 时间"行不需要,时间由自定义布局里的 Chronometer 承担
|
||||
.setShowWhen(false)
|
||||
// 模板兜底:ROM 若不支持自定义布局,至少还有任务名与读数
|
||||
|
||||
@@ -373,6 +373,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "0.12"
|
||||
const val VERSION = "0.13"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,9 +116,11 @@ class TaskAdapter(
|
||||
)
|
||||
title.setSpan(RelativeSizeSpan(0.95f), title.length - stars.length, title.length, 0)
|
||||
|
||||
// 「随时」任务:标题后带品牌蓝上箭头表示置顶,列表里排在未完成最前面
|
||||
// 「随时」任务:标题后带品牌蓝上箭头表示置顶,列表里排在未完成最前面。
|
||||
// ↑ 字形窄、两侧留白大,全角空格会显得左边距比五角星宽,
|
||||
// 改用细空格(U+2009)让两侧间隙与星标一致。
|
||||
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
|
||||
title.append(" ↑")
|
||||
title.append("\u2009↑")
|
||||
title.setSpan(
|
||||
android.text.style.ForegroundColorSpan(ctx.col(R.color.brand)),
|
||||
title.length - 2, title.length, 0
|
||||
|
||||
@@ -254,13 +254,19 @@ class LabelDonutView @JvmOverloads constructor(
|
||||
tag.slice.name, tagNamePaint, maxW, TextUtils.TruncateAt.END,
|
||||
).toString()
|
||||
|
||||
// 时间与任务名分别落在引线上、下方,两段间隙取同一值(4dp),
|
||||
// 按各自字体的 descent / ascent 反推基线,保证视觉上下对称
|
||||
// 时间与任务名分别落在引线上、下方。之前按 fontMetrics(descent/ascent)定位,
|
||||
// 但数字的字面底部远高于 descent 线、汉字顶部也和 ascent 有出入,
|
||||
// 视觉上"时间离线远、任务名离线近"。改为按实际墨迹边界(getTextBounds)
|
||||
// 定位,两侧的墨迹间隙严格相等。
|
||||
val gap = context.dpf(4f)
|
||||
val vfm = tagValuePaint.fontMetrics
|
||||
val nfm = tagNamePaint.fontMetrics
|
||||
canvas.drawText(value, textX, tag.y - gap - vfm.descent, tagValuePaint)
|
||||
canvas.drawText(name, textX, tag.y + gap - nfm.ascent, tagNamePaint)
|
||||
val vBounds = android.graphics.Rect()
|
||||
val nBounds = android.graphics.Rect()
|
||||
tagValuePaint.getTextBounds(value, 0, value.length, vBounds)
|
||||
tagNamePaint.getTextBounds(name, 0, name.length, nBounds)
|
||||
// vBounds.bottom:数字墨迹底部相对基线的偏移(≈0,正值向下)
|
||||
// nBounds.top:汉字墨迹顶部相对基线的偏移(负值向上)
|
||||
canvas.drawText(value, textX, tag.y - gap - vBounds.bottom.toFloat(), tagValuePaint)
|
||||
canvas.drawText(name, textX, tag.y + gap - nBounds.top.toFloat(), tagNamePaint)
|
||||
}
|
||||
|
||||
/** 环上的百分比文字:底色偏亮时改黑字,否则看不出来 */
|
||||
|
||||
Reference in New Issue
Block a user