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

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

@@ -41,6 +41,7 @@ class TaskSheet(
private val etNote: EditText = root.findViewById(R.id.etNote)
private val projectRow: LinearLayout = root.findViewById(R.id.projectRow)
private val priorityRow: LinearLayout = root.findViewById(R.id.priorityRow)
private val urgencyRow: LinearLayout = root.findViewById(R.id.urgencyRow)
private val repeatRow: LinearLayout = root.findViewById(R.id.repeatRow)
private val repeatEveryRow: View = root.findViewById(R.id.repeatEveryRow)
private val tvFocus: TextView = root.findViewById(R.id.tvFocus)
@@ -51,6 +52,8 @@ class TaskSheet(
private var projectId: Long = existing?.projectId
?: if (presetProjectId > 0) presetProjectId else Store.INBOX_ID
private var priority: Int = existing?.priority ?: 1
// 紧急度:0 不急 / 1 中 / 2 紧急,旧数据默认归为中
private var urgency: Int = (existing?.urgency ?: 1).coerceIn(0, 2)
// 旧数据的时长可能超出新范围(早先是"番茄数×25"),这里统一夹紧
private var focusMin: Int = (existing?.focusMinutes ?: Prefs.focusMinutes)
.coerceIn(TimerCore.MIN_MINUTES, TimerCore.MAX_MINUTES)
@@ -112,6 +115,7 @@ class TaskSheet(
renderProjects()
renderPriority()
renderUrgency()
renderRepeat()
updateDue()
}
@@ -143,6 +147,21 @@ class TaskSheet(
}
}
/** 紧急度三选一:列表标题后按档位显示三颗红 / 两颗绿 / 一颗灰五角星 */
private fun renderUrgency() {
val ctx = context
urgencyRow.removeAllViews()
val labels = listOf(R.string.p_low, R.string.p_mid, R.string.p_high)
labels.forEachIndexed { index, res ->
val chip = ctx.makeChip(ctx.getString(res), index == urgency)
chip.setOnClickListener {
urgency = index
renderUrgency()
}
urgencyRow.addView(chip)
}
}
private fun renderFocus() {
tvFocus.text = context.getString(R.string.minutes_value, focusMin)
}
@@ -214,7 +233,7 @@ class TaskSheet(
// 重复任务必须有日期作为节奏起点,否则既进不了「今日」,也无法按间隔滚动
val effectiveDue = if (repeatType != Repeat.NONE && due <= 0) Dates.todayStart() else due
if (existing == null) {
Store.addTask(title, note, projectId, priority, focusMin, effectiveDue, repeatType, every)
Store.addTask(title, note, projectId, priority, focusMin, effectiveDue, repeatType, every, urgency)
} else {
Store.updateTask(
existing.copy(
@@ -222,6 +241,7 @@ class TaskSheet(
note = note,
projectId = projectId,
priority = priority,
urgency = urgency,
focusMinutes = focusMin,
due = effectiveDue,
repeatType = repeatType,