右侧按钮改为完成并加入原因弹层;已完成任务显示真实时长;删除首页说明;修复审查发现的计时与数据缺陷
This commit is contained in:
@@ -27,7 +27,7 @@ object Store {
|
||||
const val INBOX_ID = 1L
|
||||
|
||||
private const val DB_NAME = "focusbox.db"
|
||||
private const val DB_VERSION = 2
|
||||
private const val DB_VERSION = 3
|
||||
|
||||
private lateinit var helper: Helper
|
||||
|
||||
@@ -68,7 +68,8 @@ object Store {
|
||||
sort INTEGER NOT NULL DEFAULT 0,
|
||||
focus_min INTEGER NOT NULL DEFAULT 25,
|
||||
repeat_type INTEGER NOT NULL DEFAULT 0,
|
||||
repeat_every INTEGER NOT NULL DEFAULT 1
|
||||
repeat_every INTEGER NOT NULL DEFAULT 1,
|
||||
origin_id INTEGER NOT NULL DEFAULT 0
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
@@ -104,6 +105,10 @@ object Store {
|
||||
db.execSQL("ALTER TABLE tasks ADD COLUMN repeat_every INTEGER NOT NULL DEFAULT 1")
|
||||
db.execSQL("UPDATE tasks SET focus_min = est_pomodoros * 25 WHERE est_pomodoros > 0")
|
||||
}
|
||||
// v2 → v3:记录重复任务的来源,取消完成时能精确删掉自动生成的新一条
|
||||
if (oldVersion < 3) {
|
||||
db.execSQL("ALTER TABLE tasks ADD COLUMN origin_id INTEGER NOT NULL DEFAULT 0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,6 +273,7 @@ object Store {
|
||||
*/
|
||||
fun setTaskDone(id: Long, done: Boolean) {
|
||||
if (!done) {
|
||||
val t = task(id)
|
||||
db.update(
|
||||
"tasks",
|
||||
ContentValues().apply {
|
||||
@@ -276,6 +282,14 @@ object Store {
|
||||
},
|
||||
"_id = ?", arrayOf(id.toString())
|
||||
)
|
||||
// 撤销重复任务时,上次勾选自动生成的新一条要一起撤掉,否则清单会多出一条
|
||||
if (t != null && t.repeating) {
|
||||
db.delete(
|
||||
"tasks",
|
||||
"origin_id = ? AND done = 0 AND _id != ?",
|
||||
arrayOf(id.toString(), id.toString())
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
val t = task(id) ?: return
|
||||
@@ -298,7 +312,7 @@ object Store {
|
||||
if (next == base) return
|
||||
// 下一次的截止日至少比今天晚一天,否则刚生成就会显示"已逾期"
|
||||
val due = if (next <= Dates.todayStart()) Dates.addDays(Dates.todayStart(), 1) else next
|
||||
addTask(
|
||||
val childId = addTask(
|
||||
title = t.title,
|
||||
note = t.note,
|
||||
projectId = t.projectId,
|
||||
@@ -308,6 +322,13 @@ object Store {
|
||||
repeatType = t.repeatType,
|
||||
repeatEvery = t.repeatEvery,
|
||||
)
|
||||
if (childId > 0) {
|
||||
db.update(
|
||||
"tasks",
|
||||
ContentValues().apply { put("origin_id", t.id) },
|
||||
"_id = ?", arrayOf(childId.toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** 把日期按重复规则往后推一个周期 */
|
||||
@@ -539,7 +560,7 @@ object Store {
|
||||
val map = HashMap<Long, SessionSpan>()
|
||||
db.rawQuery(
|
||||
"""
|
||||
SELECT s.task_id, s.start_at, s.end_at FROM sessions s
|
||||
SELECT s.task_id, s.start_at, s.end_at, s.seconds FROM sessions s
|
||||
JOIN (
|
||||
SELECT task_id, MAX(end_at) AS max_end FROM sessions
|
||||
WHERE task_id > 0 GROUP BY task_id
|
||||
@@ -549,7 +570,7 @@ object Store {
|
||||
).use { c ->
|
||||
while (c.moveToNext()) {
|
||||
val id = c.getLong(0)
|
||||
if (!map.containsKey(id)) map[id] = SessionSpan(c.getLong(1), c.getLong(2))
|
||||
if (!map.containsKey(id)) map[id] = SessionSpan(c.getLong(1), c.getLong(2), c.getInt(3))
|
||||
}
|
||||
}
|
||||
return map
|
||||
@@ -609,6 +630,8 @@ object Store {
|
||||
db.delete("sessions", null, null)
|
||||
db.delete("tasks", null, null)
|
||||
db.delete("projects", null, null)
|
||||
// 不清自增序列的话,清空后第一个项目 id 会继续往上跑,永远不再是收件箱的 1
|
||||
db.delete("sqlite_sequence", "name IN (?,?,?)", arrayOf("projects", "tasks", "sessions"))
|
||||
db.execSQL(
|
||||
"INSERT INTO projects (name, color, archived, sort, created_at) VALUES (?,?,?,?,?)",
|
||||
arrayOf<Any>("收件箱", 0xFF7A756C.toInt(), 0, 0, System.currentTimeMillis())
|
||||
|
||||
Reference in New Issue
Block a user