正倒计时布局统一消除晃动;原因弹层适配输入法;已完成按钮位置固定;原因文案与暂停原因;科技蓝主色
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# 变更记录
|
# 变更记录
|
||||||
|
|
||||||
|
## 2026-11-28 · 正倒计时布局统一消除晃动;原因弹层适配输入法;已完成按钮位置固定;原因文案与暂停原因;科技蓝主色
|
||||||
|
|
||||||
|
- 同步源码更新 11 个文件(新增/修改 11,删除 0)。
|
||||||
|
|
||||||
## 2026-11-28 · v0.5.0:完成按钮与提前结束原因、真实时长展示、全面 bug 修复
|
## 2026-11-28 · v0.5.0:完成按钮与提前结束原因、真实时长展示、全面 bug 修复
|
||||||
|
|
||||||
- **首页完成按钮**:右侧「跳过」换成「完成」图标(与左侧刷新同款线性描边风格);点击弹出圆角原因输入框,填完点「立即结束」结束本轮。
|
- **首页完成按钮**:右侧「跳过」换成「完成」图标(与左侧刷新同款线性描边风格);点击弹出圆角原因输入框,填完点「立即结束」结束本轮。
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import android.os.Build
|
|||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.os.VibrationEffect
|
import android.os.VibrationEffect
|
||||||
import android.os.Vibrator
|
import android.os.Vibrator
|
||||||
|
import com.focusbox.app.R
|
||||||
import com.focusbox.app.data.Store
|
import com.focusbox.app.data.Store
|
||||||
import com.focusbox.app.model.FocusFinish
|
import com.focusbox.app.model.FocusFinish
|
||||||
|
import com.focusbox.app.util.Dates
|
||||||
import com.focusbox.app.util.Prefs
|
import com.focusbox.app.util.Prefs
|
||||||
import java.util.concurrent.CopyOnWriteArrayList
|
import java.util.concurrent.CopyOnWriteArrayList
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
@@ -74,6 +76,11 @@ object TimerCore {
|
|||||||
private var endElapsed = 0L
|
private var endElapsed = 0L
|
||||||
private var clockOffset = 0L
|
private var clockOffset = 0L
|
||||||
|
|
||||||
|
/** 暂停原因在恢复时才补写备注,这里暂存起点与任务 */
|
||||||
|
private var pendingPauseReason = ""
|
||||||
|
private var pendingPauseStartAt = 0L
|
||||||
|
private var pendingPauseTaskId = 0L
|
||||||
|
|
||||||
private val listeners = CopyOnWriteArrayList<() -> Unit>()
|
private val listeners = CopyOnWriteArrayList<() -> Unit>()
|
||||||
|
|
||||||
fun addListener(l: () -> Unit) {
|
fun addListener(l: () -> Unit) {
|
||||||
@@ -105,6 +112,9 @@ object TimerCore {
|
|||||||
startedAt = Prefs.timerStartedAt
|
startedAt = Prefs.timerStartedAt
|
||||||
endElapsed = Prefs.timerEndElapsed
|
endElapsed = Prefs.timerEndElapsed
|
||||||
clockOffset = Prefs.timerClockOffset
|
clockOffset = Prefs.timerClockOffset
|
||||||
|
pendingPauseReason = Prefs.timerPauseReason
|
||||||
|
pendingPauseStartAt = Prefs.timerPauseStartAt
|
||||||
|
pendingPauseTaskId = Prefs.timerPauseTaskId
|
||||||
|
|
||||||
if (running) {
|
if (running) {
|
||||||
if (countUp) {
|
if (countUp) {
|
||||||
@@ -203,6 +213,7 @@ object TimerCore {
|
|||||||
startedAt = 0
|
startedAt = 0
|
||||||
endAt = 0
|
endAt = 0
|
||||||
endElapsed = 0
|
endElapsed = 0
|
||||||
|
clearPause()
|
||||||
save()
|
save()
|
||||||
notifyChanged()
|
notifyChanged()
|
||||||
}
|
}
|
||||||
@@ -244,6 +255,7 @@ object TimerCore {
|
|||||||
endAt = 0
|
endAt = 0
|
||||||
endElapsed = 0
|
endElapsed = 0
|
||||||
accReset()
|
accReset()
|
||||||
|
clearPause()
|
||||||
save()
|
save()
|
||||||
notifyChanged()
|
notifyChanged()
|
||||||
}
|
}
|
||||||
@@ -290,8 +302,13 @@ object TimerCore {
|
|||||||
notifyChanged()
|
notifyChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pause() {
|
fun pause(reason: String = "") {
|
||||||
if (!running) return
|
if (!running) return
|
||||||
|
if (reason.isNotBlank()) {
|
||||||
|
pendingPauseReason = reason.trim()
|
||||||
|
pendingPauseStartAt = System.currentTimeMillis()
|
||||||
|
pendingPauseTaskId = taskId
|
||||||
|
}
|
||||||
if (countUp) {
|
if (countUp) {
|
||||||
accumMs += (System.currentTimeMillis() - startedAt).coerceAtLeast(0)
|
accumMs += (System.currentTimeMillis() - startedAt).coerceAtLeast(0)
|
||||||
startedAt = 0
|
startedAt = 0
|
||||||
@@ -306,11 +323,31 @@ object TimerCore {
|
|||||||
notifyChanged()
|
notifyChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resume() = start()
|
fun resume() {
|
||||||
|
val reason = pendingPauseReason
|
||||||
|
val startAt = pendingPauseStartAt
|
||||||
|
val pausedTaskId = pendingPauseTaskId
|
||||||
|
start()
|
||||||
|
if (reason.isNotBlank() && startAt > 0L && pausedTaskId > 0L) {
|
||||||
|
val endAtPause = System.currentTimeMillis()
|
||||||
|
val seconds = ((endAtPause - startAt) / 1000).toInt().coerceAtLeast(0)
|
||||||
|
val line = ctx.getString(
|
||||||
|
R.string.task_note_pause,
|
||||||
|
reason,
|
||||||
|
Dates.hms(startAt),
|
||||||
|
Dates.hms(endAtPause),
|
||||||
|
Dates.duration(seconds),
|
||||||
|
)
|
||||||
|
appendTaskNote(pausedTaskId, line)
|
||||||
|
}
|
||||||
|
clearPause()
|
||||||
|
save()
|
||||||
|
}
|
||||||
|
|
||||||
/** 回到本轮起点,不记记录。倒计时保留当前设定的时长,正计时归零。 */
|
/** 回到本轮起点,不记记录。倒计时保留当前设定的时长,正计时归零。 */
|
||||||
fun reset() {
|
fun reset() {
|
||||||
running = false
|
running = false
|
||||||
|
clearPause()
|
||||||
endAt = 0
|
endAt = 0
|
||||||
startedAt = 0
|
startedAt = 0
|
||||||
if (countUp) {
|
if (countUp) {
|
||||||
@@ -349,6 +386,7 @@ object TimerCore {
|
|||||||
totalMs = if (totalMs > 0) totalMs else durationFor(mode)
|
totalMs = if (totalMs > 0) totalMs else durationFor(mode)
|
||||||
remainingMs = totalMs
|
remainingMs = totalMs
|
||||||
}
|
}
|
||||||
|
clearPause()
|
||||||
save()
|
save()
|
||||||
notifyChanged()
|
notifyChanged()
|
||||||
TimerService.stop(ctx)
|
TimerService.stop(ctx)
|
||||||
@@ -372,6 +410,7 @@ object TimerCore {
|
|||||||
endElapsed = 0
|
endElapsed = 0
|
||||||
startedAt = 0
|
startedAt = 0
|
||||||
if (countUp) accReset() else remainingMs = totalMs
|
if (countUp) accReset() else remainingMs = totalMs
|
||||||
|
clearPause()
|
||||||
save()
|
save()
|
||||||
notifyChanged()
|
notifyChanged()
|
||||||
TimerService.stop(ctx)
|
TimerService.stop(ctx)
|
||||||
@@ -399,6 +438,7 @@ object TimerCore {
|
|||||||
totalMs = durationFor(MODE_FOCUS)
|
totalMs = durationFor(MODE_FOCUS)
|
||||||
remainingMs = totalMs
|
remainingMs = totalMs
|
||||||
}
|
}
|
||||||
|
clearPause()
|
||||||
save()
|
save()
|
||||||
notifyChanged()
|
notifyChanged()
|
||||||
TimerService.stop(ctx)
|
TimerService.stop(ctx)
|
||||||
@@ -485,6 +525,21 @@ object TimerCore {
|
|||||||
Prefs.timerAccumMs = 0
|
Prefs.timerAccumMs = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun clearPause() {
|
||||||
|
pendingPauseReason = ""
|
||||||
|
pendingPauseStartAt = 0L
|
||||||
|
pendingPauseTaskId = 0L
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun appendTaskNote(id: Long, line: String) {
|
||||||
|
runCatching {
|
||||||
|
Store.task(id)?.let { t ->
|
||||||
|
val note = if (t.note.isBlank()) line else "${t.note}\n$line"
|
||||||
|
Store.updateTask(t.copy(note = note))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun save() {
|
private fun save() {
|
||||||
Prefs.timerMode = mode
|
Prefs.timerMode = mode
|
||||||
Prefs.timerRunning = running
|
Prefs.timerRunning = running
|
||||||
@@ -494,6 +549,9 @@ object TimerCore {
|
|||||||
Prefs.timerEndAt = endAt
|
Prefs.timerEndAt = endAt
|
||||||
Prefs.timerEndElapsed = if (endAt > 0) endElapsed else 0L
|
Prefs.timerEndElapsed = if (endAt > 0) endElapsed else 0L
|
||||||
Prefs.timerClockOffset = clockOffset
|
Prefs.timerClockOffset = clockOffset
|
||||||
|
Prefs.timerPauseReason = pendingPauseReason
|
||||||
|
Prefs.timerPauseStartAt = pendingPauseStartAt
|
||||||
|
Prefs.timerPauseTaskId = pendingPauseTaskId
|
||||||
Prefs.timerStartedAt = startedAt
|
Prefs.timerStartedAt = startedAt
|
||||||
Prefs.timerTaskId = taskId
|
Prefs.timerTaskId = taskId
|
||||||
Prefs.timerProjectId = projectId
|
Prefs.timerProjectId = projectId
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package com.focusbox.app.ui
|
|||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.graphics.Rect
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.view.ViewTreeObserver
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.focusbox.app.R
|
import com.focusbox.app.R
|
||||||
|
|
||||||
@@ -18,6 +20,9 @@ import com.focusbox.app.R
|
|||||||
*/
|
*/
|
||||||
open class SheetDialog(context: Context) : Dialog(context, R.style.SheetDialog) {
|
open class SheetDialog(context: Context) : Dialog(context, R.style.SheetDialog) {
|
||||||
|
|
||||||
|
private var imeRoot: View? = null
|
||||||
|
private var imeListener: ViewTreeObserver.OnGlobalLayoutListener? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
window?.apply {
|
window?.apply {
|
||||||
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||||
@@ -35,6 +40,35 @@ open class SheetDialog(context: Context) : Dialog(context, R.style.SheetDialog)
|
|||||||
(view.parent as? View)?.setBackgroundColor(Color.TRANSPARENT)
|
(view.parent as? View)?.setBackgroundColor(Color.TRANSPARENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 让带输入框的弹层跟随软键盘:弹出时整体上移,收起后回到页面底部。
|
||||||
|
* ADJUST_RESIZE 在部分 EMUI 上不会推动 Dialog 内容,只能自己按可见区域平移。
|
||||||
|
*/
|
||||||
|
fun fitOnIme(content: View) {
|
||||||
|
window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING)
|
||||||
|
val root = content.rootView
|
||||||
|
imeRoot = root
|
||||||
|
val threshold = (context.resources.displayMetrics.density * 100).toInt()
|
||||||
|
val screenHeight = context.resources.displayMetrics.heightPixels
|
||||||
|
val listener = object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
override fun onGlobalLayout() {
|
||||||
|
val frame = Rect()
|
||||||
|
root.getWindowVisibleDisplayFrame(frame)
|
||||||
|
val keyboard = screenHeight - frame.bottom
|
||||||
|
content.translationY = if (keyboard > threshold) -keyboard.toFloat() else 0f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
root.viewTreeObserver.addOnGlobalLayoutListener(listener)
|
||||||
|
imeListener = listener
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dismiss() {
|
||||||
|
imeListener?.let { imeRoot?.viewTreeObserver?.removeOnGlobalLayoutListener(it) }
|
||||||
|
imeListener = null
|
||||||
|
imeRoot = null
|
||||||
|
super.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
override fun show() {
|
override fun show() {
|
||||||
super.show()
|
super.show()
|
||||||
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
|
|||||||
@@ -116,11 +116,12 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
|
|
||||||
btnMain.setOnClickListener {
|
btnMain.setOnClickListener {
|
||||||
if (TimerCore.running) {
|
if (TimerCore.running) {
|
||||||
TimerCore.pause()
|
showPauseSheet()
|
||||||
} else {
|
return@setOnClickListener
|
||||||
requestNotifPermissionIfNeeded()
|
|
||||||
TimerCore.start()
|
|
||||||
}
|
}
|
||||||
|
requestNotifPermissionIfNeeded()
|
||||||
|
// 暂停后点"继续"要走 resume,恢复时才会把暂停原因补写进备注
|
||||||
|
if (TimerCore.elapsedNow() > 0) TimerCore.resume() else TimerCore.start()
|
||||||
render()
|
render()
|
||||||
}
|
}
|
||||||
btnReset.setOnClickListener {
|
btnReset.setOnClickListener {
|
||||||
@@ -231,7 +232,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
btnMain.background = requireContext().roundBg(accent, 100f)
|
btnMain.background = requireContext().roundBg(accent, 100f)
|
||||||
}
|
}
|
||||||
|
|
||||||
modeSwitch.visible(!TimerCore.countUp)
|
// 正计时与倒计时共用同一套布局:顶部模式分段、环内圆点都常驻,避免左右滑动时版面跳动
|
||||||
applySegments(focusMode)
|
applySegments(focusMode)
|
||||||
renderPageDots()
|
renderPageDots()
|
||||||
renderDots(accent)
|
renderDots(accent)
|
||||||
@@ -241,41 +242,87 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
if (!TimerCore.running && !dragging) handler.removeCallbacks(ticker)
|
if (!TimerCore.running && !dragging) handler.removeCallbacks(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 通用的原因输入弹层:输入法弹出时整体上移,收起后归位 */
|
||||||
* 提前完成:先写原因,再按真实起止结束本轮。
|
private fun reasonSheet(
|
||||||
* 原因会追加到任务备注并标记任务完成,任务页的已完成列表能看到备注与实际时段。
|
titleRes: Int,
|
||||||
*/
|
hintRes: Int,
|
||||||
|
inputHintRes: Int,
|
||||||
|
buttonRes: Int,
|
||||||
|
onConfirm: (String) -> Unit,
|
||||||
|
) {
|
||||||
|
val ctx = requireContext()
|
||||||
|
val sheet = SheetDialog(ctx)
|
||||||
|
val root = layoutInflater.inflate(R.layout.sheet_finish_reason, null)
|
||||||
|
root.findViewById<TextView>(R.id.tvReasonTitle).setText(titleRes)
|
||||||
|
root.findViewById<TextView>(R.id.tvReasonHint).setText(hintRes)
|
||||||
|
val etReason = root.findViewById<EditText>(R.id.etFinishReason)
|
||||||
|
etReason.setHint(inputHintRes)
|
||||||
|
val btnConfirm = root.findViewById<TextView>(R.id.btnFinishNow)
|
||||||
|
btnConfirm.setText(buttonRes)
|
||||||
|
btnConfirm.setOnClickListener {
|
||||||
|
val raw = etReason.text?.toString()?.trim().orEmpty()
|
||||||
|
onConfirm(raw)
|
||||||
|
sheet.dismiss()
|
||||||
|
render()
|
||||||
|
}
|
||||||
|
sheet.setContentView(root)
|
||||||
|
sheet.fitOnIme(root)
|
||||||
|
etReason.requestFocus()
|
||||||
|
sheet.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提前完成:按真实起止结束,并把"原计划 / 原因 / 提前多久"写进任务备注 */
|
||||||
private fun showFinishSheet() {
|
private fun showFinishSheet() {
|
||||||
if (TimerCore.elapsedNow() <= 0) {
|
if (TimerCore.elapsedNow() <= 0) {
|
||||||
Toast.makeText(requireContext(), R.string.finish_need_start, Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), R.string.finish_need_start, Toast.LENGTH_SHORT).show()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val ctx = requireContext()
|
val plannedMinutes = TimerCore.durationMinutes().takeIf { it > 0 } ?: Prefs.focusMinutes
|
||||||
val sheet = SheetDialog(ctx)
|
reasonSheet(
|
||||||
val root = layoutInflater.inflate(R.layout.sheet_finish_reason, null)
|
R.string.finish_reason_title,
|
||||||
val etReason = root.findViewById<EditText>(R.id.etFinishReason)
|
R.string.finish_reason_hint,
|
||||||
root.findViewById<View>(R.id.btnFinishNow).setOnClickListener {
|
R.string.finish_reason_input_hint,
|
||||||
val raw = etReason.text?.toString()?.trim().orEmpty()
|
R.string.finish_now,
|
||||||
|
) { raw ->
|
||||||
// 休息阶段点完成不算任务完成,只按实际时长记一条未完成记录
|
// 休息阶段点完成不算任务完成,只按实际时长记一条未完成记录
|
||||||
val wasFocus = TimerCore.mode == TimerCore.MODE_FOCUS
|
val wasFocus = TimerCore.mode == TimerCore.MODE_FOCUS
|
||||||
val finish = TimerCore.finishEarly(wasFocus)
|
val finish = TimerCore.finishEarly(wasFocus)
|
||||||
if (finish != null && wasFocus && finish.taskId > 0) {
|
if (finish != null && wasFocus && finish.taskId > 0) {
|
||||||
Store.task(finish.taskId)?.let { task ->
|
Store.task(finish.taskId)?.let { task ->
|
||||||
if (raw.isNotEmpty()) {
|
if (raw.isNotEmpty()) {
|
||||||
val line = getString(R.string.task_note_finish, Dates.hms(finish.endAt), raw)
|
val diff = plannedMinutes * 60 - finish.seconds
|
||||||
|
val ending = when {
|
||||||
|
diff > 0 -> "提前${Dates.duration(diff)}结束"
|
||||||
|
diff < 0 -> "超时${Dates.duration(-diff)}结束"
|
||||||
|
else -> "按时结束"
|
||||||
|
}
|
||||||
|
val line = getString(
|
||||||
|
R.string.task_note_finish, plannedMinutes, raw, Dates.hms(finish.endAt), ending
|
||||||
|
)
|
||||||
val note = if (task.note.isBlank()) line else "${task.note}\n$line"
|
val note = if (task.note.isBlank()) line else "${task.note}\n$line"
|
||||||
Store.updateTask(task.copy(note = note))
|
Store.updateTask(task.copy(note = note))
|
||||||
}
|
}
|
||||||
Store.setTaskDone(finish.taskId, true)
|
Store.setTaskDone(finish.taskId, true)
|
||||||
}
|
}
|
||||||
(activity as? com.focusbox.app.ui.MainActivity)?.refreshAll()
|
(activity as? com.focusbox.app.ui.MainActivity)?.refreshAll()
|
||||||
Toast.makeText(ctx, R.string.finish_saved, Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), R.string.finish_saved, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 暂停也记原因;起止时段在点击"继续"时补齐并写入任务备注 */
|
||||||
|
private fun showPauseSheet() {
|
||||||
|
reasonSheet(
|
||||||
|
R.string.pause_reason_title,
|
||||||
|
R.string.pause_reason_hint,
|
||||||
|
R.string.pause_reason_input_hint,
|
||||||
|
R.string.pause_now,
|
||||||
|
) { raw ->
|
||||||
|
TimerCore.pause(raw)
|
||||||
|
if (raw.isNotEmpty()) {
|
||||||
|
Toast.makeText(requireContext(), R.string.pause_saved, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
sheet.dismiss()
|
|
||||||
render()
|
|
||||||
}
|
}
|
||||||
sheet.setContentView(root)
|
|
||||||
sheet.show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderPageDots() {
|
private fun renderPageDots() {
|
||||||
@@ -308,8 +355,6 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
|
|
||||||
private fun renderDots(accent: Int) {
|
private fun renderDots(accent: Int) {
|
||||||
val every = Prefs.longBreakEvery.coerceAtLeast(2)
|
val every = Prefs.longBreakEvery.coerceAtLeast(2)
|
||||||
dots.visible(!TimerCore.countUp)
|
|
||||||
if (TimerCore.countUp) return
|
|
||||||
if (dots.childCount != every) {
|
if (dots.childCount != every) {
|
||||||
dots.removeAllViews()
|
dots.removeAllViews()
|
||||||
repeat(every) {
|
repeat(every) {
|
||||||
@@ -412,20 +457,9 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (TimerCore.countUp == toCountUp) return
|
if (TimerCore.countUp == toCountUp) return
|
||||||
val dir = if (toCountUp) -1f else 1f
|
// 两页布局完全一致,直接换状态即可;位移动画会在圆环上产生可见晃动
|
||||||
val shift = dpi(36f).toFloat()
|
|
||||||
dialWrap.animate()
|
|
||||||
.translationX(dir * shift)
|
|
||||||
.alpha(0f)
|
|
||||||
.setDuration(110)
|
|
||||||
.withEndAction {
|
|
||||||
if (view == null) return@withEndAction
|
|
||||||
TimerCore.setCountUp(toCountUp)
|
TimerCore.setCountUp(toCountUp)
|
||||||
render()
|
render()
|
||||||
dialWrap.translationX = -dir * shift
|
|
||||||
dialWrap.animate().translationX(0f).alpha(1f).setDuration(140).start()
|
|
||||||
}
|
|
||||||
.start()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------ 任务
|
// ------------------------------------------------------------------ 任务
|
||||||
|
|||||||
@@ -105,12 +105,14 @@ class TasksFragment : Fragment(R.layout.fragment_tasks) {
|
|||||||
tvCount.text = getString(R.string.task_count, pending.size)
|
tvCount.text = getString(R.string.task_count, pending.size)
|
||||||
tvEmpty.setText(R.string.empty_tasks)
|
tvEmpty.setText(R.string.empty_tasks)
|
||||||
if (done.isNotEmpty()) {
|
if (done.isNotEmpty()) {
|
||||||
if (expandedDone) done.forEach { rows.add(toRow(it, spans)) }
|
// 按钮固定在未完成列表之后,展开的已完成项排在它下面,
|
||||||
|
// 不管展开与否都在同一个位置,长列表也不用一路拉到底
|
||||||
rows.add(
|
rows.add(
|
||||||
TaskAdapter.Row.Footer(
|
TaskAdapter.Row.Footer(
|
||||||
getString(if (expandedDone) R.string.hide_done else R.string.show_done)
|
getString(if (expandedDone) R.string.hide_done else R.string.show_done)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if (expandedDone) done.forEach { rows.add(toRow(it, spans)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,19 @@ object Prefs {
|
|||||||
get() = sp.getLong("t_clock_offset", 0L)
|
get() = sp.getLong("t_clock_offset", 0L)
|
||||||
set(v) = sp.edit().putLong("t_clock_offset", v).apply()
|
set(v) = sp.edit().putLong("t_clock_offset", v).apply()
|
||||||
|
|
||||||
|
/** 暂停原因与起点,恢复时补写"暂停 X 分钟"到任务备注 */
|
||||||
|
var timerPauseReason: String
|
||||||
|
get() = sp.getString("t_pause_reason", "").orEmpty()
|
||||||
|
set(v) = sp.edit().putString("t_pause_reason", v).apply()
|
||||||
|
|
||||||
|
var timerPauseStartAt: Long
|
||||||
|
get() = sp.getLong("t_pause_start", 0L)
|
||||||
|
set(v) = sp.edit().putLong("t_pause_start", v).apply()
|
||||||
|
|
||||||
|
var timerPauseTaskId: Long
|
||||||
|
get() = sp.getLong("t_pause_task", 0L)
|
||||||
|
set(v) = sp.edit().putLong("t_pause_task", v).apply()
|
||||||
|
|
||||||
var timerTaskId: Long
|
var timerTaskId: Long
|
||||||
get() = sp.getLong("t_task", 0L)
|
get() = sp.getLong("t_task", 0L)
|
||||||
set(v) = sp.edit().putLong("t_task", v).apply()
|
set(v) = sp.edit().putLong("t_task", v).apply()
|
||||||
@@ -129,6 +142,9 @@ object Prefs {
|
|||||||
.putLong("t_remaining", 0L)
|
.putLong("t_remaining", 0L)
|
||||||
.putLong("t_end", 0L)
|
.putLong("t_end", 0L)
|
||||||
.putLong("t_end_elapsed", 0L)
|
.putLong("t_end_elapsed", 0L)
|
||||||
|
.putString("t_pause_reason", "")
|
||||||
|
.putLong("t_pause_start", 0L)
|
||||||
|
.putLong("t_pause_task", 0L)
|
||||||
.putLong("t_started", 0L)
|
.putLong("t_started", 0L)
|
||||||
.putLong("t_accum", 0L)
|
.putLong("t_accum", 0L)
|
||||||
.apply()
|
.apply()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||||
<gradient
|
<gradient
|
||||||
android:angle="270"
|
android:angle="270"
|
||||||
android:startColor="#5AA3FF"
|
android:startColor="#64A8FF"
|
||||||
android:centerColor="#4F97FF"
|
android:centerColor="#2F80ED"
|
||||||
android:endColor="#3D7FE0" />
|
android:endColor="#1B5FC0" />
|
||||||
</shape>
|
</shape>
|
||||||
|
|||||||
@@ -23,12 +23,14 @@
|
|||||||
android:paddingBottom="22dp">
|
android:paddingBottom="22dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/tvReasonTitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/finish_reason_title"
|
android:text="@string/finish_reason_title"
|
||||||
style="@style/T.Title" />
|
style="@style/T.Title" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/tvReasonHint"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
android:viewportWidth="108"
|
android:viewportWidth="108"
|
||||||
android:viewportHeight="108">
|
android:viewportHeight="108">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#4F97FF"
|
android:fillColor="#2F80ED"
|
||||||
android:pathData="M54,0 L108,0 L108,108 L0,108 L0,0 Z" />
|
android:pathData="M54,0 L108,0 L108,108 L0,108 L0,0 Z" />
|
||||||
<path
|
<path
|
||||||
android:pathData="M54,26 A28,28 0 1 1 53.99,26"
|
android:pathData="M54,26 A28,28 0 1 1 53.99,26"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="brand">#E08A72</color>
|
<color name="brand">#64A8FF</color>
|
||||||
<color name="brand_deep">#C75B45</color>
|
<color name="brand_deep">#2F80ED</color>
|
||||||
<color name="brand_soft">#33E08A72</color>
|
<color name="brand_soft">#3364A8FF</color>
|
||||||
<color name="on_brand">#1A120E</color>
|
<color name="on_brand">#0A1730</color>
|
||||||
|
|
||||||
<color name="rest">#7FBFAE</color>
|
<color name="rest">#7FBFAE</color>
|
||||||
<color name="rest_deep">#5FA391</color>
|
<color name="rest_deep">#5FA391</color>
|
||||||
@@ -11,37 +11,37 @@
|
|||||||
<color name="danger">#E8705F</color>
|
<color name="danger">#E8705F</color>
|
||||||
<color name="success">#6FBF8F</color>
|
<color name="success">#6FBF8F</color>
|
||||||
|
|
||||||
<color name="bg">#121316</color>
|
<color name="bg">#0E1520</color>
|
||||||
<color name="surface">#1B1D21</color>
|
<color name="surface">#151D29</color>
|
||||||
<color name="surface_alt">#232629</color>
|
<color name="surface_alt">#1D2734</color>
|
||||||
<color name="card_stroke">#2C3035</color>
|
<color name="card_stroke">#273546</color>
|
||||||
|
|
||||||
<color name="text">#EDE9E3</color>
|
<color name="text">#E8F0FA</color>
|
||||||
<color name="title">#F7F4EF</color>
|
<color name="title">#F5F9FF</color>
|
||||||
<color name="text_secondary">#A9A39A</color>
|
<color name="text_secondary">#9FB0C4</color>
|
||||||
<color name="text_tertiary">#8C867D</color>
|
<color name="text_tertiary">#7C8DA3</color>
|
||||||
|
|
||||||
<color name="divider">#2A2D31</color>
|
<color name="divider">#233044</color>
|
||||||
<color name="input_bg">#232629</color>
|
<color name="input_bg">#1D2734</color>
|
||||||
<color name="field_stroke">#34383E</color>
|
<color name="field_stroke">#31445C</color>
|
||||||
|
|
||||||
<color name="ring_track">#2B2F34</color>
|
<color name="ring_track">#223044</color>
|
||||||
<color name="segment_track">#262A2E</color>
|
<color name="segment_track">#1E2A38</color>
|
||||||
<color name="segment_on">#33383E</color>
|
<color name="segment_on">#2A3A4D</color>
|
||||||
|
|
||||||
<!-- 深色下用明显更亮的描边与加号,保证一眼能找到 -->
|
<!-- 深色下用明显更亮的描边与加号,保证一眼能找到 -->
|
||||||
<color name="icon_add_bg">#3C2A25</color>
|
<color name="icon_add_bg">#16304F</color>
|
||||||
<color name="icon_add_stroke">#8A5140</color>
|
<color name="icon_add_stroke">#2F80ED</color>
|
||||||
<color name="icon_add_fg">#FFB49A</color>
|
<color name="icon_add_fg">#8CC0FF</color>
|
||||||
|
|
||||||
<color name="ripple_surface">#1FFFFFFF</color>
|
<color name="ripple_surface">#1FFFFFFF</color>
|
||||||
<color name="ripple_brand">#33FFFFFF</color>
|
<color name="ripple_brand">#33FFFFFF</color>
|
||||||
|
|
||||||
<color name="heat0">#26292D</color>
|
<color name="heat0">#222C3A</color>
|
||||||
<color name="heat1">#4A2E27</color>
|
<color name="heat1">#1C3B5C</color>
|
||||||
<color name="heat2">#6E4034</color>
|
<color name="heat2">#235888</color>
|
||||||
<color name="heat3">#96523F</color>
|
<color name="heat3">#2F80ED</color>
|
||||||
<color name="heat4">#C47056</color>
|
<color name="heat4">#64A8FF</color>
|
||||||
|
|
||||||
<color name="mark_bg_top">#2A2D33</color>
|
<color name="mark_bg_top">#2A2D33</color>
|
||||||
<color name="mark_bg_bottom">#191B1F</color>
|
<color name="mark_bg_bottom">#191B1F</color>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<!--
|
<!--
|
||||||
专注盒子:陶土红作强调(番茄钟的原始意象),暖纸色作底。
|
时间简史:科技蓝作强调,冷灰蓝作底。
|
||||||
与 PostPad 的视觉语言同源,但更安静:长时间盯着计时器,底色不能抢眼。
|
长时间盯着计时器,底色保持安静,蓝色只出现在可操作与已完成的地方。
|
||||||
-->
|
-->
|
||||||
<color name="brand">#C75B45</color>
|
<color name="brand">#2F80ED</color>
|
||||||
<color name="brand_deep">#A6462F</color>
|
<color name="brand_deep">#1B5FC0</color>
|
||||||
<color name="brand_soft">#1FC75B45</color>
|
<color name="brand_soft">#1F2F80ED</color>
|
||||||
<color name="on_brand">#FFFFFF</color>
|
<color name="on_brand">#FFFFFF</color>
|
||||||
|
|
||||||
<!-- 休息态用青绿,与专注态形成明确的"换气"信号 -->
|
<!-- 休息态用青绿,与专注态形成明确的"换气"信号 -->
|
||||||
@@ -16,38 +16,38 @@
|
|||||||
<color name="danger">#C0392B</color>
|
<color name="danger">#C0392B</color>
|
||||||
<color name="success">#2E7D51</color>
|
<color name="success">#2E7D51</color>
|
||||||
|
|
||||||
<color name="bg">#F6F3EE</color>
|
<color name="bg">#F5F8FC</color>
|
||||||
<color name="surface">#FFFFFF</color>
|
<color name="surface">#FFFFFF</color>
|
||||||
<color name="surface_alt">#F1ECE4</color>
|
<color name="surface_alt">#EEF4FB</color>
|
||||||
<color name="card_stroke">#E9E2D6</color>
|
<color name="card_stroke">#E2EAF4</color>
|
||||||
|
|
||||||
<color name="text">#1E1B18</color>
|
<color name="text">#16202E</color>
|
||||||
<color name="title">#131110</color>
|
<color name="title">#0C1728</color>
|
||||||
<color name="text_secondary">#635C52</color>
|
<color name="text_secondary">#5B6B80</color>
|
||||||
<color name="text_tertiary">#6F685C</color>
|
<color name="text_tertiary">#708096</color>
|
||||||
|
|
||||||
<color name="divider">#E7E1D6</color>
|
<color name="divider">#E3EAF3</color>
|
||||||
<color name="input_bg">#F4F0E9</color>
|
<color name="input_bg">#F2F6FC</color>
|
||||||
<color name="field_stroke">#DDD5C7</color>
|
<color name="field_stroke">#D5E1F0</color>
|
||||||
|
|
||||||
<color name="ring_track">#EDE6DA</color>
|
<color name="ring_track">#E5ECF5</color>
|
||||||
<color name="segment_track">#EBE5DA</color>
|
<color name="segment_track">#E5ECF5</color>
|
||||||
<color name="segment_on">#FFFFFF</color>
|
<color name="segment_on">#FFFFFF</color>
|
||||||
|
|
||||||
<!-- 新增按钮:独立配色,避免深色下 + 号与底色糊成一片 -->
|
<!-- 新增按钮:独立蓝色描边与加号,避免和底色糊成一片 -->
|
||||||
<color name="icon_add_bg">#F6DED6</color>
|
<color name="icon_add_bg">#DCEBFF</color>
|
||||||
<color name="icon_add_stroke">#E3B2A1</color>
|
<color name="icon_add_stroke">#A8CBFF</color>
|
||||||
<color name="icon_add_fg">#9E3F29</color>
|
<color name="icon_add_fg">#1B5FC0</color>
|
||||||
|
|
||||||
<color name="ripple_surface">#14000000</color>
|
<color name="ripple_surface">#14000000</color>
|
||||||
<color name="ripple_brand">#33FFFFFF</color>
|
<color name="ripple_brand">#33FFFFFF</color>
|
||||||
|
|
||||||
<!-- 热力图色阶:从"没练"到"练满",用同一色相的五档明度,避免花 -->
|
<!-- 热力图色阶:同一蓝色相的五档明度 -->
|
||||||
<color name="heat0">#EDE7DB</color>
|
<color name="heat0">#E6EDF5</color>
|
||||||
<color name="heat1">#F2C9B9</color>
|
<color name="heat1">#C3DDFB</color>
|
||||||
<color name="heat2">#E39B80</color>
|
<color name="heat2">#8FBEFA</color>
|
||||||
<color name="heat3">#D4745B</color>
|
<color name="heat3">#5A9CF5</color>
|
||||||
<color name="heat4">#B44B36</color>
|
<color name="heat4">#2F80ED</color>
|
||||||
|
|
||||||
<color name="mark_bg_top">#2A2D33</color>
|
<color name="mark_bg_top">#2A2D33</color>
|
||||||
<color name="mark_bg_bottom">#191B1F</color>
|
<color name="mark_bg_bottom">#191B1F</color>
|
||||||
|
|||||||
@@ -27,7 +27,15 @@
|
|||||||
<string name="finish_now">立即结束</string>
|
<string name="finish_now">立即结束</string>
|
||||||
<string name="finish_saved">已结束并记入任务备注</string>
|
<string name="finish_saved">已结束并记入任务备注</string>
|
||||||
<string name="finish_need_start">请先开始专注</string>
|
<string name="finish_need_start">请先开始专注</string>
|
||||||
<string name="task_note_finish">【提前结束 %1$s】%2$s</string>
|
<!-- %4$s 由代码填"提前X结束 / 按时结束 / 超时X结束" -->
|
||||||
|
<string name="task_note_finish">原计划%1$d分钟,因%2$s原因%3$s%4$s</string>
|
||||||
|
<string name="task_note_pause">因%1$s原因%2$s到%3$s暂停%4$s</string>
|
||||||
|
|
||||||
|
<string name="pause_reason_title">暂停原因</string>
|
||||||
|
<string name="pause_reason_hint">写下暂停原因,恢复计时后会记入任务备注</string>
|
||||||
|
<string name="pause_reason_input_hint">例如:接电话 / 临时走开</string>
|
||||||
|
<string name="pause_now">立即暂停</string>
|
||||||
|
<string name="pause_saved">已记录暂停原因</string>
|
||||||
|
|
||||||
<string name="count_down">倒计时</string>
|
<string name="count_down">倒计时</string>
|
||||||
<string name="count_up">正计时</string>
|
<string name="count_up">正计时</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user