已完成与时长统一累计口径、20色重排高反差、任务时长可输入、文案去空格
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
# 变更记录
|
||||
|
||||
## 2026-12-02 · 已完成与时长统一累计口径、20色重排高反差、任务时长可输入、文案去空格
|
||||
|
||||
- 同步源码更新 6 个文件(新增/修改 6,删除 0)。
|
||||
|
||||
## 2026-12-01 · 目标达成允许超100%、项目20色重配色差、锁屏权限自检、立即创建预选项目(v3.4)
|
||||
|
||||
- 统计页顶部目标达成不再封顶 100%:`TodayStat.goalProgress` 去掉上限,新增 `goalPercent` 按真实分钟数四舍五入显示(如 128%);圆环仍画满一圈表示已达成的视觉满格。
|
||||
|
||||
@@ -8,8 +8,11 @@ data class Project(
|
||||
val archived: Boolean,
|
||||
val sort: Int,
|
||||
val openTasks: Int,
|
||||
/** 任务本体中已完成的数量(含手动勾选完成的),只用于「任务总数」与进度条 */
|
||||
val doneTasks: Int,
|
||||
/** 累计专注秒数(该项目下所有专注记录之和,含重复实例) */
|
||||
val focusSeconds: Int,
|
||||
/** 累计真实完成次数(已完成专注记录的条数),项目页「已完成N次」展示用 */
|
||||
val pomodoros: Int,
|
||||
/** 排序序号:非置顶项目按它升序排,数字越小越靠前 */
|
||||
val sortIndex: Int = 0,
|
||||
|
||||
@@ -81,10 +81,15 @@ class ProjectAdapter(
|
||||
name.text = p.name
|
||||
colorBar.background = ctx.roundBg(p.color, 2f)
|
||||
|
||||
// 项目页只统计项目下创建的任务:总数、已完成数、累计专注时长
|
||||
// 项目页统计口径(全周期累计,不是今日,也没有时间上限):
|
||||
// 任务数 = 项目下创建的任务本体(不含重复实例/完成记录副本);
|
||||
// 已完成 = 真实跑完的专注次数(sessions.completed = 1 的条数),
|
||||
// 重复任务每完成一轮就 +1,和「累计时长」同源;
|
||||
// 手动勾选完成、周期滚动时的自动完成都没有专注记录,不计入;
|
||||
// 时长 = 该项目全部专注记录秒数之和。
|
||||
val parts = ArrayList<String>(3)
|
||||
parts.add(ctx.getString(R.string.project_tasks_total, p.totalTasks))
|
||||
if (p.doneTasks > 0) parts.add(ctx.getString(R.string.project_tasks_done, p.doneTasks))
|
||||
if (p.pomodoros > 0) parts.add(ctx.getString(R.string.project_tasks_done, p.pomodoros))
|
||||
if (p.focusSeconds >= 60) parts.add(Dates.duration(p.focusSeconds))
|
||||
meta.text = parts.joinToString(" · ")
|
||||
|
||||
|
||||
@@ -612,6 +612,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "3.4"
|
||||
const val VERSION = "3.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ import com.focusbox.app.ui.SheetDialog
|
||||
import com.focusbox.app.util.Dates
|
||||
import com.focusbox.app.util.Prefs
|
||||
import com.focusbox.app.util.col
|
||||
import com.focusbox.app.util.dpi
|
||||
import com.focusbox.app.util.makeChip
|
||||
import com.focusbox.app.util.roundBg
|
||||
import com.focusbox.app.util.visible
|
||||
import java.util.Calendar
|
||||
|
||||
@@ -72,6 +74,8 @@ class TaskSheet(
|
||||
etTitle.setText(existing?.title ?: "")
|
||||
etNote.setText(existing?.note ?: "")
|
||||
renderFocus()
|
||||
// 点数字直接输入时长,微调按钮保留做快速微调
|
||||
tvFocus.setOnClickListener { inputFocus() }
|
||||
|
||||
root.findViewById<View>(R.id.btnFocusMinus).setOnClickListener {
|
||||
focusMin = (focusMin - 5).coerceAtLeast(TimerCore.MIN_MINUTES)
|
||||
@@ -173,6 +177,88 @@ class TaskSheet(
|
||||
tvFocus.text = context.getString(R.string.minutes_value, focusMin)
|
||||
}
|
||||
|
||||
/**
|
||||
* 专注时长支持直接输入(与设置页「每日目标」同一套交互)。
|
||||
*
|
||||
* 微调按钮一次只有 5 分钟,25 → 90 要点十几次;
|
||||
* 输入后统一夹紧到 [TimerCore.MIN_MINUTES, TimerCore.MAX_MINUTES]。
|
||||
*/
|
||||
private fun inputFocus() {
|
||||
val ctx = context
|
||||
val dialog = android.app.Dialog(ctx)
|
||||
dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)
|
||||
|
||||
val panel = LinearLayout(ctx).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
background = ctx.roundBg(ctx.col(R.color.surface), 16f, ctx.col(R.color.card_stroke), 1f)
|
||||
setPadding(dpi(20f), dpi(20f), dpi(20f), dpi(14f))
|
||||
}
|
||||
panel.addView(TextView(ctx).apply {
|
||||
text = ctx.getString(R.string.focus_duration)
|
||||
textSize = 16f
|
||||
typeface = android.graphics.Typeface.DEFAULT_BOLD
|
||||
setTextColor(ctx.col(R.color.text))
|
||||
})
|
||||
val et = EditText(ctx).apply {
|
||||
inputType = android.text.InputType.TYPE_CLASS_NUMBER
|
||||
setText(focusMin.toString())
|
||||
setSelection(text.length)
|
||||
textSize = 15f
|
||||
setTextColor(ctx.col(R.color.text))
|
||||
background = ctx.roundBg(ctx.col(R.color.surface_alt), 12f)
|
||||
setPadding(dpi(14f), dpi(12f), dpi(14f), dpi(12f))
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
).apply { topMargin = dpi(14f) }
|
||||
}
|
||||
panel.addView(et)
|
||||
|
||||
val btnRow = LinearLayout(ctx).apply {
|
||||
orientation = LinearLayout.HORIZONTAL
|
||||
gravity = android.view.Gravity.END
|
||||
setPadding(0, dpi(12f), 0, 0)
|
||||
}
|
||||
fun btn(labelRes: Int, onClick: () -> Unit) = TextView(ctx).apply {
|
||||
text = ctx.getString(labelRes)
|
||||
textSize = 14f
|
||||
typeface = android.graphics.Typeface.DEFAULT_BOLD
|
||||
gravity = android.view.Gravity.CENTER
|
||||
setTextColor(ctx.col(R.color.brand))
|
||||
background = ctx.roundBg(ctx.col(R.color.surface_alt), 12f)
|
||||
setPadding(dpi(22f), dpi(10f), dpi(22f), dpi(10f))
|
||||
setOnClickListener { onClick() }
|
||||
}
|
||||
btnRow.addView(btn(R.string.cancel) { dialog.dismiss() })
|
||||
btnRow.addView(
|
||||
btn(R.string.save) {
|
||||
val input = et.text.toString().trim().toIntOrNull()
|
||||
if (input == null) {
|
||||
et.error = " "
|
||||
} else {
|
||||
focusMin = input.coerceIn(TimerCore.MIN_MINUTES, TimerCore.MAX_MINUTES)
|
||||
renderFocus()
|
||||
dialog.dismiss()
|
||||
}
|
||||
},
|
||||
LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
).apply { marginStart = dpi(10f) },
|
||||
)
|
||||
panel.addView(btnRow)
|
||||
|
||||
dialog.setContentView(panel)
|
||||
dialog.show()
|
||||
et.post {
|
||||
et.requestFocus()
|
||||
runCatching {
|
||||
(ctx.getSystemService(Context.INPUT_METHOD_SERVICE) as? android.view.inputmethod.InputMethodManager)
|
||||
?.showSoftInput(et, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 重复单位五选一;只有真正的周期重复(天/周/月)才露出间隔步进器 */
|
||||
private fun renderRepeat() {
|
||||
val ctx = context
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package com.focusbox.app.util
|
||||
|
||||
/**
|
||||
* 项目配色:20 色,**全部按感知色差挑选**,任意两色在 CIE ΔE00 上至少差 13。
|
||||
* 项目配色:20 色。
|
||||
*
|
||||
* 排布原则:
|
||||
* 1. 前 8 个是 v3.13 及以前的原始配色,顺序与色值一律不变 ——
|
||||
* 老项目的颜色不能因为扩容而整体位移;
|
||||
* 2. 第 9–16 个是同一色相家族的「浅色版」:浅粉 / 浅橙 / 浅黄 / 浅绿 /
|
||||
* 浅青 / 浅蓝 / 浅紫 / 浅玫,深色主题下也够亮,和原始 8 色一眼能分开;
|
||||
* 3. 第 17–20 个是「深色版」:深棕 / 深蓝 / 深绿 / 深紫,补足低明度端;
|
||||
* 4. 每行 10 个:第一行暖色 → 浅色过渡,第二行浅色 → 深色收尾。
|
||||
*
|
||||
* 为什么不用「色相环等分 18°」:圆点和饼图扇区都很小,色相差 15° 而明度相同
|
||||
* 时(v3.14 的 20 色)ΔE00 只有 7–11,肉眼几乎分不出来;拉开明度差才能真区分。
|
||||
* 取舍说明(改之前先读):
|
||||
* 1. 前 8 色是 v3.13 及以前就有的配色,色值与顺序**永不改动** ——
|
||||
* 老项目已经用了这些颜色,扩容不能让它整体位移;
|
||||
* 2. 20 个颜色要塞进一个色相环,平均只能分到 18°,所以「两两都不像」
|
||||
* 在数学上做不到。真正有效的区分手段是**同时拉开色相和明度**,
|
||||
* 这也是新增 12 色的挑选标准:亮的一档(L≈65)与暗的一档(L≈38)
|
||||
* 交替出现,相邻格子永远一亮一暗,不会出现「一排浅色看起来都一样」;
|
||||
* 3. 所有颜色两两之间 CIE ΔE00 ≥ 15(前 8 色里 #4C8C4A / #3F7F6E 那对 14.3
|
||||
* 是历史配色,不在本次调整范围)。上一版按「同色相浅色版」做的 8 个浅色
|
||||
* (浅粉/浅橙/浅黄…)虽然 ΔE 也够,但明度全挤在 70 附近,肉眼看着一样,已整体废弃;
|
||||
* 4. 排序按「暖 → 冷」铺开,同色相的深浅两档分到两排,避免同屏对比。
|
||||
*/
|
||||
object Palette {
|
||||
|
||||
@@ -26,20 +27,20 @@ object Palette {
|
||||
0xFF3B7DD8.toInt(), // 靛蓝
|
||||
0xFF6C5CE7.toInt(), // 紫
|
||||
0xFFB7548E.toInt(), // 玫红
|
||||
// ---- 浅色 8 个:同色相的轻量版,和上面 8 色明度拉开
|
||||
0xFFF0A6A0.toInt(), // 浅粉
|
||||
0xFFF3C08B.toInt(), // 浅橙
|
||||
0xFFE3D27C.toInt(), // 浅黄
|
||||
0xFF9CCB86.toInt(), // 浅绿
|
||||
0xFF8FCFC4.toInt(), // 浅青
|
||||
0xFF8FB8E8.toInt(), // 浅蓝
|
||||
0xFFB3A4E8.toInt(), // 浅紫
|
||||
0xFFE3A3C6.toInt(), // 浅玫
|
||||
// ---- 深色 4 个:补低明度端
|
||||
0xFF7A4A34.toInt(), // 深棕
|
||||
0xFF1F3A66.toInt(), // 深蓝
|
||||
0xFF2B5C3F.toInt(), // 深绿
|
||||
0xFF5B4C8C.toInt(), // 深紫
|
||||
// ---- 第一排剩下 2 个:亮青 + 亮黄,和上面的玫红、琥珀形成强反差
|
||||
0xFF56D3DC.toInt(), // 亮青
|
||||
0xFFE0D867.toInt(), // 亮黄
|
||||
// ---- 第二排 10 个:深/浅交替,相邻永远一亮一暗
|
||||
0xFF3523A9.toInt(), // 深蓝紫(深)
|
||||
0xFFA67DCA.toInt(), // 淡紫(浅)
|
||||
0xFF91743B.toInt(), // 卡其(深)
|
||||
0xFF97E067.toInt(), // 嫩绿(浅)
|
||||
0xFFA92347.toInt(), // 深红(深)
|
||||
0xFF43C79B.toInt(), // 薄荷(浅)
|
||||
0xFF9D26BA.toInt(), // 品红紫(深)
|
||||
0xFF91A63A.toInt(), // 橄榄绿(浅,偏中性)
|
||||
0xFFCA7D87.toInt(), // 灰粉(浅)
|
||||
0xFF3495AD.toInt(), // 湖蓝(深)
|
||||
)
|
||||
|
||||
/** 未分类用中性灰,避免和自建项目争注意力 */
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
<string name="p_mid">中</string>
|
||||
<string name="p_high">高</string>
|
||||
<string name="focus_duration">专注时长</string>
|
||||
<string name="minutes_value">%1$d 分钟</string>
|
||||
<string name="minutes_value">%1$d分钟</string>
|
||||
<string name="repeat">重复</string>
|
||||
<string name="repeat_none">不重复</string>
|
||||
<string name="repeat_anytime">随时</string>
|
||||
@@ -132,7 +132,7 @@
|
||||
<string name="projects_title">项目</string>
|
||||
<string name="project_no_tasks">还没有添加任务</string>
|
||||
<string name="project_tasks_total">%1$d个任务</string>
|
||||
<string name="project_tasks_done">%1$d已完成</string>
|
||||
<string name="project_tasks_done">已完成%1$d次</string>
|
||||
<string name="project_task_last_done">最近%1$s完成</string>
|
||||
<string name="project_task_done_count">累计%1$d次</string>
|
||||
<string name="project_expand_done">展开完成记录(%1$d)</string>
|
||||
@@ -249,7 +249,7 @@
|
||||
<string name="task_meta_overdue">已逾期 · %1$s</string>
|
||||
<string name="task_priority_high">高优先</string>
|
||||
<!-- %1$s 项目名 / %2$d 专注分钟 / %3$d 完成次数 -->
|
||||
<string name="task_card_meta">%1$s · %2$d 分钟 · 已完成 %3$d 次</string>
|
||||
<string name="task_card_meta">%1$s · %2$d分钟 · 已完成%3$d次</string>
|
||||
<string name="stat_today_minutes">%1$d分钟</string>
|
||||
<!-- %1$d 连续天数 / %2$d 每日目标分钟 -->
|
||||
<string name="stat_streak">连续专注%1$d天 · 目标%2$d分钟</string>
|
||||
|
||||
Reference in New Issue
Block a user