休息页恢复轮次圆点并保持主按钮原宽度;休息只有开始和结束,去除暂停
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# 变更记录
|
# 变更记录
|
||||||
|
|
||||||
|
## 2026-11-28 · 休息页恢复轮次圆点并保持主按钮原宽度;休息只有开始和结束,去除暂停
|
||||||
|
|
||||||
|
- 同步源码更新 3 个文件(新增/修改 3,删除 0)。
|
||||||
|
|
||||||
## 2026-11-28 · v0.5.4:休息页精简、圆圈标签统一、完成记录独立落库
|
## 2026-11-28 · v0.5.4:休息页精简、圆圈标签统一、完成记录独立落库
|
||||||
|
|
||||||
- **圆圈标签统一**:环内只显示「正计时 / 倒计时」,与专注页完全一致;右上角分段控件首项由「专注」改「工作」,休息文案不变。
|
- **圆圈标签统一**:环内只显示「正计时 / 倒计时」,与专注页完全一致;右上角分段控件首项由「专注」改「工作」,休息文案不变。
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ object Notif {
|
|||||||
val rv = RemoteViews(context.packageName, R.layout.notif_timer)
|
val rv = RemoteViews(context.packageName, R.layout.notif_timer)
|
||||||
rv.setTextViewText(R.id.tvNotifTask, headline)
|
rv.setTextViewText(R.id.tvNotifTask, headline)
|
||||||
bindChronometer(rv, running, countUp)
|
bindChronometer(rv, running, countUp)
|
||||||
|
if (TimerCore.mode == TimerCore.MODE_FOCUS) {
|
||||||
rv.setOnClickPendingIntent(
|
rv.setOnClickPendingIntent(
|
||||||
R.id.notifPause,
|
R.id.notifPause,
|
||||||
serviceAction(
|
serviceAction(
|
||||||
@@ -118,6 +119,10 @@ object Notif {
|
|||||||
R.id.notifPause,
|
R.id.notifPause,
|
||||||
if (running) R.drawable.ic_pause else R.drawable.ic_play,
|
if (running) R.drawable.ic_pause else R.drawable.ic_play,
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
// 休息是纯计时:没有暂停,按钮占位保留但不可见,结束按钮位置不挪
|
||||||
|
rv.setViewVisibility(R.id.notifPause, android.view.View.INVISIBLE)
|
||||||
|
}
|
||||||
rv.setOnClickPendingIntent(
|
rv.setOnClickPendingIntent(
|
||||||
R.id.notifStop,
|
R.id.notifStop,
|
||||||
serviceAction(context, TimerService.ACTION_STOP, 13),
|
serviceAction(context, TimerService.ACTION_STOP, 13),
|
||||||
@@ -126,6 +131,7 @@ object Notif {
|
|||||||
b.setCustomBigContentView(rv)
|
b.setCustomBigContentView(rv)
|
||||||
|
|
||||||
// 模板动作保留作兜底(自定义布局生效时系统不会重复绘制这两颗按钮)
|
// 模板动作保留作兜底(自定义布局生效时系统不会重复绘制这两颗按钮)
|
||||||
|
if (TimerCore.mode == TimerCore.MODE_FOCUS) {
|
||||||
b.addAction(
|
b.addAction(
|
||||||
NotificationCompat.Action(
|
NotificationCompat.Action(
|
||||||
if (running) R.drawable.ic_pause else R.drawable.ic_play, "",
|
if (running) R.drawable.ic_pause else R.drawable.ic_play, "",
|
||||||
@@ -136,6 +142,7 @@ object Notif {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
b.addAction(
|
b.addAction(
|
||||||
NotificationCompat.Action(
|
NotificationCompat.Action(
|
||||||
R.drawable.ic_stop, "",
|
R.drawable.ic_stop, "",
|
||||||
|
|||||||
@@ -313,6 +313,8 @@ object TimerCore {
|
|||||||
|
|
||||||
fun pause(reason: String = "") {
|
fun pause(reason: String = "") {
|
||||||
if (!running) return
|
if (!running) return
|
||||||
|
// 休息是纯计时:不允许暂停,页面上也只有开始/结束两个状态
|
||||||
|
if (mode != MODE_FOCUS) return
|
||||||
// 休息是纯计时:连暂停原因也不落库、不写任务备注
|
// 休息是纯计时:连暂停原因也不落库、不写任务备注
|
||||||
if (reason.isNotBlank() && mode == MODE_FOCUS) {
|
if (reason.isNotBlank() && mode == MODE_FOCUS) {
|
||||||
pendingPauseReason = reason.trim()
|
pendingPauseReason = reason.trim()
|
||||||
|
|||||||
@@ -118,6 +118,17 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
btnFinish.tint(col(R.color.text_secondary))
|
btnFinish.tint(col(R.color.text_secondary))
|
||||||
|
|
||||||
btnMain.setOnClickListener {
|
btnMain.setOnClickListener {
|
||||||
|
// 休息只有开始/结束:开始后按钮变为"结束休息",再点直接结束,没有暂停这套
|
||||||
|
if (TimerCore.mode != TimerCore.MODE_FOCUS) {
|
||||||
|
if (TimerCore.running) {
|
||||||
|
TimerCore.endBreak()
|
||||||
|
} else {
|
||||||
|
requestNotifPermissionIfNeeded()
|
||||||
|
TimerCore.start()
|
||||||
|
}
|
||||||
|
render()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
if (TimerCore.running) {
|
if (TimerCore.running) {
|
||||||
showPauseSheet()
|
showPauseSheet()
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
@@ -214,19 +225,20 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
// 圆环内标签与专注页完全一致:只说计时方向,不重复顶部的「工作/休息」
|
// 圆环内标签与专注页完全一致:只说计时方向,不重复顶部的「工作/休息」
|
||||||
tvModeLabel.text = getString(if (TimerCore.countUp) R.string.count_up else R.string.count_down)
|
tvModeLabel.text = getString(if (TimerCore.countUp) R.string.count_up else R.string.count_down)
|
||||||
|
|
||||||
// 休息只是计时:去掉主按钮左右的重置/结束按钮、轮次圆点与底部任务卡片
|
// 轮次圆点两种模式都保留;左右按钮在休息时改为隐形占位,
|
||||||
btnReset.visible(focusMode)
|
// 主按钮宽度和左右居中位置保持与专注页完全一致,不会被拉满整行
|
||||||
btnFinish.visible(focusMode)
|
btnReset.visibility = if (focusMode) View.VISIBLE else View.INVISIBLE
|
||||||
|
btnFinish.visibility = if (focusMode) View.VISIBLE else View.INVISIBLE
|
||||||
taskCard.visible(focusMode)
|
taskCard.visible(focusMode)
|
||||||
dots.visible(focusMode)
|
dots.visibility = View.VISIBLE
|
||||||
btnFinish.contentDescription = getString(R.string.finish)
|
btnFinish.contentDescription = getString(R.string.finish)
|
||||||
|
|
||||||
btnMain.text = when {
|
btnMain.text = when {
|
||||||
|
!focusMode -> getString(if (TimerCore.running) R.string.end_break else R.string.start_break)
|
||||||
TimerCore.running -> getString(R.string.pause)
|
TimerCore.running -> getString(R.string.pause)
|
||||||
TimerCore.countUp -> if (display > 0) getString(R.string.resume) else getString(R.string.start_timing)
|
TimerCore.countUp -> if (display > 0) getString(R.string.resume) else getString(R.string.start_timing)
|
||||||
display < TimerCore.totalMs -> getString(R.string.resume)
|
display < TimerCore.totalMs -> getString(R.string.resume)
|
||||||
focusMode -> getString(R.string.start)
|
else -> getString(R.string.start)
|
||||||
else -> getString(R.string.start_break)
|
|
||||||
}
|
}
|
||||||
// 按钮底色随模式变,但每 250ms 新建一个 drawable 会造成无谓的 GC,
|
// 按钮底色随模式变,但每 250ms 新建一个 drawable 会造成无谓的 GC,
|
||||||
// 用 tag 记住当前颜色,只有真的变了才换。
|
// 用 tag 记住当前颜色,只有真的变了才换。
|
||||||
|
|||||||
Reference in New Issue
Block a user