休息页精简与圆圈标签统一;完成记录独立落库并隔离暂停备注
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 = 4
|
||||
private const val DB_VERSION = 5
|
||||
|
||||
private lateinit var helper: Helper
|
||||
|
||||
@@ -69,7 +69,8 @@ object Store {
|
||||
focus_min INTEGER NOT NULL DEFAULT 25,
|
||||
repeat_type INTEGER NOT NULL DEFAULT 0,
|
||||
repeat_every INTEGER NOT NULL DEFAULT 1,
|
||||
origin_id INTEGER NOT NULL DEFAULT 0
|
||||
origin_id INTEGER NOT NULL DEFAULT 0,
|
||||
log_seconds INTEGER NOT NULL DEFAULT 0
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
@@ -116,6 +117,10 @@ object Store {
|
||||
"WHERE note LIKE '%【%' OR note LIKE '%】%'"
|
||||
)
|
||||
}
|
||||
// v4 → v5:每次专注单独成一条完成记录,存本轮秒数以显示真实起止
|
||||
if (oldVersion < 5) {
|
||||
db.execSQL("ALTER TABLE tasks ADD COLUMN log_seconds INTEGER NOT NULL DEFAULT 0")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,11 +205,12 @@ object Store {
|
||||
repeatType = c.getInt(12),
|
||||
repeatEvery = c.getInt(13),
|
||||
originId = c.getLong(14),
|
||||
logSeconds = c.getInt(15),
|
||||
)
|
||||
|
||||
private val taskColumns =
|
||||
"_id, title, note, project_id, priority, focus_min, done_pomodoros, due, done, done_at, " +
|
||||
"created_at, sort, repeat_type, repeat_every, origin_id"
|
||||
"created_at, sort, repeat_type, repeat_every, origin_id, log_seconds"
|
||||
|
||||
fun tasks(projectId: Long = 0L, includeDone: Boolean = true): List<Task> {
|
||||
val where = StringBuilder("1 = 1")
|
||||
@@ -294,6 +300,43 @@ object Store {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次专注结束 = 一条独立的完成任务记录。
|
||||
*
|
||||
* 每次点「完成」都新建一条已完成的任务副本,备注只属于这一次,
|
||||
* 不再往源任务的备注里累加;源任务保持待办,可以继续下一轮。
|
||||
* origin_id 指回源任务(仅用于取这次专注的起止时刻),repeat_type 清零,
|
||||
* 这样完成记录不会被重复任务滚动逻辑当成新周期实例。
|
||||
*/
|
||||
fun addCompletionRecord(
|
||||
sourceId: Long,
|
||||
note: String,
|
||||
startAt: Long,
|
||||
endAt: Long,
|
||||
seconds: Int,
|
||||
): Long {
|
||||
val source = if (sourceId > 0) task(sourceId) else null
|
||||
val cv = ContentValues().apply {
|
||||
put("title", source?.title ?: "未关联任务")
|
||||
put("note", note)
|
||||
put("project_id", source?.projectId ?: INBOX_ID)
|
||||
put("priority", source?.priority ?: 1)
|
||||
put("focus_min", source?.focusMinutes ?: 25)
|
||||
put("est_pomodoros", 1)
|
||||
put("done_pomodoros", 1)
|
||||
put("due", source?.due ?: 0L)
|
||||
put("done", 1)
|
||||
put("done_at", endAt)
|
||||
put("created_at", if (startAt > 0) startAt else endAt)
|
||||
put("sort", 0)
|
||||
put("repeat_type", Repeat.NONE)
|
||||
put("repeat_every", 1)
|
||||
put("origin_id", sourceId)
|
||||
put("log_seconds", seconds)
|
||||
}
|
||||
return db.insert("tasks", null, cv)
|
||||
}
|
||||
|
||||
/** 为重复系列生成一条全新实例:备注永远从空开始 */
|
||||
private fun createSeriesInstance(rootId: Long, source: Task, due: Long): Long {
|
||||
val id = addTask(
|
||||
|
||||
Reference in New Issue
Block a user