常驻通知渠道改默认重要度(修复状态栏图标不显示);箭头细空格对齐;饼图标注墨迹对称(v0.13)

This commit is contained in:
XIGE
2026-11-29 11:09:43 +08:00
parent cc9cb506dc
commit 42d97d82f0
5 changed files with 32 additions and 13 deletions

View File

@@ -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 若不支持自定义布局,至少还有任务名与读数