修复:移除常驻通知底部模板按钮;提前完成只留带备注记录、隐藏无备注源任务行(v0.8)
This commit is contained in:
@@ -308,6 +308,24 @@ object Store {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 已被"提前完成"关闭的源任务 id 集合。
|
||||
*
|
||||
* 提前完成 = 源任务标记已完成 + 一条带备注的独立完成记录(origin_id 指回源任务),
|
||||
* 列表里只应显示带备注的记录那条;完成记录的特征是 repeat_type = 0
|
||||
* (重复任务实例虽然也有 origin_id,但 repeat_type > 0,不会误伤)。
|
||||
*/
|
||||
fun completedSourceIds(): Set<Long> {
|
||||
val ids = HashSet<Long>()
|
||||
db.rawQuery(
|
||||
"SELECT DISTINCT origin_id FROM tasks WHERE done = 1 AND origin_id > 0 AND repeat_type = 0",
|
||||
null,
|
||||
).use { c ->
|
||||
while (c.moveToNext()) ids.add(c.getLong(0))
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次专注结束 = 一条独立的完成任务记录。
|
||||
*
|
||||
|
||||
@@ -129,29 +129,8 @@ object Notif {
|
||||
)
|
||||
b.setCustomContentView(rv)
|
||||
b.setCustomBigContentView(rv)
|
||||
|
||||
// 模板动作保留作兜底(自定义布局生效时系统不会重复绘制这两颗按钮)。
|
||||
// 文字必须有:屏幕朗读器读兜底动作时靠它提供语义。
|
||||
if (TimerCore.mode == TimerCore.MODE_FOCUS) {
|
||||
b.addAction(
|
||||
NotificationCompat.Action(
|
||||
if (running) R.drawable.ic_pause else R.drawable.ic_play,
|
||||
context.getString(if (running) R.string.notif_action_pause else R.string.notif_action_resume),
|
||||
serviceAction(
|
||||
context,
|
||||
if (running) TimerService.ACTION_PAUSE else TimerService.ACTION_RESUME,
|
||||
21,
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
b.addAction(
|
||||
NotificationCompat.Action(
|
||||
R.drawable.ic_stop,
|
||||
context.getString(R.string.notif_action_stop),
|
||||
serviceAction(context, TimerService.ACTION_STOP, 23),
|
||||
)
|
||||
)
|
||||
// 不加模板 Action:暂停/结束按钮只保留自定义布局右侧的两颗,
|
||||
// 模板按钮会在通知下方再画一排,重复且占屏。
|
||||
return b.build()
|
||||
}
|
||||
|
||||
|
||||
@@ -373,6 +373,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "0.7"
|
||||
const val VERSION = "0.8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,8 +125,10 @@ class TasksFragment : Fragment(R.layout.fragment_tasks) {
|
||||
|
||||
val all = Store.tasks(includeDone = true)
|
||||
val spans = if (all.any { it.done }) Store.lastSessions() else emptyMap()
|
||||
// 提前完成的任务:源任务行(无备注)隐藏,只显示带备注的独立完成记录
|
||||
val finishedIds = Store.completedSourceIds()
|
||||
|
||||
val matched = all.filter { matches(it) }
|
||||
val matched = all.filter { matches(it) && !(it.done && it.id in finishedIds) }
|
||||
val rows = ArrayList<TaskAdapter.Row>(matched.size)
|
||||
matched.forEach { rows.add(toRow(it, spans)) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user