任务完成后从列表消失;重要度改名并新增紧急度五角星;通知按钮间距与默认专注页
This commit is contained in:
@@ -112,6 +112,10 @@ class MainActivity : AppCompatActivity() {
|
||||
// 进程常驻时跨天不会重走 App.onCreate,回到前台再滚一次重复任务。
|
||||
// 放在 super 之前:片段 onResume 里的 reload 读到的就是推进后的日期。
|
||||
runCatching { Store.rollRepeatingTasks() }
|
||||
// 打开/回到前台默认停在专注页;休息正在计时时不打断
|
||||
if (!TimerCore.running && TimerCore.mode != TimerCore.MODE_FOCUS) {
|
||||
runCatching { TimerCore.setMode(TimerCore.MODE_FOCUS) }
|
||||
}
|
||||
super.onResume()
|
||||
rollHandler.removeCallbacks(rollRunner)
|
||||
rollHandler.postDelayed(rollRunner, 60_000L)
|
||||
|
||||
@@ -67,6 +67,7 @@ class TaskAdapter(
|
||||
|
||||
private inner class TaskViewHolder(v: View) : RecyclerView.ViewHolder(v) {
|
||||
private val tvTitle: TextView = v.findViewById(R.id.tvTitle)
|
||||
private val tvStars: TextView = v.findViewById(R.id.tvStars)
|
||||
private val tvMeta: TextView = v.findViewById(R.id.tvMeta)
|
||||
private val tvNote: TextView = v.findViewById(R.id.tvNote)
|
||||
private val checkCircle: View = v.findViewById(R.id.checkCircle)
|
||||
@@ -87,6 +88,20 @@ class TaskAdapter(
|
||||
tvTitle.setTextColor(ctx.col(if (task.done) R.color.text_tertiary else R.color.text))
|
||||
tvTitle.typeface = if (task.priority >= 2 && !task.done) Typeface.DEFAULT_BOLD else Typeface.DEFAULT
|
||||
|
||||
// 紧急度五角星:紧急三颗红 / 中两颗绿 / 不急一颗灰;完成任务不再显示
|
||||
if (!task.done) {
|
||||
val (stars, color) = when (task.urgency) {
|
||||
2 -> "★★★" to R.color.urgent_high
|
||||
1 -> "★★" to R.color.urgent_mid
|
||||
else -> "★" to R.color.urgent_low
|
||||
}
|
||||
tvStars.text = stars
|
||||
tvStars.setTextColor(ctx.col(color))
|
||||
tvStars.visible(true)
|
||||
} else {
|
||||
tvStars.visible(false)
|
||||
}
|
||||
|
||||
if (task.done) {
|
||||
checkCircle.background = ctx.circleBg(ctx.col(R.color.brand))
|
||||
checkMark.visible(true)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -119,19 +119,12 @@ class TasksFragment : Fragment(R.layout.fragment_tasks) {
|
||||
ViewFilter.TODAY -> {
|
||||
val from = Dates.todayStart()
|
||||
val to = Dates.addDays(from, 1)
|
||||
// 今日 = 截止日正好是今天、且还没完成的任务
|
||||
// + 今天勾选完成的任务
|
||||
// 逾期(截止日在今天之前)不进来:那是「全部」里带"已逾期"标记的事,
|
||||
// 混进今日会把列表撑成一大串旧账,也让人分不清今天到底要做什么。
|
||||
// 今日 = 截止日正好是今天、还没完成的任务。
|
||||
// 完成的任务直接从列表消失(历史统一去「已完成」视图看),
|
||||
// 重复任务由跨零点的 rollRepeatingTasks 按周期生成新实例。
|
||||
val dueToday = pending.filter { it.due >= from && it.due < to }
|
||||
val doneToday = done.filter { it.doneAt >= from && it.doneAt < to }
|
||||
dueToday.forEach { rows.add(toRow(it, spans)) }
|
||||
doneToday.forEach { rows.add(toRow(it, spans)) }
|
||||
tvCount.text = if (doneToday.isEmpty()) {
|
||||
getString(R.string.task_count_today, dueToday.size)
|
||||
} else {
|
||||
getString(R.string.task_count_today_mixed, dueToday.size, doneToday.size)
|
||||
}
|
||||
tvCount.text = getString(R.string.task_count_today, dueToday.size)
|
||||
tvEmpty.setText(R.string.empty_today)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user