任务完成后从列表消失;重要度改名并新增紧急度五角星;通知按钮间距与默认专注页

This commit is contained in:
XIGE
2026-11-28 17:11:28 +08:00
parent 6d13a5bf3c
commit 6b68d56467
13 changed files with 176 additions and 58 deletions

View File

@@ -27,7 +27,7 @@ object Store {
const val INBOX_ID = 1L
private const val DB_NAME = "focusbox.db"
private const val DB_VERSION = 5
private const val DB_VERSION = 6
private lateinit var helper: Helper
@@ -70,7 +70,8 @@ object Store {
repeat_type INTEGER NOT NULL DEFAULT 0,
repeat_every INTEGER NOT NULL DEFAULT 1,
origin_id INTEGER NOT NULL DEFAULT 0,
log_seconds INTEGER NOT NULL DEFAULT 0
log_seconds INTEGER NOT NULL DEFAULT 0,
urgency INTEGER NOT NULL DEFAULT 1
)
""".trimIndent()
)
@@ -117,10 +118,14 @@ object Store {
"WHERE note LIKE '%【%' OR note LIKE '%】%'"
)
}
// v4 → v5:每次专注单独成一条完成记录,存本轮秒数以显示真实起止
// v4 → v5:每次专注单独成条完成记录,存本轮秒数以显示真实起止
if (oldVersion < 5) {
db.execSQL("ALTER TABLE tasks ADD COLUMN log_seconds INTEGER NOT NULL DEFAULT 0")
}
// v5 → v6:紧急度(0 不急 / 1 中 / 2 紧急),旧任务统一归为中
if (oldVersion < 6) {
db.execSQL("ALTER TABLE tasks ADD COLUMN urgency INTEGER NOT NULL DEFAULT 1")
}
}
}
@@ -206,11 +211,12 @@ object Store {
repeatEvery = c.getInt(13),
originId = c.getLong(14),
logSeconds = c.getInt(15),
urgency = c.getInt(16),
)
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, log_seconds"
"created_at, sort, repeat_type, repeat_every, origin_id, log_seconds, urgency"
fun tasks(projectId: Long = 0L, includeDone: Boolean = true): List<Task> {
val where = StringBuilder("1 = 1")
@@ -246,12 +252,14 @@ object Store {
due: Long,
repeatType: Int,
repeatEvery: Int,
urgency: Int = 1,
): Long {
val cv = ContentValues().apply {
put("title", title)
put("note", note)
put("project_id", projectId)
put("priority", priority)
put("urgency", urgency.coerceIn(0, 2))
put("focus_min", focusMinutes)
put("est_pomodoros", (focusMinutes / 25).coerceAtLeast(1))
put("done_pomodoros", 0)
@@ -272,6 +280,7 @@ object Store {
put("note", task.note)
put("project_id", task.projectId)
put("priority", task.priority)
put("urgency", task.urgency.coerceIn(0, 2))
put("focus_min", task.focusMinutes)
put("est_pomodoros", (task.focusMinutes / 25).coerceAtLeast(1))
put("due", task.due)
@@ -321,6 +330,7 @@ object Store {
put("note", note)
put("project_id", source?.projectId ?: INBOX_ID)
put("priority", source?.priority ?: 1)
put("urgency", source?.urgency?.coerceIn(0, 2) ?: 1)
put("focus_min", source?.focusMinutes ?: 25)
put("est_pomodoros", 1)
put("done_pomodoros", 1)
@@ -348,6 +358,7 @@ object Store {
due = due,
repeatType = source.repeatType,
repeatEvery = source.repeatEvery,
urgency = source.urgency,
)
if (id > 0) {
db.update(