休息页恢复轮次圆点并保持主按钮原宽度;休息只有开始和结束,去除暂停
This commit is contained in:
@@ -106,18 +106,23 @@ object Notif {
|
||||
val rv = RemoteViews(context.packageName, R.layout.notif_timer)
|
||||
rv.setTextViewText(R.id.tvNotifTask, headline)
|
||||
bindChronometer(rv, running, countUp)
|
||||
rv.setOnClickPendingIntent(
|
||||
R.id.notifPause,
|
||||
serviceAction(
|
||||
context,
|
||||
if (running) TimerService.ACTION_PAUSE else TimerService.ACTION_RESUME,
|
||||
11,
|
||||
),
|
||||
)
|
||||
rv.setImageViewResource(
|
||||
R.id.notifPause,
|
||||
if (running) R.drawable.ic_pause else R.drawable.ic_play,
|
||||
)
|
||||
if (TimerCore.mode == TimerCore.MODE_FOCUS) {
|
||||
rv.setOnClickPendingIntent(
|
||||
R.id.notifPause,
|
||||
serviceAction(
|
||||
context,
|
||||
if (running) TimerService.ACTION_PAUSE else TimerService.ACTION_RESUME,
|
||||
11,
|
||||
),
|
||||
)
|
||||
rv.setImageViewResource(
|
||||
R.id.notifPause,
|
||||
if (running) R.drawable.ic_pause else R.drawable.ic_play,
|
||||
)
|
||||
} else {
|
||||
// 休息是纯计时:没有暂停,按钮占位保留但不可见,结束按钮位置不挪
|
||||
rv.setViewVisibility(R.id.notifPause, android.view.View.INVISIBLE)
|
||||
}
|
||||
rv.setOnClickPendingIntent(
|
||||
R.id.notifStop,
|
||||
serviceAction(context, TimerService.ACTION_STOP, 13),
|
||||
@@ -126,16 +131,18 @@ object Notif {
|
||||
b.setCustomBigContentView(rv)
|
||||
|
||||
// 模板动作保留作兜底(自定义布局生效时系统不会重复绘制这两颗按钮)
|
||||
b.addAction(
|
||||
NotificationCompat.Action(
|
||||
if (running) R.drawable.ic_pause else R.drawable.ic_play, "",
|
||||
serviceAction(
|
||||
context,
|
||||
if (running) TimerService.ACTION_PAUSE else TimerService.ACTION_RESUME,
|
||||
21,
|
||||
),
|
||||
if (TimerCore.mode == TimerCore.MODE_FOCUS) {
|
||||
b.addAction(
|
||||
NotificationCompat.Action(
|
||||
if (running) R.drawable.ic_pause else R.drawable.ic_play, "",
|
||||
serviceAction(
|
||||
context,
|
||||
if (running) TimerService.ACTION_PAUSE else TimerService.ACTION_RESUME,
|
||||
21,
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
b.addAction(
|
||||
NotificationCompat.Action(
|
||||
R.drawable.ic_stop, "",
|
||||
|
||||
@@ -313,6 +313,8 @@ object TimerCore {
|
||||
|
||||
fun pause(reason: String = "") {
|
||||
if (!running) return
|
||||
// 休息是纯计时:不允许暂停,页面上也只有开始/结束两个状态
|
||||
if (mode != MODE_FOCUS) return
|
||||
// 休息是纯计时:连暂停原因也不落库、不写任务备注
|
||||
if (reason.isNotBlank() && mode == MODE_FOCUS) {
|
||||
pendingPauseReason = reason.trim()
|
||||
|
||||
Reference in New Issue
Block a user