右侧按钮改为完成并加入原因弹层;已完成任务显示真实时长;删除首页说明;修复审查发现的计时与数据缺陷
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# 变更记录
|
# 变更记录
|
||||||
|
|
||||||
|
## 2026-11-28 · 右侧按钮改为完成并加入原因弹层;已完成任务显示真实时长;删除首页说明;修复审查发现的计时与数据缺陷
|
||||||
|
|
||||||
|
- 同步源码更新 14 个文件(新增/修改 14,删除 0)。
|
||||||
|
|
||||||
## 2026-11-28 · v0.4.4:通知按钮留边距、项目操作弹层圆角、改名时间简史
|
## 2026-11-28 · v0.4.4:通知按钮留边距、项目操作弹层圆角、改名时间简史
|
||||||
|
|
||||||
- **通知 / 锁屏**:暂停与结束按钮之间留 8dp 间距,整组按钮距右边缘 10dp,不再贴成一团。
|
- **通知 / 锁屏**:暂停与结束按钮之间留 8dp 间距,整组按钮距右边缘 10dp,不再贴成一团。
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.MainActivity"
|
android:name=".ui.MainActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|uiMode"
|
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ object Store {
|
|||||||
const val INBOX_ID = 1L
|
const val INBOX_ID = 1L
|
||||||
|
|
||||||
private const val DB_NAME = "focusbox.db"
|
private const val DB_NAME = "focusbox.db"
|
||||||
private const val DB_VERSION = 2
|
private const val DB_VERSION = 3
|
||||||
|
|
||||||
private lateinit var helper: Helper
|
private lateinit var helper: Helper
|
||||||
|
|
||||||
@@ -68,7 +68,8 @@ object Store {
|
|||||||
sort INTEGER NOT NULL DEFAULT 0,
|
sort INTEGER NOT NULL DEFAULT 0,
|
||||||
focus_min INTEGER NOT NULL DEFAULT 25,
|
focus_min INTEGER NOT NULL DEFAULT 25,
|
||||||
repeat_type INTEGER NOT NULL DEFAULT 0,
|
repeat_type INTEGER NOT NULL DEFAULT 0,
|
||||||
repeat_every INTEGER NOT NULL DEFAULT 1
|
repeat_every INTEGER NOT NULL DEFAULT 1,
|
||||||
|
origin_id INTEGER NOT NULL DEFAULT 0
|
||||||
)
|
)
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
@@ -104,6 +105,10 @@ object Store {
|
|||||||
db.execSQL("ALTER TABLE tasks ADD COLUMN repeat_every INTEGER NOT NULL DEFAULT 1")
|
db.execSQL("ALTER TABLE tasks ADD COLUMN repeat_every INTEGER NOT NULL DEFAULT 1")
|
||||||
db.execSQL("UPDATE tasks SET focus_min = est_pomodoros * 25 WHERE est_pomodoros > 0")
|
db.execSQL("UPDATE tasks SET focus_min = est_pomodoros * 25 WHERE est_pomodoros > 0")
|
||||||
}
|
}
|
||||||
|
// v2 → v3:记录重复任务的来源,取消完成时能精确删掉自动生成的新一条
|
||||||
|
if (oldVersion < 3) {
|
||||||
|
db.execSQL("ALTER TABLE tasks ADD COLUMN origin_id INTEGER NOT NULL DEFAULT 0")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,6 +273,7 @@ object Store {
|
|||||||
*/
|
*/
|
||||||
fun setTaskDone(id: Long, done: Boolean) {
|
fun setTaskDone(id: Long, done: Boolean) {
|
||||||
if (!done) {
|
if (!done) {
|
||||||
|
val t = task(id)
|
||||||
db.update(
|
db.update(
|
||||||
"tasks",
|
"tasks",
|
||||||
ContentValues().apply {
|
ContentValues().apply {
|
||||||
@@ -276,6 +282,14 @@ object Store {
|
|||||||
},
|
},
|
||||||
"_id = ?", arrayOf(id.toString())
|
"_id = ?", arrayOf(id.toString())
|
||||||
)
|
)
|
||||||
|
// 撤销重复任务时,上次勾选自动生成的新一条要一起撤掉,否则清单会多出一条
|
||||||
|
if (t != null && t.repeating) {
|
||||||
|
db.delete(
|
||||||
|
"tasks",
|
||||||
|
"origin_id = ? AND done = 0 AND _id != ?",
|
||||||
|
arrayOf(id.toString(), id.toString())
|
||||||
|
)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val t = task(id) ?: return
|
val t = task(id) ?: return
|
||||||
@@ -298,7 +312,7 @@ object Store {
|
|||||||
if (next == base) return
|
if (next == base) return
|
||||||
// 下一次的截止日至少比今天晚一天,否则刚生成就会显示"已逾期"
|
// 下一次的截止日至少比今天晚一天,否则刚生成就会显示"已逾期"
|
||||||
val due = if (next <= Dates.todayStart()) Dates.addDays(Dates.todayStart(), 1) else next
|
val due = if (next <= Dates.todayStart()) Dates.addDays(Dates.todayStart(), 1) else next
|
||||||
addTask(
|
val childId = addTask(
|
||||||
title = t.title,
|
title = t.title,
|
||||||
note = t.note,
|
note = t.note,
|
||||||
projectId = t.projectId,
|
projectId = t.projectId,
|
||||||
@@ -308,6 +322,13 @@ object Store {
|
|||||||
repeatType = t.repeatType,
|
repeatType = t.repeatType,
|
||||||
repeatEvery = t.repeatEvery,
|
repeatEvery = t.repeatEvery,
|
||||||
)
|
)
|
||||||
|
if (childId > 0) {
|
||||||
|
db.update(
|
||||||
|
"tasks",
|
||||||
|
ContentValues().apply { put("origin_id", t.id) },
|
||||||
|
"_id = ?", arrayOf(childId.toString())
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 把日期按重复规则往后推一个周期 */
|
/** 把日期按重复规则往后推一个周期 */
|
||||||
@@ -539,7 +560,7 @@ object Store {
|
|||||||
val map = HashMap<Long, SessionSpan>()
|
val map = HashMap<Long, SessionSpan>()
|
||||||
db.rawQuery(
|
db.rawQuery(
|
||||||
"""
|
"""
|
||||||
SELECT s.task_id, s.start_at, s.end_at FROM sessions s
|
SELECT s.task_id, s.start_at, s.end_at, s.seconds FROM sessions s
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT task_id, MAX(end_at) AS max_end FROM sessions
|
SELECT task_id, MAX(end_at) AS max_end FROM sessions
|
||||||
WHERE task_id > 0 GROUP BY task_id
|
WHERE task_id > 0 GROUP BY task_id
|
||||||
@@ -549,7 +570,7 @@ object Store {
|
|||||||
).use { c ->
|
).use { c ->
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
val id = c.getLong(0)
|
val id = c.getLong(0)
|
||||||
if (!map.containsKey(id)) map[id] = SessionSpan(c.getLong(1), c.getLong(2))
|
if (!map.containsKey(id)) map[id] = SessionSpan(c.getLong(1), c.getLong(2), c.getInt(3))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map
|
return map
|
||||||
@@ -609,6 +630,8 @@ object Store {
|
|||||||
db.delete("sessions", null, null)
|
db.delete("sessions", null, null)
|
||||||
db.delete("tasks", null, null)
|
db.delete("tasks", null, null)
|
||||||
db.delete("projects", null, null)
|
db.delete("projects", null, null)
|
||||||
|
// 不清自增序列的话,清空后第一个项目 id 会继续往上跑,永远不再是收件箱的 1
|
||||||
|
db.delete("sqlite_sequence", "name IN (?,?,?)", arrayOf("projects", "tasks", "sessions"))
|
||||||
db.execSQL(
|
db.execSQL(
|
||||||
"INSERT INTO projects (name, color, archived, sort, created_at) VALUES (?,?,?,?,?)",
|
"INSERT INTO projects (name, color, archived, sort, created_at) VALUES (?,?,?,?,?)",
|
||||||
arrayOf<Any>("收件箱", 0xFF7A756C.toInt(), 0, 0, System.currentTimeMillis())
|
arrayOf<Any>("收件箱", 0xFF7A756C.toInt(), 0, 0, System.currentTimeMillis())
|
||||||
|
|||||||
@@ -43,8 +43,17 @@ data class Task(
|
|||||||
val repeating: Boolean get() = repeatType != Repeat.NONE && repeatEvery > 0
|
val repeating: Boolean get() = repeatType != Repeat.NONE && repeatEvery > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 一条专注记录的起止时刻,用于在已完成任务上显示实际工作时段。 */
|
/** 一条专注记录的起止时刻与实际秒数,用于在已完成任务上显示真实工作时段。 */
|
||||||
data class SessionSpan(val startAt: Long, val endAt: Long)
|
data class SessionSpan(val startAt: Long, val endAt: Long, val seconds: Int = 0)
|
||||||
|
|
||||||
|
/** 提前完成时交给 UI 落备注的实际专注信息 */
|
||||||
|
data class FocusFinish(
|
||||||
|
val taskId: Long,
|
||||||
|
val projectId: Long,
|
||||||
|
val startAt: Long,
|
||||||
|
val endAt: Long,
|
||||||
|
val seconds: Int,
|
||||||
|
)
|
||||||
|
|
||||||
data class DayPoint(
|
data class DayPoint(
|
||||||
val key: String, // yyyy-MM-dd
|
val key: String, // yyyy-MM-dd
|
||||||
|
|||||||
@@ -168,10 +168,12 @@ object Notif {
|
|||||||
base = now + TimerCore.remainingNow()
|
base = now + TimerCore.remainingNow()
|
||||||
countDown = true
|
countDown = true
|
||||||
}
|
}
|
||||||
rv.setChronometer(R.id.notifChrono, base, null, running)
|
// 方向必须在 base 之前下发:部分 ROM 会按 RemoteViews 指令顺序应用属性,
|
||||||
|
// 先 setChronometer 再切 countDown 会出现先按正计时算、再倒着走的错读数。
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
rv.setChronometerCountDown(R.id.notifChrono, countDown)
|
rv.setChronometerCountDown(R.id.notifChrono, countDown)
|
||||||
}
|
}
|
||||||
|
rv.setChronometer(R.id.notifChrono, base, null, running)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateOngoing(context: Context) {
|
fun updateOngoing(context: Context) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -59,6 +59,8 @@ class TimerService : Service() {
|
|||||||
|
|
||||||
private val onStateChanged: () -> Unit = {
|
private val onStateChanged: () -> Unit = {
|
||||||
Notif.updateOngoing(this)
|
Notif.updateOngoing(this)
|
||||||
|
// 暂停/结束时同步停掉 1 秒轮询,别让 Handler 空转
|
||||||
|
syncTicker()
|
||||||
syncWakeLock()
|
syncWakeLock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import androidx.fragment.app.Fragment
|
|||||||
import com.focusbox.app.R
|
import com.focusbox.app.R
|
||||||
import com.focusbox.app.model.Task
|
import com.focusbox.app.model.Task
|
||||||
import com.focusbox.app.service.TimerCore
|
import com.focusbox.app.service.TimerCore
|
||||||
|
import com.focusbox.app.service.TimerService
|
||||||
import com.focusbox.app.ui.focus.FocusFragment
|
import com.focusbox.app.ui.focus.FocusFragment
|
||||||
import com.focusbox.app.ui.projects.ProjectsFragment
|
import com.focusbox.app.ui.projects.ProjectsFragment
|
||||||
import com.focusbox.app.ui.settings.SettingsFragment
|
import com.focusbox.app.ui.settings.SettingsFragment
|
||||||
@@ -80,6 +81,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
showTab(start, force = true)
|
showTab(start, force = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
// 进程曾被系统回收时,前台服务也随之消失;回到前台补一次拉起,
|
||||||
|
// 否则计时状态还在走,却没有常驻通知也拿不到到点提醒。
|
||||||
|
if (TimerCore.running) TimerService.ensureRunning(this)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
outState.putInt(KEY_TAB, current)
|
outState.putInt(KEY_TAB, current)
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.view.MotionEvent
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewConfiguration
|
import android.view.ViewConfiguration
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import android.widget.EditText
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
@@ -47,14 +48,13 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
private lateinit var ring: RingView
|
private lateinit var ring: RingView
|
||||||
private lateinit var tvTime: TextView
|
private lateinit var tvTime: TextView
|
||||||
private lateinit var tvModeLabel: TextView
|
private lateinit var tvModeLabel: TextView
|
||||||
private lateinit var tvDialHint: TextView
|
|
||||||
private lateinit var dots: LinearLayout
|
private lateinit var dots: LinearLayout
|
||||||
private lateinit var pageDots: LinearLayout
|
private lateinit var pageDots: LinearLayout
|
||||||
private lateinit var dialWrap: View
|
private lateinit var dialWrap: View
|
||||||
private lateinit var modeSwitch: View
|
private lateinit var modeSwitch: View
|
||||||
private lateinit var btnMain: TextView
|
private lateinit var btnMain: TextView
|
||||||
private lateinit var btnReset: ImageView
|
private lateinit var btnReset: ImageView
|
||||||
private lateinit var btnSkip: ImageView
|
private lateinit var btnFinish: ImageView
|
||||||
private lateinit var tvTask: TextView
|
private lateinit var tvTask: TextView
|
||||||
private lateinit var tvTaskMeta: TextView
|
private lateinit var tvTaskMeta: TextView
|
||||||
private lateinit var tvTaskAction: TextView
|
private lateinit var tvTaskAction: TextView
|
||||||
@@ -84,7 +84,8 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
// 计时与到时结算仍然准确。
|
// 计时与到时结算仍然准确。
|
||||||
if (TimerCore.running) TimerCore.tick()
|
if (TimerCore.running) TimerCore.tick()
|
||||||
render()
|
render()
|
||||||
handler.postDelayed(this, 250L)
|
// 空闲且没拖动时 render 已经移除轮询,这里不再续命
|
||||||
|
if (TimerCore.running || dragging) handler.postDelayed(this, 250L)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,14 +96,13 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
ring = view.findViewById(R.id.ring)
|
ring = view.findViewById(R.id.ring)
|
||||||
tvTime = view.findViewById(R.id.tvTime)
|
tvTime = view.findViewById(R.id.tvTime)
|
||||||
tvModeLabel = view.findViewById(R.id.tvModeLabel)
|
tvModeLabel = view.findViewById(R.id.tvModeLabel)
|
||||||
tvDialHint = view.findViewById(R.id.tvDialHint)
|
|
||||||
dots = view.findViewById(R.id.dots)
|
dots = view.findViewById(R.id.dots)
|
||||||
pageDots = view.findViewById(R.id.pageDots)
|
pageDots = view.findViewById(R.id.pageDots)
|
||||||
dialWrap = view.findViewById(R.id.dialWrap)
|
dialWrap = view.findViewById(R.id.dialWrap)
|
||||||
modeSwitch = view.findViewById(R.id.modeSwitch)
|
modeSwitch = view.findViewById(R.id.modeSwitch)
|
||||||
btnMain = view.findViewById(R.id.btnMain)
|
btnMain = view.findViewById(R.id.btnMain)
|
||||||
btnReset = view.findViewById(R.id.btnReset)
|
btnReset = view.findViewById(R.id.btnReset)
|
||||||
btnSkip = view.findViewById(R.id.btnSkip)
|
btnFinish = view.findViewById(R.id.btnFinish)
|
||||||
tvTask = view.findViewById(R.id.tvTask)
|
tvTask = view.findViewById(R.id.tvTask)
|
||||||
tvTaskMeta = view.findViewById(R.id.tvTaskMeta)
|
tvTaskMeta = view.findViewById(R.id.tvTaskMeta)
|
||||||
tvTaskAction = view.findViewById(R.id.tvTaskAction)
|
tvTaskAction = view.findViewById(R.id.tvTaskAction)
|
||||||
@@ -112,7 +112,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
|
|
||||||
slop = ViewConfiguration.get(requireContext()).scaledTouchSlop
|
slop = ViewConfiguration.get(requireContext()).scaledTouchSlop
|
||||||
btnReset.tint(col(R.color.text_secondary))
|
btnReset.tint(col(R.color.text_secondary))
|
||||||
btnSkip.tint(col(R.color.text_secondary))
|
btnFinish.tint(col(R.color.text_secondary))
|
||||||
|
|
||||||
btnMain.setOnClickListener {
|
btnMain.setOnClickListener {
|
||||||
if (TimerCore.running) {
|
if (TimerCore.running) {
|
||||||
@@ -127,10 +127,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
TimerCore.reset()
|
TimerCore.reset()
|
||||||
render()
|
render()
|
||||||
}
|
}
|
||||||
btnSkip.setOnClickListener {
|
btnFinish.setOnClickListener { showFinishSheet() }
|
||||||
TimerCore.skip()
|
|
||||||
render()
|
|
||||||
}
|
|
||||||
view.findViewById<View>(R.id.taskCard).setOnClickListener { pickTask() }
|
view.findViewById<View>(R.id.taskCard).setOnClickListener { pickTask() }
|
||||||
segFocus.setOnClickListener {
|
segFocus.setOnClickListener {
|
||||||
if (!TimerCore.running) {
|
if (!TimerCore.running) {
|
||||||
@@ -175,6 +172,8 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
handler.removeCallbacks(ticker)
|
handler.removeCallbacks(ticker)
|
||||||
applyKeepScreen(false)
|
applyKeepScreen(false)
|
||||||
} else {
|
} else {
|
||||||
|
// 任务可能在别的页面被改名/改时长,重新显示时强制重读
|
||||||
|
cachedTaskId = Long.MIN_VALUE
|
||||||
render()
|
render()
|
||||||
handler.removeCallbacks(ticker)
|
handler.removeCallbacks(ticker)
|
||||||
handler.post(ticker)
|
handler.post(ticker)
|
||||||
@@ -237,20 +236,46 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
|
|||||||
renderPageDots()
|
renderPageDots()
|
||||||
renderDots(accent)
|
renderDots(accent)
|
||||||
renderTask()
|
renderTask()
|
||||||
renderHint()
|
|
||||||
applyKeepScreen(TimerCore.running && Prefs.keepScreenOn)
|
applyKeepScreen(TimerCore.running && Prefs.keepScreenOn)
|
||||||
|
// 空闲且没在拖动时不必每 250ms 重绘一次,省电也避免无谓 GC
|
||||||
|
if (!TimerCore.running && !dragging) handler.removeCallbacks(ticker)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderHint() {
|
/**
|
||||||
val text = when {
|
* 提前完成:先写原因,再按真实起止结束本轮。
|
||||||
TimerCore.running -> ""
|
* 原因会追加到任务备注并标记任务完成,任务页的已完成列表能看到备注与实际时段。
|
||||||
TimerCore.countUp -> getString(R.string.dial_hint_count_up)
|
*/
|
||||||
// 休息时长属于设置项,不引导用户在休息环上拖动
|
private fun showFinishSheet() {
|
||||||
TimerCore.mode == TimerCore.MODE_FOCUS -> getString(R.string.dial_hint)
|
if (TimerCore.elapsedNow() <= 0) {
|
||||||
else -> ""
|
Toast.makeText(requireContext(), R.string.finish_need_start, Toast.LENGTH_SHORT).show()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
tvDialHint.text = text
|
val ctx = requireContext()
|
||||||
tvDialHint.visible(text.isNotEmpty())
|
val sheet = SheetDialog(ctx)
|
||||||
|
val root = layoutInflater.inflate(R.layout.sheet_finish_reason, null)
|
||||||
|
val etReason = root.findViewById<EditText>(R.id.etFinishReason)
|
||||||
|
root.findViewById<View>(R.id.btnFinishNow).setOnClickListener {
|
||||||
|
val raw = etReason.text?.toString()?.trim().orEmpty()
|
||||||
|
// 休息阶段点完成不算任务完成,只按实际时长记一条未完成记录
|
||||||
|
val wasFocus = TimerCore.mode == TimerCore.MODE_FOCUS
|
||||||
|
val finish = TimerCore.finishEarly(wasFocus)
|
||||||
|
if (finish != null && wasFocus && finish.taskId > 0) {
|
||||||
|
Store.task(finish.taskId)?.let { task ->
|
||||||
|
if (raw.isNotEmpty()) {
|
||||||
|
val line = getString(R.string.task_note_finish, Dates.hms(finish.endAt), raw)
|
||||||
|
val note = if (task.note.isBlank()) line else "${task.note}\n$line"
|
||||||
|
Store.updateTask(task.copy(note = note))
|
||||||
|
}
|
||||||
|
Store.setTaskDone(finish.taskId, true)
|
||||||
|
}
|
||||||
|
(activity as? com.focusbox.app.ui.MainActivity)?.refreshAll()
|
||||||
|
Toast.makeText(ctx, R.string.finish_saved, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
sheet.dismiss()
|
||||||
|
render()
|
||||||
|
}
|
||||||
|
sheet.setContentView(root)
|
||||||
|
sheet.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderPageDots() {
|
private fun renderPageDots() {
|
||||||
|
|||||||
@@ -161,8 +161,10 @@ class TasksFragment : Fragment(R.layout.fragment_tasks) {
|
|||||||
private fun doneRange(task: Task, spans: Map<Long, SessionSpan>): String? {
|
private fun doneRange(task: Task, spans: Map<Long, SessionSpan>): String? {
|
||||||
val span = spans[task.id]
|
val span = spans[task.id]
|
||||||
if (span != null) {
|
if (span != null) {
|
||||||
return "${Dates.dateWithWeek(span.startAt)} " +
|
val range = "${Dates.dateWithWeek(span.startAt)} " +
|
||||||
"${Dates.hms(span.startAt)}-${Dates.hms(span.endAt)}"
|
"${Dates.hms(span.startAt)}-${Dates.hms(span.endAt)}"
|
||||||
|
// 记录里存的是实际专注秒数(不含暂停),不能拿起止时间差冒充
|
||||||
|
return if (span.seconds > 0) "$range · 专注${Dates.duration(span.seconds)}" else range
|
||||||
}
|
}
|
||||||
if (task.doneAt > 0) {
|
if (task.doneAt > 0) {
|
||||||
return "${Dates.dateWithWeek(task.doneAt)} ${Dates.hms(task.doneAt)}"
|
return "${Dates.dateWithWeek(task.doneAt)} ${Dates.hms(task.doneAt)}"
|
||||||
|
|||||||
@@ -87,6 +87,16 @@ object Prefs {
|
|||||||
get() = sp.getLong("t_end", 0L)
|
get() = sp.getLong("t_end", 0L)
|
||||||
set(v) = sp.edit().putLong("t_end", v).apply()
|
set(v) = sp.edit().putLong("t_end", v).apply()
|
||||||
|
|
||||||
|
/** 单调钟终点,墙钟被 NTP 改动时继续按它走时 */
|
||||||
|
var timerEndElapsed: Long
|
||||||
|
get() = sp.getLong("t_end_elapsed", 0L)
|
||||||
|
set(v) = sp.edit().putLong("t_end_elapsed", v).apply()
|
||||||
|
|
||||||
|
/** 保存终点时的 elapsedRealtime - currentTimeMillis,用于识别开机 */
|
||||||
|
var timerClockOffset: Long
|
||||||
|
get() = sp.getLong("t_clock_offset", 0L)
|
||||||
|
set(v) = sp.edit().putLong("t_clock_offset", 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()
|
||||||
@@ -118,6 +128,7 @@ object Prefs {
|
|||||||
.putBoolean("t_running", false)
|
.putBoolean("t_running", false)
|
||||||
.putLong("t_remaining", 0L)
|
.putLong("t_remaining", 0L)
|
||||||
.putLong("t_end", 0L)
|
.putLong("t_end", 0L)
|
||||||
|
.putLong("t_end_elapsed", 0L)
|
||||||
.putLong("t_started", 0L)
|
.putLong("t_started", 0L)
|
||||||
.putLong("t_accum", 0L)
|
.putLong("t_accum", 0L)
|
||||||
.apply()
|
.apply()
|
||||||
|
|||||||
21
src/main/res/drawable/ic_finish.xml
Normal file
21
src/main/res/drawable/ic_finish.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 完成:与左侧刷新图标同为 24dp 线性描边 + 黑色填充,运行时统一 tint -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#FF000000"
|
||||||
|
android:strokeWidth="1.8"
|
||||||
|
android:strokeLineCap="round"
|
||||||
|
android:pathData="M12,3.2 A8.8,8.8 0 1 1 11.99,3.2" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#FF000000"
|
||||||
|
android:strokeWidth="2.4"
|
||||||
|
android:strokeLineCap="round"
|
||||||
|
android:strokeLineJoin="round"
|
||||||
|
android:pathData="M7.8,12.2 L10.8,15.2 L16.4,9.2" />
|
||||||
|
</vector>
|
||||||
@@ -113,15 +113,6 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center_vertical" />
|
android:gravity="center_vertical" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvDialHint"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/dial_hint"
|
|
||||||
style="@style/T.Caption" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -153,13 +144,13 @@
|
|||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/btnSkip"
|
android:id="@+id/btnFinish"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:background="@drawable/bg_icon_btn"
|
android:background="@drawable/bg_icon_btn"
|
||||||
android:padding="14dp"
|
android:padding="14dp"
|
||||||
android:src="@drawable/ic_skip"
|
android:src="@drawable/ic_finish"
|
||||||
android:contentDescription="@string/skip" />
|
android:contentDescription="@string/finish" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
|
|||||||
69
src/main/res/layout/sheet_finish_reason.xml
Normal file
69
src/main/res/layout/sheet_finish_reason.xml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 提前完成:圆角底部弹层,记录原因后结束本轮专注 -->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@drawable/bg_sheet">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="4dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:background="@color/divider" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingStart="20dp"
|
||||||
|
android:paddingEnd="20dp"
|
||||||
|
android:paddingTop="14dp"
|
||||||
|
android:paddingBottom="22dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/finish_reason_title"
|
||||||
|
style="@style/T.Title" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:text="@string/finish_reason_hint"
|
||||||
|
style="@style/T.Meta" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etFinishReason"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:background="@drawable/bg_field"
|
||||||
|
android:gravity="top|start"
|
||||||
|
android:hint="@string/finish_reason_input_hint"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:maxLines="5"
|
||||||
|
android:minLines="3"
|
||||||
|
android:paddingStart="14dp"
|
||||||
|
android:paddingEnd="14dp"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:textColor="@color/text"
|
||||||
|
android:textColorHint="@color/text_tertiary"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnFinishNow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginTop="18dp"
|
||||||
|
android:background="@drawable/bg_btn_primary"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/finish_now"
|
||||||
|
android:textColor="@color/on_brand"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
@@ -21,6 +21,13 @@
|
|||||||
<string name="skip">跳过</string>
|
<string name="skip">跳过</string>
|
||||||
<string name="stop">结束本轮</string>
|
<string name="stop">结束本轮</string>
|
||||||
<string name="finish">完成</string>
|
<string name="finish">完成</string>
|
||||||
|
<string name="finish_reason_title">提前结束</string>
|
||||||
|
<string name="finish_reason_hint">写下原因,会记入这次任务的备注并显示在任务列表</string>
|
||||||
|
<string name="finish_reason_input_hint">例如:临时有会 / 身体不舒服</string>
|
||||||
|
<string name="finish_now">立即结束</string>
|
||||||
|
<string name="finish_saved">已结束并记入任务备注</string>
|
||||||
|
<string name="finish_need_start">请先开始专注</string>
|
||||||
|
<string name="task_note_finish">【提前结束 %1$s】%2$s</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