休息纯计时解耦滑动;重复任务按周期自动生成;统计数字去空格

This commit is contained in:
XIGE
2026-11-28 13:25:28 +08:00
parent ef2fb3a955
commit c3e0c9d67a
11 changed files with 147 additions and 102 deletions

View File

@@ -129,7 +129,15 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
TimerCore.reset()
render()
}
btnFinish.setOnClickListener { showFinishSheet() }
btnFinish.setOnClickListener {
// 休息是纯计时:右侧按钮直接结束休息,不弹原因、不检查是否已开始
if (TimerCore.mode != TimerCore.MODE_FOCUS) {
TimerCore.endBreak()
render()
} else {
showFinishSheet()
}
}
view.findViewById<View>(R.id.taskCard).setOnClickListener { pickTask() }
segFocus.setOnClickListener {
if (!TimerCore.running) {
@@ -209,12 +217,20 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
TimerCore.progress()
}
tvModeLabel.text = when {
TimerCore.countUp -> getString(R.string.count_up)
TimerCore.mode == TimerCore.MODE_SHORT -> getString(R.string.mode_break)
TimerCore.mode == TimerCore.MODE_LONG -> getString(R.string.mode_long_break)
else -> getString(R.string.count_down)
// 模式(专注/休息)与方向(正计时/倒计时)正交:休息页的正计时要同时说明两者
tvModeLabel.text = buildString {
when (TimerCore.mode) {
TimerCore.MODE_SHORT -> append(getString(R.string.mode_break))
TimerCore.MODE_LONG -> append(getString(R.string.mode_long_break))
}
if (TimerCore.countUp) {
if (isNotEmpty()) append(" · ")
append(getString(R.string.count_up))
} else if (focusMode) {
append(getString(R.string.count_down))
}
}
btnFinish.contentDescription = getString(if (focusMode) R.string.finish else R.string.end_break)
btnMain.text = when {
TimerCore.running -> getString(R.string.pause)