修复负数计时回归:前台服务类型按版本显式选型;重要度改圆圈数字;置顶改上箭头(v0.10)
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# 变更记录
|
# 变更记录
|
||||||
|
|
||||||
|
## 2026-11-29 · 修复负数计时回归:前台服务类型按版本显式选型;重要度改圆圈数字;置顶改上箭头(v0.10)
|
||||||
|
|
||||||
|
- 同步源码更新 4 个文件(新增/修改 4,删除 0)。
|
||||||
|
|
||||||
## 2026-11-29 · 通知完成卡文案更新;已完成显示紧急度;饼图标注对称;热力图标签间距;重要度改竖线图标;重复新增随时置顶(v0.9)
|
## 2026-11-29 · 通知完成卡文案更新;已完成显示紧急度;饼图标注对称;热力图标签间距;重要度改竖线图标;重复新增随时置顶(v0.9)
|
||||||
|
|
||||||
- 通知/锁屏完成卡:「本轮完成」→「任务完成」;副文案改为「恭喜你,再接再厉,休息下再继续」(去掉休息分钟数参数)
|
- 通知/锁屏完成卡:「本轮完成」→「任务完成」;副文案改为「恭喜你,再接再厉,休息下再继续」(去掉休息分钟数参数)
|
||||||
|
|||||||
@@ -6,7 +6,11 @@
|
|||||||
拿不到时退化为窗口闹钟)。 -->
|
拿不到时退化为窗口闹钟)。 -->
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<!-- specialUse:Android 14 起 dataSync 类型有 24 小时 6 小时的累计上限,
|
<!-- specialUse:Android 14 起 dataSync 类型有 24 小时 6 小时的累计上限,
|
||||||
番茄钟连续衔接多轮会被强停;specialUse 没有这个限制。 -->
|
番茄钟连续衔接多轮会被强停;specialUse 没有这个限制。
|
||||||
|
但 specialUse 是 Android 14 才引入的类型,Android 12/13 不认识这个位,
|
||||||
|
startForeground 会被拒绝 → 计时冻结成负数。因此两种类型都声明:
|
||||||
|
运行时按系统版本选(<34 用 dataSync,>=34 用 specialUse)。 -->
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||||
@@ -39,7 +43,7 @@
|
|||||||
<service
|
<service
|
||||||
android:name=".service.TimerService"
|
android:name=".service.TimerService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:foregroundServiceType="specialUse">
|
android:foregroundServiceType="dataSync|specialUse">
|
||||||
<!-- Android 14 要求说明 specialUse 的具体用途;旧系统忽略此声明 -->
|
<!-- Android 14 要求说明 specialUse 的具体用途;旧系统忽略此声明 -->
|
||||||
<property
|
<property
|
||||||
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
|
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
|
||||||
|
|||||||
@@ -103,11 +103,18 @@ class TimerService : Service() {
|
|||||||
|
|
||||||
private fun startForegroundCompat() {
|
private fun startForegroundCompat() {
|
||||||
val notification = Notif.buildOngoing(this)
|
val notification = Notif.buildOngoing(this)
|
||||||
|
// 必须显式传类型:specialUse 是 Android 14 才引入的,
|
||||||
|
// Android 12/13 不认识清单里的这个类型位,两参版本(读清单)会被拒绝,
|
||||||
|
// 服务起不来 → 每秒 tick 停掉 → 息屏后到点无人结算,通知滚成负数。
|
||||||
|
// <34 用 dataSync(Android 12 原生支持,行为与历史版本一致);
|
||||||
|
// >=34 用 specialUse 规避 dataSync 的 24 小时 6 小时累计上限。
|
||||||
|
val type = if (android.os.Build.VERSION.SDK_INT >= 34) {
|
||||||
|
android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
||||||
|
} else {
|
||||||
|
android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
|
||||||
|
}
|
||||||
runCatching {
|
runCatching {
|
||||||
// 两参版本会读清单里声明的前台服务类型(specialUse)。
|
startForeground(Notif.ID_ONGOING, notification, type)
|
||||||
// 不用三参 + SPECIAL_USE:该类型 Android 14 才引入,
|
|
||||||
// 在 P30 的 Android 12 上传进去会直接抛 IllegalArgumentException。
|
|
||||||
startForeground(Notif.ID_ONGOING, notification)
|
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
// 前台服务被系统拒绝(省电策略/权限)时退化为普通服务,
|
// 前台服务被系统拒绝(省电策略/权限)时退化为普通服务,
|
||||||
// 计时本身仍在 TimerCore 里走,只是通知可能不显示。
|
// 计时本身仍在 TimerCore 里走,只是通知可能不显示。
|
||||||
|
|||||||
@@ -373,6 +373,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val VERSION = "0.9"
|
const val VERSION = "0.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,21 +85,22 @@ class TaskAdapter(
|
|||||||
val ctx = itemView.context
|
val ctx = itemView.context
|
||||||
|
|
||||||
// 标题右侧的属性图标,未完成与已完成都显示:
|
// 标题右侧的属性图标,未完成与已完成都显示:
|
||||||
// 重要度竖线(高3/中2/低1,颜色与紧急度同色系)→ 紧急度五角星 → 随时图钉。
|
// 重要度圆圈数字(③ 高 / ② 中 / ① 普通,颜色与紧急度同色系)→
|
||||||
|
// 紧急度五角星 → 随时上箭头。
|
||||||
// 用 spannable 保证图标紧贴标题而不是被推到行尾。
|
// 用 spannable 保证图标紧贴标题而不是被推到行尾。
|
||||||
val title = SpannableStringBuilder(task.title)
|
val title = SpannableStringBuilder(task.title)
|
||||||
|
|
||||||
val (bars, barColor) = when (task.priority) {
|
val (badge, badgeColor) = when (task.priority) {
|
||||||
2 -> " ▏▏▏" to R.color.urgent_high
|
2 -> " ③" to R.color.urgent_high
|
||||||
1 -> " ▏▏" to R.color.urgent_mid
|
1 -> " ②" to R.color.urgent_mid
|
||||||
else -> " ▏" to R.color.urgent_low
|
else -> " ①" to R.color.urgent_low
|
||||||
}
|
}
|
||||||
title.append(bars)
|
title.append(badge)
|
||||||
title.setSpan(
|
title.setSpan(
|
||||||
android.text.style.ForegroundColorSpan(ctx.col(barColor)),
|
android.text.style.ForegroundColorSpan(ctx.col(badgeColor)),
|
||||||
title.length - bars.length, title.length, 0
|
title.length - badge.length, title.length, 0
|
||||||
)
|
)
|
||||||
title.setSpan(RelativeSizeSpan(0.95f), title.length - bars.length, title.length, 0)
|
title.setSpan(RelativeSizeSpan(0.95f), title.length - badge.length, title.length, 0)
|
||||||
|
|
||||||
// 紧急度五角星:紧急三颗红 / 中两颗绿 / 不急一颗灰
|
// 紧急度五角星:紧急三颗红 / 中两颗绿 / 不急一颗灰
|
||||||
val (stars, starColor) = when (task.urgency) {
|
val (stars, starColor) = when (task.urgency) {
|
||||||
@@ -114,9 +115,14 @@ class TaskAdapter(
|
|||||||
)
|
)
|
||||||
title.setSpan(RelativeSizeSpan(0.95f), title.length - stars.length, title.length, 0)
|
title.setSpan(RelativeSizeSpan(0.95f), title.length - stars.length, title.length, 0)
|
||||||
|
|
||||||
// 「随时」任务:标题后带置顶图钉,列表里排在未完成最前面
|
// 「随时」任务:标题后带品牌蓝上箭头表示置顶,列表里排在未完成最前面
|
||||||
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
|
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
|
||||||
title.append(" 📌")
|
title.append(" ↑")
|
||||||
|
title.setSpan(
|
||||||
|
android.text.style.ForegroundColorSpan(ctx.col(R.color.brand)),
|
||||||
|
title.length - 2, title.length, 0
|
||||||
|
)
|
||||||
|
title.setSpan(RelativeSizeSpan(0.95f), title.length - 2, title.length, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
tvTitle.text = title
|
tvTitle.text = title
|
||||||
|
|||||||
Reference in New Issue
Block a user