64 Commits
v1.2 ... v3.3

Author SHA1 Message Date
XIGE
ae75410e9b CHANGELOG:3.3 发布条目(去除自动计数条目) 2026-12-01 21:41:44 +08:00
XIGE
234df41f64 发布 3.3:版本号 3.3 / versionCode 70 2026-12-01 21:40:20 +08:00
XIGE
aad58da3b9 CHANGELOG:v3.15 手写条目(去除自动计数条目) 2026-12-01 21:10:17 +08:00
XIGE
0a7d5fda8c 选任务即开始、任务卡正在专注、饼图引线回归几何分侧(v3.15) 2026-12-01 21:08:29 +08:00
XIGE
ec286bcc6b CHANGELOG:v3.14 手写条目(去除自动计数条目) 2026-12-01 20:41:25 +08:00
XIGE
853186015d 项目色板20色、删除级联清理、未关联数据清理、饼图左右各三、手动完成标记(v3.14) 2026-12-01 20:40:39 +08:00
XIGE
1df122af48 CHANGELOG:v3.13 手写条目(去除自动计数条目) 2026-12-01 19:01:35 +08:00
XIGE
177c965894 饼图标注回到6条并在下方完整列出其余切片(v3.13) 2026-12-01 19:00:43 +08:00
XIGE
c9c7a79349 CHANGELOG:v3.12 手写条目(去除自动计数条目) 2026-12-01 18:32:39 +08:00
XIGE
320554381e 删除改整系列软删除、系列统计与饼图归属修正(v3.12) 2026-12-01 18:30:57 +08:00
XIGE
a1e200a1d6 CHANGELOG:v3.11 手写条目(去除自动计数条目) 2026-12-01 18:00:33 +08:00
XIGE
256ccfe1ae 饼图按系列根任务与任务当前项目归并,选择器改为立即创建(v3.11) 2026-12-01 17:59:28 +08:00
XIGE
0058efe5df CHANGELOG:v3.10 手写条目(去除自动计数条目) 2026-12-01 17:32:18 +08:00
XIGE
6989dc0c68 项目展开完成记录加开始按钮,专注页无任务改为立即创建(v3.10) 2026-12-01 17:31:24 +08:00
XIGE
43b12b1bf4 CHANGELOG:v3.9 手写条目(去除自动计数条目) 2026-12-01 16:53:20 +08:00
XIGE
fcfd167623 项目任务行恢复统计口径与完成记录对齐任务页(v3.9) 2026-12-01 16:52:28 +08:00
XIGE
44b0baacca 重复任务自动完成与项目页口径对齐(v3.8) 2026-12-01 16:28:21 +08:00
XIGE
ce48d805fc 专注选任务、任务页与项目页口径重整(v3.7) 2026-12-01 14:51:04 +08:00
XIGE
65f56490e9 修复任务图标间距与项目编辑键盘遮挡(v3.6) 2026-12-01 14:06:17 +08:00
XIGE
35a7c4a785 CHANGELOG:v3.5 手写条目(去除自动计数条目) 2026-12-01 13:42:51 +08:00
XIGE
ab8840d421 回退v3.3基线并删除内置收件箱项目(v3.5) 2026-12-01 13:42:12 +08:00
XIGE
ce4ec2cd51 项目页统计口径重构与执行入口移除(v3.4) 2026-12-01 13:18:59 +08:00
XIGE
467d34afe8 图标间距减半与逾期任务过滤(v3.3) 2026-12-01 12:54:03 +08:00
XIGE
256c0d4540 CHANGELOG:v3.2 数字去空格与完成副本去重条目(去除自动计数条目) 2026-12-01 12:33:15 +08:00
XIGE
30b385a4d9 项目页数字去空格、任务图标留间距、按session时间排除历史完成副本去重(v3.2) 2026-12-01 12:33:06 +08:00
XIGE
8a7147b299 CHANGELOG:v3.1 统计补全与完成记录折叠条目(去除自动计数条目) 2026-12-01 11:58:16 +08:00
XIGE
47294f4fcf 项目统计补累计专注分钟、展开行点开编辑删除、置顶前移并统一圆圈规格、已完成任务折叠(v3.1) 2026-12-01 11:58:05 +08:00
XIGE
8ad5441ba4 CHANGELOG:v3.0 项目列表展开任务与统计条目(去除自动计数条目) 2026-12-01 11:24:23 +08:00
XIGE
9c8e2eb534 项目列表点击就地展开任务与统计,任务页零改动(v3.0) 2026-12-01 11:24:03 +08:00
XIGE
eb3d961b0a CHANGELOG:v2.9 回退字体并删除分割线条目(去除自动计数条目) 2026-11-30 10:00:50 +08:00
XIGE
9fdecfb1b9 回退打包字体,删除横屏分割线(v2.9) 2026-11-30 10:00:37 +08:00
XIGE
a8446bcf51 CHANGELOG:v2.8 横屏时间字体SourceCodePro条目(去除自动计数条目) 2026-11-30 09:37:39 +08:00
XIGE
54df5b398c 横屏大时间换SourceCodeProBold修墨迹边距不均导致的分割线左右间隙不等(v2.8) 2026-11-30 09:37:29 +08:00
XIGE
8a1f41ca9d CHANGELOG:v2.7 删除CountdownFit回退v2.3行为条目(去除自动计数条目) 2026-11-30 09:12:28 +08:00
XIGE
4a648669ea 删除CountdownFit,LockScreenActivity/LockOverlay恢复v2.3,竖屏专注时间恢复原字号(v2.7) 2026-11-30 09:12:10 +08:00
XIGE
60fd3d1044 CHANGELOG:v2.6 回退v2.3基线与等宽缩号条目(去除自动计数条目) 2026-11-30 08:57:43 +08:00
XIGE
ed7927af1d 回退v2.3布局基线,撤销autoSize;新增CountdownFit按实测字宽把6位倒计时缩到与时钟等宽修复左右间隙不等(v2.6) 2026-11-30 08:57:32 +08:00
XIGE
2d999edc0c CHANGELOG:v2.5 autoSize防溢出条目(去除自动计数条目) 2026-11-30 08:40:27 +08:00
XIGE
4e062923ef 分割线等距修正:大时间autoSize自动缩号(40..130sp)修复6位数倒计时溢出越线,贴线对齐间隙恒24dp(v2.5) 2026-11-30 08:40:17 +08:00
XIGE
7d8995ead0 CHANGELOG:v2.4 分割线左右等距条目(去除自动计数条目) 2026-11-30 08:19:59 +08:00
XIGE
4444b18b29 分割线左右等距:左栏右对齐右栏左对齐各距线24dp,tnum等宽数字,修复系统字体数字非等宽导致的间隙不等(v2.4) 2026-11-30 08:19:49 +08:00
XIGE
11dc2825cc CHANGELOG:v2.3 分割线中列镜像对齐条目(去除自动计数条目) 2026-11-30 07:52:06 +08:00
XIGE
2dd7f8b506 分割线中列完整镜像左右两栏:三列同高同顶,线中心严格等于时间中心,修复v2.2锚点列偏矮居中失效(v2.3) 2026-11-30 07:51:44 +08:00
XIGE
3277fa5826 CHANGELOG:v2.2 分割线镜像锚点对齐条目(去除自动计数条目) 2026-11-30 01:29:39 +08:00
XIGE
00a01b3f22 分割线镜像锚点对齐:中心与左右时间文字严格重合,修复下移(v2.2) 2026-11-30 01:28:49 +08:00
XIGE
01ca852b2a CHANGELOG:v2.1 条目细化(去除自动计数条目) 2026-11-30 01:09:35 +08:00
XIGE
8e7de267a4 分割线降至92dp与时间等高;改项目时迁移系列实例与完成记录修复双项目重复;普通任务按重要+紧急总分排序,版本 2.1 2026-11-30 01:09:06 +08:00
XIGE
9305bd588b CHANGELOG:v2.0 条目细化(去除自动计数条目) 2026-11-30 00:44:43 +08:00
XIGE
77319b30da 分割线恢复原始静态View实现高度150dp;逾期任务排在置顶之后列表最前,版本 2.0 2026-11-30 00:44:14 +08:00
XIGE
8694908305 CHANGELOG:v1.9 条目细化(去除自动计数条目) 2026-11-30 00:29:32 +08:00
XIGE
5b58596727 横屏分割线改纯XML结构化对齐(match_parent继承时间行高),删除运行时高度代码,版本 1.9 2026-11-30 00:28:57 +08:00
XIGE
7762e463d6 CHANGELOG:v1.8 条目细化(去除自动计数条目) 2026-11-30 00:10:38 +08:00
XIGE
3cad26fbdb 分割线改fontMetrics直接计算修复消失;删除线按墨迹中点自绘居中;置顶圆圈粗细与底部对齐调整,版本 1.8 2026-11-30 00:10:10 +08:00
XIGE
035da90a76 CHANGELOG:v1.7 条目细化(去除自动计数条目) 2026-11-29 23:34:19 +08:00
XIGE
68b9961784 完成文案改字;横屏分割线只分时间;置顶图标黑色bug修复恢复品牌蓝;完成删除线恢复,版本 1.7 2026-11-29 23:33:47 +08:00
XIGE
d03fb45adf CHANGELOG:v1.6 条目细化(去除自动计数条目) 2026-11-29 23:10:15 +08:00
XIGE
e7089ae76b 完成任务删除线只画任务名;置顶改圆圈箭头图标;饼图中心删小字居中;悬浮窗权限已开启不可点;每日目标可输入去上限,版本 1.6 2026-11-29 23:09:39 +08:00
XIGE
1d355693be CHANGELOG:v1.5 条目细化 2026-11-29 21:03:39 +08:00
XIGE
93faf6d21e 悬浮窗补齐遮状态栏与横竖屏排版,解锁残留秒级自动关窗,版本 1.5 2026-11-29 21:02:55 +08:00
XIGE
a5cd605a5c CHANGELOG:v1.4 条目细化 2026-11-29 20:35:32 +08:00
XIGE
05a3462c6e 锁屏倒计时主链路改悬浮窗不受后台弹出限制;设置页加悬浮窗权限入口;版本 1.4 2026-11-29 20:34:23 +08:00
XIGE
c8cc773fef CHANGELOG:v1.3 条目细化 2026-11-29 14:41:38 +08:00
XIGE
c0182de5e5 竖屏删工作中提示;横屏时间加大到130sp、下方文字统一规格收紧间距;版本 1.3 2026-11-29 14:40:59 +08:00
XIGE
65dd5bfe91 CHANGELOG:v1.2 条目细化(去除自动计数条目) 2026-11-29 14:20:53 +08:00
27 changed files with 1999 additions and 248 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,8 @@
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- 锁屏全屏倒计时:计时中锁屏亮屏时把全屏页盖在锁屏上 --> <!-- 锁屏全屏倒计时:计时中锁屏亮屏时把全屏页盖在锁屏上 -->
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" /> <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<!-- 锁屏悬浮窗:鸿蒙拦 Activity 后台启动,改用 WindowManager 直接把倒计时画在锁屏上(addView 不受"后台弹出界面"限制) -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" /> <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
package com.focusbox.app.model package com.focusbox.app.model
/** 项目(清单)。收件箱固定 id=1,不可删除。 */ /** 项目(清单)。id=0 表示未分类,不对应项目行;项目行均可编辑/归档/删除。 */
data class Project( data class Project(
val id: Long, val id: Long,
val name: String, val name: String,
@@ -62,6 +62,30 @@ data class Task(
/** 一条专注记录的起止时刻与实际秒数,用于在已完成任务上显示真实工作时段。 */ /** 一条专注记录的起止时刻与实际秒数,用于在已完成任务上显示真实工作时段。 */
data class SessionSpan(val startAt: Long, val endAt: Long, val seconds: Int = 0) data class SessionSpan(val startAt: Long, val endAt: Long, val seconds: Int = 0)
/**
* 项目卡展开后的一条任务行:任务本体 + 三项统计。
* 仅用于项目页展开列表,任务页的 Task 口径不变。
*/
data class ProjectTaskStat(
val task: Task,
/** 最近一次完成时刻(源任务 done_at 与该任务 sessions 最近 end_at 取大),0 表示未完成过 */
val lastDoneAt: Long,
/** 累计完成次数(done_pomodoros;勾选完成且无 session 时至少 1) */
val doneCount: Int,
/** 累计专注秒数(sessions 里该任务的 seconds 之和) */
val focusSeconds: Int,
)
/** 项目页一条完成记录:对应一条已完成的任务行(与任务页完成记录同源)。 */
data class ProjectCompletion(
val taskId: Long,
val taskTitle: String,
val note: String,
val startAt: Long,
val endAt: Long,
val seconds: Int,
)
/** 提前完成时交给 UI 落备注的实际专注信息 */ /** 提前完成时交给 UI 落备注的实际专注信息 */
data class FocusFinish( data class FocusFinish(
val taskId: Long, val taskId: Long,

View File

@@ -0,0 +1,147 @@
package com.focusbox.app.service
import android.content.Context
import android.content.res.Configuration
import android.graphics.PixelFormat
import android.os.Build
import android.provider.Settings
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import android.widget.TextView
import com.focusbox.app.R
import com.focusbox.app.data.Store
import com.focusbox.app.util.Dates
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
/**
* 锁屏悬浮窗:计时中锁屏/灭屏时,把黑底倒计时窗口直接画在锁屏之上。
*
* 为什么用悬浮窗:鸿蒙 4.0 对「后台弹出界面」的限制只拦 startActivity
* (实测开了权限也拦,全屏意图灭屏投递也不可靠),而 WindowManager.addView
* 悬浮窗不属于 Activity 启动,只要用户授了「悬浮窗」权限就能稳定盖在锁屏上
* ——这正是专注清单等 App 锁屏显示的做法。
*
* 窗口内容直接复用锁屏页布局(activity_lock_screen),inflate 时系统按当前
* 横竖屏自动选 layout 或 layout-land,旋转后重建窗口即可切换排版。
* FLAG_NOT_FOCUSABLE 不抢按键(不影响锁屏密码输入),点击任意处关闭。
*/
object LockOverlay {
private var root: View? = null
private var wm: WindowManager? = null
private var orientation = Configuration.ORIENTATION_PORTRAIT
private val clockFmt = SimpleDateFormat("HH:mm", Locale.getDefault())
/** 悬浮窗窗口是否正显示在锁屏上 */
fun isShowing(): Boolean = root != null
/** 用户是否已授予「悬浮窗」权限 */
fun canShow(context: Context): Boolean = Settings.canDrawOverlays(context)
/** 显示(幂等):已在显示或无权限时不重复添加 */
fun show(context: Context) {
if (root != null || !canShow(context)) return
try {
val ctx = context.applicationContext
val manager = ctx.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val view = LayoutInflater.from(ctx).inflate(R.layout.activity_lock_screen, null)
view.setOnClickListener { hide() }
// API 26+ 用应用悬浮窗类型;更旧版本退回 TYPE_PHONE(本应用 minSdk 24)
val type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
} else {
@Suppress("DEPRECATION")
WindowManager.LayoutParams.TYPE_PHONE
}
// 关键:EMUI 把悬浮窗限制在状态栏以下的内容区里(顶部时间/信号/电池露出来)。
// 对策是把窗口做得比屏幕更大并向上顶出——高度补上状态栏和导航栏,
// y 偏移取负的状态栏高度,配 FLAG_LAYOUT_NO_LIMITS 允许越界绘制,
// 黑底就完整盖住状态栏区域(护眼滤镜类 App 同款做法)
val res = ctx.resources
val sbId = res.getIdentifier("status_bar_height", "dimen", "android")
val navId = res.getIdentifier("navigation_bar_height", "dimen", "android")
val statusBar = if (sbId > 0) res.getDimensionPixelSize(sbId) else 0
val navBar = if (navId > 0) res.getDimensionPixelSize(navId) else 0
val lp = WindowManager.LayoutParams(
res.displayMetrics.widthPixels,
res.displayMetrics.heightPixels + statusBar + navBar,
type,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
or WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
PixelFormat.TRANSLUCENT,
)
lp.gravity = Gravity.TOP
lp.x = 0
lp.y = -statusBar
manager.addView(view, lp)
root = view
wm = manager
orientation = ctx.resources.configuration.orientation
render(view)
} catch (_: Exception) {
root = null
wm = null
}
}
/** 关闭(幂等):窗口不存在时无事发生 */
fun hide() {
val view = root ?: return
root = null
wm?.let { runCatching { it.removeView(view) } }
wm = null
}
/**
* 每秒刷新读数;顺带做两件保活级检查:
* 1. 用户已解锁(keyguard 解除)→ 自动关窗——不依赖 USER_PRESENT 广播,
* 广播在个别 ROM 上时序不稳,靠这秒级兜底保证解锁后不留全屏黑窗挡桌面;
* 2. 横竖屏变化 → 重建窗口换对应排版(悬浮窗不经过 Activity 重建)。
*/
fun update(context: Context) {
val view = root ?: return
val km = context.getSystemService(Context.KEYGUARD_SERVICE) as android.app.KeyguardManager
if (!km.isKeyguardLocked()) {
hide()
return
}
val current = context.resources.configuration.orientation
if (current != orientation) {
hide()
show(context)
return
}
render(view)
}
private fun render(view: View) {
val now = TimerCore.displayNow()
// 计时结束:窗口使命完成,自动关闭
if (!TimerCore.running && now <= 0) {
hide()
return
}
val cal = Calendar.getInstance()
view.findViewById<TextView>(R.id.tvLockDate)?.text =
"${Dates.mdLong(cal.timeInMillis)} 星期${Dates.weekdayShort(weekdayIndex(cal))}"
view.findViewById<TextView>(R.id.tvLockClock)?.text = clockFmt.format(cal.time)
view.findViewById<TextView>(R.id.tvLockCountdown)?.text = Dates.clock(now)
val task = if (TimerCore.taskId > 0) Store.task(TimerCore.taskId)?.title else null
view.findViewById<TextView>(R.id.tvLockTask)?.text =
task?.takeIf { it.isNotBlank() } ?: view.context.getString(R.string.notif_no_task)
}
/** Calendar 的 DAY_OF_WEEK(周日=1)转成 weekdayShort 的下标(周一=0 … 周日=6) */
private fun weekdayIndex(cal: Calendar): Int = (cal.get(Calendar.DAY_OF_WEEK) + 5) % 7
}

View File

@@ -53,6 +53,8 @@ class TimerService : Service() {
// 只推进状态,不再每秒重发通知:通知里的时间是系统的 Chronometer 在走, // 只推进状态,不再每秒重发通知:通知里的时间是系统的 Chronometer 在走,
// 每秒 notify 反而会让锁屏上的计时被系统限流后"冻住"。 // 每秒 notify 反而会让锁屏上的计时被系统限流后"冻住"。
TimerCore.tick() TimerCore.tick()
// 锁屏悬浮窗的读数刷新(窗口存在时每秒重画日期/时钟/倒计时)
LockOverlay.update(this@TimerService)
handler.postDelayed(this, 1000L) handler.postDelayed(this, 1000L)
} }
} }
@@ -60,8 +62,8 @@ class TimerService : Service() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
TimerCore.addListener(onStateChanged) TimerCore.addListener(onStateChanged)
// 锁屏全屏倒计时:计时中亮屏(用户按电源键偷看)→ 发全屏意图把 // 锁屏倒计时主链路:悬浮窗(WindowManager 直接画在锁屏上,
// LockScreenActivity 盖在锁屏上;灭屏时撤回触发通知,不在抽屉里堆垃圾 // 不受"后台弹出界面"限制);灭屏/亮屏/解锁三个时机同步显隐
ContextCompat.registerReceiver( ContextCompat.registerReceiver(
this, this,
screenReceiver, screenReceiver,
@@ -71,6 +73,13 @@ class TimerService : Service() {
}, },
ContextCompat.RECEIVER_NOT_EXPORTED, ContextCompat.RECEIVER_NOT_EXPORTED,
) )
// 用户解锁(输密码/指纹进入系统)后悬浮窗没有存在意义,立即关闭
ContextCompat.registerReceiver(
this,
unlockReceiver,
IntentFilter(Intent.ACTION_USER_PRESENT),
ContextCompat.RECEIVER_NOT_EXPORTED,
)
} }
private val screenReceiver = object : BroadcastReceiver() { private val screenReceiver = object : BroadcastReceiver() {
@@ -82,49 +91,77 @@ class TimerService : Service() {
} }
} }
private val unlockReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == Intent.ACTION_USER_PRESENT) {
LockOverlay.hide()
Notif.cancelFullscreen(this@TimerService)
}
}
}
/** /**
* 灭屏瞬间投递全屏意图通知——这是鸿蒙唯一会直接拉起 LockScreenActivity 的窗口。 * 悬浮窗显隐的总开关:锁屏中 + 计时未清零 + 开关打开 + 有悬浮窗权限。
* 鸿蒙 4.0 的规则:全屏意图只在「锁屏 + 灭屏」时投递才直接把页面盖在锁屏上; * 显示成功时顺手清掉抽屉里的全屏意图触发通知(不再需要)。
* 亮屏后投递永远只出横幅;服务直接 startActivity 则被"后台弹出界面"策略静默拦截
* (实测开了权限也一样)。所以改成灭屏时就投递:页面(turnScreenOn=false)
* 悄悄盖在锁屏底下、屏幕保持熄灭,用户按电源键亮屏就直接看到倒计时,
* 不会再出现任何通知横幅。
*/ */
private fun onScreenOff() { private fun syncLockOverlay() {
if (!Prefs.lockFullscreen || !TimerCore.running) return
TimerCore.tick() // 灭屏一瞬先补结算,避免到点边界上拉出 00:00 的空页面
if (!TimerCore.running) return
val km = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager val km = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
if (!km.isKeyguardLocked()) return val want = Prefs.lockFullscreen
Notif.updateFullscreen(this) && LockOverlay.canShow(this)
&& km.isKeyguardLocked()
&& (TimerCore.running || TimerCore.displayNow() > 0)
if (want) LockOverlay.show(this) else LockOverlay.hide()
if (LockOverlay.isShowing()) Notif.cancelFullscreen(this)
}
/** 灭屏:先补结算,悬浮窗可用就直接盖到锁屏上(保持熄屏,按电源键即见);不可用走全屏意图兜底 */
private fun onScreenOff() {
TimerCore.tick() // 灭屏一瞬先补结算,避免到点边界上拉出 00:00 的空页面
if (!Prefs.lockFullscreen || !TimerCore.running) return
syncLockOverlay()
if (LockOverlay.isShowing()) return
// 无悬浮窗权限的兜底:灭屏投递全屏意图(个别 ROM 直启,其余进抽屉可点)
val km = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
if (km.isKeyguardLocked()) Notif.updateFullscreen(this)
} }
/** 亮屏:先补结算(冻结进程的到点闹钟被推迟时,靠这一下止损,不再滚负数) */ /** 亮屏:先补结算(冻结进程的到点闹钟被推迟时,靠这一下止损,不再滚负数) */
private fun onScreenOn() { private fun onScreenOn() {
TimerCore.tick() TimerCore.tick()
if (LockScreenActivity.showing) { syncLockOverlay()
// 页面已经盖在锁屏上(灭屏投递拉起的),抽屉里的触发通知清掉 // 悬浮窗已盖住锁屏时,仍尝试用沉浸式锁屏页接管——
Notif.cancelFullscreen(this) // Activity 有主题级全屏(状态栏彻底遮掉)+ 横竖屏专属排版,
} else if (Prefs.lockFullscreen && TimerCore.running) { // 直启成功则显示效果更完整;被鸿蒙拦截也无损失,悬浮窗继续顶着
if (Prefs.lockFullscreen && TimerCore.running) {
val km = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager val km = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
if (km.isKeyguardLocked()) { if (km.isKeyguardLocked()) {
// 灭屏投递没拉起来(个别 ROM 拦全屏意图)的兜底:
// 先试服务直启,再留一条全屏意图通知让用户点进同一页面
runCatching { runCatching {
startActivity( startActivity(
Intent(this, LockScreenActivity::class.java) Intent(this, LockScreenActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
) )
} }
Notif.updateFullscreen(this) if (!LockOverlay.isShowing() && !LockScreenActivity.showing) {
// 悬浮窗和直启都失败:留全屏意图通知兜底(点进同一页面)
Notif.updateFullscreen(this)
}
} }
} else if (LockScreenActivity.showing) {
Notif.cancelFullscreen(this)
} }
} }
/** 系统配置变化(旋转):悬浮窗立刻换横/竖屏排版重建 */
override fun onConfigurationChanged(newConfig: android.content.res.Configuration) {
super.onConfigurationChanged(newConfig)
LockOverlay.update(this)
}
private val onStateChanged: () -> Unit = { private val onStateChanged: () -> Unit = {
Notif.updateOngoing(this) Notif.updateOngoing(this)
// 计时结束/暂停时清掉锁屏触发通知,抽屉里不留垃圾 // 计时结束/暂停时清掉锁屏触发通知,抽屉里不留垃圾
if (!TimerCore.running) Notif.cancelFullscreen(this) if (!TimerCore.running) Notif.cancelFullscreen(this)
syncLockOverlay()
syncTicker() syncTicker()
syncWakeLock() syncWakeLock()
} }
@@ -236,7 +273,9 @@ class TimerService : Service() {
override fun onDestroy() { override fun onDestroy() {
stopTicker() stopTicker()
releaseWakeLock() releaseWakeLock()
LockOverlay.hide()
runCatching { unregisterReceiver(screenReceiver) } runCatching { unregisterReceiver(screenReceiver) }
runCatching { unregisterReceiver(unlockReceiver) }
Notif.cancelFullscreen(this) Notif.cancelFullscreen(this)
TimerCore.removeListener(onStateChanged) TimerCore.removeListener(onStateChanged)
super.onDestroy() super.onDestroy()

View File

@@ -254,6 +254,15 @@ class MainActivity : AppCompatActivity() {
showTab(TAB_FOCUS) showTab(TAB_FOCUS)
} }
/**
* 按任务 id 开始计时,供项目页的完成记录行使用:
* 记录行本身是已完成的行,先经 [Store.startTargetFor] 换成系列里可计时的任务。
*/
fun startFocusFrom(taskId: Long) {
val target = Store.startTargetFor(taskId) ?: return
startFocusOn(target)
}
/** 设置改动后(清空数据、改主题)统一刷新其余页面 */ /** 设置改动后(清空数据、改主题)统一刷新其余页面 */
fun refreshAll() { fun refreshAll() {
for (f in fragments) { for (f in fragments) {

View File

@@ -26,6 +26,7 @@ import com.focusbox.app.model.Project
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.ui.SheetDialog import com.focusbox.app.ui.SheetDialog
import com.focusbox.app.ui.tasks.TaskSheet
import com.focusbox.app.util.Dates import com.focusbox.app.util.Dates
import com.focusbox.app.util.Prefs import com.focusbox.app.util.Prefs
import com.focusbox.app.util.circleBg import com.focusbox.app.util.circleBg
@@ -404,6 +405,10 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
cachedProject = cachedTask?.let { Store.project(it.projectId) } cachedProject = cachedTask?.let { Store.project(it.projectId) }
} }
val task = cachedTask val task = cachedTask
// 专注进行中,任务已经绑进这一轮:右侧文案改成「正在专注」,整卡不可点。
// 否则中途换任务会把 elapsed 清零重建(setTask 会重设 totalMs),这一轮就白跑了。
val locked = TimerCore.running && TimerCore.mode == TimerCore.MODE_FOCUS && task != null
taskCard.isClickable = !locked
if (task == null) { if (task == null) {
taskDot.visible(false) taskDot.visible(false)
tvTask.text = getString(R.string.no_task) tvTask.text = getString(R.string.no_task)
@@ -417,7 +422,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
tvTask.text = task.title tvTask.text = task.title
val projectName = project?.name ?: getString(R.string.inbox) val projectName = project?.name ?: getString(R.string.inbox)
tvTaskMeta.text = getString(R.string.task_card_meta, projectName, task.focusMinutes, task.donePomodoros) tvTaskMeta.text = getString(R.string.task_card_meta, projectName, task.focusMinutes, task.donePomodoros)
tvTaskAction.text = getString(R.string.task_selected) tvTaskAction.text = getString(if (locked) R.string.task_focusing else R.string.task_selected)
} }
// ------------------------------------------------------------------ 手势 // ------------------------------------------------------------------ 手势
@@ -487,6 +492,33 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
// ------------------------------------------------------------------ 任务 // ------------------------------------------------------------------ 任务
/**
* 选任务弹层第二步底部的「立即创建」:拉起新建任务弹层。
*
* 保存成功后把新任务设为当前任务(圆环套用它设定的专注时长)并直接开始计时,
* 与「选中已有任务」走同一条路径;取消新建则什么都不变。
*/
private fun createTaskAndSelect() {
val ctx = context ?: return
val act = activity
val sheet = TaskSheet(ctx, null, 0L) { newId ->
if (newId > 0) {
Store.task(newId)?.let { t ->
TimerCore.setCountUp(false)
TimerCore.setTask(t.id, t.projectId, t.focusMinutes)
// 走的是同一条「选任务」路径,建完也直接开跑,保持口径一致
requestNotifPermissionIfNeeded()
if (TimerCore.elapsedNow() > 0) TimerCore.resume() else TimerCore.start()
Toast.makeText(ctx, R.string.task_created, Toast.LENGTH_SHORT).show()
}
cachedTaskId = Long.MIN_VALUE
(act as? com.focusbox.app.ui.MainActivity)?.refreshAll()
}
if (view != null) render()
}
sheet.show()
}
/** /**
* 选择任务:第一步选项目,第二步只列出该项目的待办。 * 选择任务:第一步选项目,第二步只列出该项目的待办。
* 用自绘底部弹层而不是系统 AlertDialog,便于圆角、分步标题与选中态。 * 用自绘底部弹层而不是系统 AlertDialog,便于圆角、分步标题与选中态。
@@ -543,7 +575,8 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
btnBack.visibility = View.VISIBLE btnBack.visibility = View.VISIBLE
btnClear.visibility = View.VISIBLE btnClear.visibility = View.VISIBLE
list.removeAllViews() list.removeAllViews()
val tasks = Store.tasks(projectId, includeDone = false) // 选任务只按项目列任务:不按完成、逾期过滤,也不显示完成记录
val tasks = Store.projectTasks(projectId)
if (tasks.isEmpty()) { if (tasks.isEmpty()) {
list.addView(TextView(ctx).apply { list.addView(TextView(ctx).apply {
text = getString(R.string.pick_task_empty) text = getString(R.string.pick_task_empty)
@@ -554,10 +587,8 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
}) })
} }
tasks.forEach { t -> tasks.forEach { t ->
val meta = buildString { // 行内只写任务时间(专注时长),不挂截止/随时、也不标完成或逾期
append(getString(R.string.minutes_value, t.focusMinutes)) val meta = "${t.focusMinutes}分钟"
if (t.due > 0) append(" · ${Dates.dueLabel(t.due)}截止")
}
addRow( addRow(
title = t.title, title = t.title,
meta = meta, meta = meta,
@@ -568,6 +599,10 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
TimerCore.setCountUp(false) TimerCore.setCountUp(false)
TimerCore.setTask(t.id, t.projectId, t.focusMinutes) TimerCore.setTask(t.id, t.projectId, t.focusMinutes)
sheet.dismiss() sheet.dismiss()
// 选完即开跑,不用再点一次「开始专注」;
// 没跑过就 start,暂停过的(elapsed > 0)走 resume,才会补写暂停原因
requestNotifPermissionIfNeeded()
if (TimerCore.elapsedNow() > 0) TimerCore.resume() else TimerCore.start()
render() render()
} }
} }
@@ -586,7 +621,7 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
Store.projects().forEach { p -> Store.projects().forEach { p ->
addRow( addRow(
title = p.name, title = p.name,
meta = getString(R.string.pick_project_meta, p.openTasks), meta = getString(R.string.pick_project_meta, p.totalTasks),
color = p.color, color = p.color,
selected = p.id == currentPid, selected = p.id == currentPid,
alignLeft = true, // 项目列表不要左侧色点缩进,名称贴左对齐 alignLeft = true, // 项目列表不要左侧色点缩进,名称贴左对齐
@@ -597,10 +632,12 @@ class FocusFragment : Fragment(R.layout.fragment_focus) {
btnBack.setOnClickListener { showProjects() } btnBack.setOnClickListener { showProjects() }
btnClose.setOnClickListener { sheet.dismiss() } btnClose.setOnClickListener { sheet.dismiss() }
// 第二步底部:没有合适的任务就当场建一个,建完自动选中并回到专注页
btnClear.text = getString(R.string.create_now)
btnClear.setTextColor(col(R.color.brand))
btnClear.setOnClickListener { btnClear.setOnClickListener {
TimerCore.setTask(0, 0)
sheet.dismiss() sheet.dismiss()
render() createTaskAndSelect()
} }
sheet.setContentView(root) sheet.setContentView(root)
showProjects() showProjects()

View File

@@ -156,11 +156,6 @@ class LockScreenActivity : AppCompatActivity() {
tvClock.text = clockFmt.format(cal.time) tvClock.text = clockFmt.format(cal.time)
tvCountdown.text = Dates.clock(now) tvCountdown.text = Dates.clock(now)
// 工作中/休息中提示只有竖屏布局有(横屏排版里删掉了),横屏下 findViewById 返回 null
findViewById<TextView>(R.id.tvLockMode)?.text = getString(
if (TimerCore.mode == TimerCore.MODE_FOCUS) R.string.lock_mode_focus else R.string.lock_mode_break
)
val task = if (TimerCore.taskId > 0) Store.task(TimerCore.taskId)?.title else null val task = if (TimerCore.taskId > 0) Store.task(TimerCore.taskId)?.title else null
tvTask.text = task?.takeIf { it.isNotBlank() } ?: getString(R.string.notif_no_task) tvTask.text = task?.takeIf { it.isNotBlank() } ?: getString(R.string.notif_no_task)
} }

View File

@@ -1,30 +1,61 @@
package com.focusbox.app.ui.projects package com.focusbox.app.ui.projects
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Paint
import android.text.Spannable
import android.text.SpannableString
import android.text.style.StrikethroughSpan
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.TextView import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.focusbox.app.R import com.focusbox.app.R
import com.focusbox.app.model.Project import com.focusbox.app.model.Project
import com.focusbox.app.model.ProjectCompletion
import com.focusbox.app.model.ProjectTaskStat
import com.focusbox.app.model.Task
import com.focusbox.app.util.Dates import com.focusbox.app.util.Dates
import com.focusbox.app.util.col import com.focusbox.app.util.col
import com.focusbox.app.util.roundBg import com.focusbox.app.util.roundBg
import com.focusbox.app.util.tint import com.focusbox.app.util.tint
import com.focusbox.app.util.visible
/**
* 项目列表:点击项目头就地展开该项目下创建的任务,不再跳转任务页。
* 任务不按完成/逾期过滤,全部列出;任务下方用「展开/收起完成记录」开关
* 控制该项目的历史完成记录,避免记录越积越长。
*/
class ProjectAdapter( class ProjectAdapter(
private val onClick: (Project) -> Unit, private val onToggleExpand: (Project) -> Unit,
private val onLongClick: (Project) -> Unit, private val onLongClick: (Project) -> Unit,
private val onMore: (Project) -> Unit, private val onMore: (Project) -> Unit,
private val onStart: (Task) -> Unit,
private val onEdit: (Task) -> Unit,
private val onToggleDone: () -> Unit,
) : RecyclerView.Adapter<ProjectAdapter.VH>() { ) : RecyclerView.Adapter<ProjectAdapter.VH>() {
private var items: List<Project> = emptyList() private var items: List<Project> = emptyList()
private var expandedId: Long = -1L
private var stats: Map<Long, List<ProjectTaskStat>> = emptyMap()
private var completions: Map<Long, List<ProjectCompletion>> = emptyMap()
private var showDone: Boolean = false
fun submit(list: List<Project>) { fun submit(
list: List<Project>,
expanded: Long,
taskStats: Map<Long, List<ProjectTaskStat>>,
completionRows: Map<Long, List<ProjectCompletion>>,
showDoneRows: Boolean,
) {
items = list items = list
expandedId = expanded
stats = taskStats
completions = completionRows
showDone = showDoneRows
notifyDataSetChanged() notifyDataSetChanged()
} }
@@ -41,16 +72,19 @@ class ProjectAdapter(
private val progress: ProgressBar = v.findViewById(R.id.progress) private val progress: ProgressBar = v.findViewById(R.id.progress)
private val colorBar: View = v.findViewById(R.id.colorBar) private val colorBar: View = v.findViewById(R.id.colorBar)
private val more: ImageView = v.findViewById(R.id.btnMore) private val more: ImageView = v.findViewById(R.id.btnMore)
private val header: View = v.findViewById(R.id.projectHeader)
private val taskList: LinearLayout = v.findViewById(R.id.taskList)
private val tvTaskEmpty: TextView = v.findViewById(R.id.tvTaskEmpty)
fun bind(p: Project) { fun bind(p: Project) {
val ctx = itemView.context val ctx = itemView.context
name.text = p.name name.text = p.name
colorBar.background = ctx.roundBg(p.color, 2f) colorBar.background = ctx.roundBg(p.color, 2f)
// 只看任务与时长,不再显示番茄数 // 项目页只统计项目下创建的任务:总数、已完成数、累计专注时长
val parts = ArrayList<String>(3) val parts = ArrayList<String>(3)
parts.add("${p.openTasks} 待办") parts.add(ctx.getString(R.string.project_tasks_total, p.totalTasks))
if (p.doneTasks > 0) parts.add("${p.doneTasks} 已完成") if (p.doneTasks > 0) parts.add(ctx.getString(R.string.project_tasks_done, p.doneTasks))
if (p.focusSeconds >= 60) parts.add(Dates.duration(p.focusSeconds)) if (p.focusSeconds >= 60) parts.add(Dates.duration(p.focusSeconds))
meta.text = parts.joinToString(" · ") meta.text = parts.joinToString(" · ")
@@ -61,11 +95,127 @@ class ProjectAdapter(
more.tint(ctx.col(R.color.text_tertiary)) more.tint(ctx.col(R.color.text_tertiary))
more.setOnClickListener { onMore(p) } more.setOnClickListener { onMore(p) }
itemView.setOnClickListener { onClick(p) } header.setOnClickListener { onToggleExpand(p) }
itemView.setOnLongClickListener { header.setOnLongClickListener {
onLongClick(p) onLongClick(p)
true true
} }
val expanded = expandedId == p.id
val rows = if (expanded) stats[p.id].orEmpty() else emptyList()
val records = if (expanded) completions[p.id].orEmpty() else emptyList()
taskList.visible(expanded && (rows.isNotEmpty() || records.isNotEmpty()))
tvTaskEmpty.visible(expanded && rows.isEmpty() && records.isEmpty())
if (!expanded) return
fun addTaskRow(row: ProjectTaskStat) {
val item = LayoutInflater.from(ctx)
.inflate(R.layout.item_project_task, taskList, false)
bindTaskRow(item, row, p)
taskList.addView(item)
}
taskList.removeAllViews()
// 项目下创建的任务全部列出:不按完成/逾期过滤,也不重复生成
rows.forEach { addTaskRow(it) }
// 任务下面单独一条开关:展开/隐藏该项目下的完成记录
if (records.isNotEmpty()) {
val toggle = LayoutInflater.from(ctx)
.inflate(R.layout.item_footer, taskList, false)
val tv = toggle.findViewById<TextView>(R.id.tvFooter)
tv.text = ctx.getString(
if (showDone) R.string.project_collapse_done else R.string.project_expand_done,
records.size,
)
tv.setTextColor(ctx.col(R.color.brand))
toggle.setOnClickListener { onToggleDone() }
taskList.addView(toggle)
if (showDone) records.forEach { addCompletionRow(it, p) }
}
}
private fun bindTaskRow(item: View, row: ProjectTaskStat, p: Project) {
val ctx = item.context
val task = row.task
val tvTitle: TextView = item.findViewById(R.id.tvTaskTitle)
val tvMeta: TextView = item.findViewById(R.id.tvTaskMeta)
val btnPlay: ImageView = item.findViewById(R.id.btnTaskPlay)
item.findViewById<View>(R.id.taskColorBar).background = ctx.roundBg(p.color, 2f)
// 顶部是「创建了就一直在」的任务清单:不划线、不变灰;
// 完成与否只体现在下面的完成记录里
tvTitle.text = task.title
tvTitle.setTextColor(ctx.col(R.color.text))
tvTitle.paintFlags = tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
// 任务时间(专注时长)· 最近完成 · 累计次数与累计专注
val parts = ArrayList<String>(3)
parts.add("${task.focusMinutes}分钟")
if (row.lastDoneAt > 0) {
val whenText = "${Dates.md(row.lastDoneAt)}·${Dates.hm(row.lastDoneAt)}"
parts.add(ctx.getString(R.string.project_task_last_done, whenText))
}
val totals = StringBuilder()
if (row.doneCount > 0) {
totals.append(ctx.getString(R.string.project_task_done_count, row.doneCount))
}
if (row.focusSeconds > 0) {
// 累计专注只写「数字分钟」,不加说明文案,也不留空格
totals.append(row.focusSeconds / 60).append("分钟")
}
if (totals.isNotEmpty()) parts.add(totals.toString())
tvMeta.text = parts.joinToString(" · ")
// 开始键常驻:已完成的创建任务同样可以再开始一轮,
// 由调用方把「已完成的行」换成系列里当前可计时的任务
btnPlay.visible(true)
btnPlay.tint(ctx.col(R.color.brand))
btnPlay.setOnClickListener { onStart(task) }
// 与任务页一致:点行打开编辑/删除弹窗
item.setOnClickListener { onEdit(task) }
}
private fun addCompletionRow(record: ProjectCompletion, p: Project) {
val ctx = itemView.context
val item = LayoutInflater.from(ctx)
.inflate(R.layout.item_project_task, taskList, false)
item.findViewById<View>(R.id.taskColorBar).background = ctx.roundBg(p.color, 2f)
val tvTitle: TextView = item.findViewById(R.id.tvTaskTitle)
val tvMeta: TextView = item.findViewById(R.id.tvTaskMeta)
val btnPlay: ImageView = item.findViewById(R.id.btnTaskPlay)
// 完成记录行只做历史展示:开始键只出现在上面的创建任务行
btnPlay.visible(false)
// 完成记录与任务页底部一致:任务名划线,完成原因跟在后面但不划线
val noteText = record.note.replace('\n', ' ')
val titleText = if (noteText.isBlank()) {
record.taskTitle
} else {
"${record.taskTitle} · $noteText"
}
val line = SpannableString(titleText)
if (record.taskTitle.isNotEmpty()) {
line.setSpan(
StrikethroughSpan(), 0, record.taskTitle.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE,
)
}
tvTitle.text = line
tvTitle.setTextColor(ctx.col(R.color.text_secondary))
tvTitle.paintFlags = tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
// 与任务页完成记录同格式:日期 周几 起-止 · 专注X;没有真实时长就只写完成时刻
tvMeta.text = if (record.seconds > 0) {
"${Dates.dateWithWeek(record.startAt)} ${Dates.hms(record.startAt)}" +
"-${Dates.hms(record.endAt)} · 专注${Dates.duration(record.seconds)}"
} else {
"${Dates.dateWithWeek(record.endAt)} ${Dates.hms(record.endAt)}完成"
}
item.isClickable = false
item.setOnClickListener(null)
taskList.addView(item)
} }
} }
} }

View File

@@ -13,6 +13,7 @@ import androidx.appcompat.app.AlertDialog
import com.focusbox.app.R import com.focusbox.app.R
import com.focusbox.app.data.Store import com.focusbox.app.data.Store
import com.focusbox.app.model.Project import com.focusbox.app.model.Project
import com.focusbox.app.service.TimerCore
import com.focusbox.app.ui.SheetDialog import com.focusbox.app.ui.SheetDialog
import com.focusbox.app.util.Palette import com.focusbox.app.util.Palette
import com.focusbox.app.util.circleBg import com.focusbox.app.util.circleBg
@@ -35,7 +36,11 @@ class ProjectSheet(
private var color: Int = existing?.color ?: Palette.colorAt(0) private var color: Int = existing?.color ?: Palette.colorAt(0)
init { init {
setContentView(root) // 项目编辑含多个输入框:必须走满屏容器 + 键盘顶起,否则输入法会盖住弹层
fitOnIme(root)
// 满屏容器后仍保留“点弹层外关闭”,点弹层内部空白不关闭
(root.parent as? View)?.setOnClickListener { dismiss() }
root.setOnClickListener { }
root.findViewById<TextView>(R.id.sheetTitle).setText( root.findViewById<TextView>(R.id.sheetTitle).setText(
if (existing == null) R.string.add_project else R.string.edit if (existing == null) R.string.add_project else R.string.edit
) )
@@ -57,6 +62,11 @@ class ProjectSheet(
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.delete) { _, _ -> .setPositiveButton(R.string.delete) { _, _ ->
Store.deleteProject(existing.id) Store.deleteProject(existing.id)
// 项目下的任务行已经删掉了:正在计时的如果正好是其中一条,
// 必须先把计时解绑,否则这一轮结束时会写出一条挂不到任务上的记录
if (TimerCore.taskId > 0 && Store.task(TimerCore.taskId) == null) {
TimerCore.setTask(0, 0)
}
onSaved() onSaved()
dismiss() dismiss()
} }
@@ -89,28 +99,37 @@ class ProjectSheet(
} }
} }
/**
* 20 色两行平铺(每行 10 个)。
*
* 从一行横向滑动改成两行:20 个色点若排成一行要滑很久才找得到,
* 两行 × 10 个刚好铺满一屏宽度(10 × 32dp = 320dp),窄屏仍可横向滑动兜底。
*/
private fun renderColors() { private fun renderColors() {
val ctx = context val ctx = context
colorRow.removeAllViews() colorRow.removeAllViews()
Palette.colors.forEach { c -> Palette.colors.toList().chunked(10).forEach { rowColors ->
val wrap = FrameLayout(ctx) val row = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL }
val lp = LinearLayout.LayoutParams(dpi(40f), dpi(40f)) colorRow.addView(row)
lp.marginEnd = dpi(2f) rowColors.forEach { c ->
wrap.layoutParams = lp val wrap = FrameLayout(ctx)
wrap.background = if (c == color) ctx.roundBg(Color.TRANSPARENT, 100f, c, 2f) else null val lp = LinearLayout.LayoutParams(dpi(32f), dpi(32f))
wrap.layoutParams = lp
wrap.background = if (c == color) ctx.roundBg(Color.TRANSPARENT, 100f, c, 2f) else null
val dot = View(ctx) val dot = View(ctx)
val dlp = FrameLayout.LayoutParams(dpi(26f), dpi(26f)) val dlp = FrameLayout.LayoutParams(dpi(20f), dpi(20f))
dlp.gravity = Gravity.CENTER dlp.gravity = Gravity.CENTER
dot.layoutParams = dlp dot.layoutParams = dlp
dot.background = circleBg(c) dot.background = circleBg(c)
wrap.addView(dot) wrap.addView(dot)
wrap.setOnClickListener { wrap.setOnClickListener {
color = c color = c
renderColors() renderColors()
}
row.addView(wrap)
} }
colorRow.addView(wrap)
} }
} }
} }

View File

@@ -10,8 +10,12 @@ import androidx.recyclerview.widget.RecyclerView
import com.focusbox.app.R import com.focusbox.app.R
import com.focusbox.app.data.Store import com.focusbox.app.data.Store
import com.focusbox.app.model.Project import com.focusbox.app.model.Project
import com.focusbox.app.model.ProjectCompletion
import com.focusbox.app.model.ProjectTaskStat
import com.focusbox.app.service.TimerCore
import com.focusbox.app.ui.MainActivity import com.focusbox.app.ui.MainActivity
import com.focusbox.app.ui.SheetDialog import com.focusbox.app.ui.SheetDialog
import com.focusbox.app.ui.tasks.TaskSheet
import com.focusbox.app.util.col import com.focusbox.app.util.col
import com.focusbox.app.util.visible import com.focusbox.app.util.visible
@@ -25,6 +29,13 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
private var showArchived = false private var showArchived = false
/** 当前展开的项目 id;-1 表示全部收起。只展开一个,避免列表过长 */
private var expandedProjectId = -1L
private var taskStats: Map<Long, List<ProjectTaskStat>> = emptyMap()
private var completions: Map<Long, List<ProjectCompletion>> = emptyMap()
/** 项目任务下方的完成记录默认折叠,避免历史记录越积越长 */
private var showDoneInProject = false
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
recycler = view.findViewById(R.id.recycler) recycler = view.findViewById(R.id.recycler)
@@ -33,9 +44,20 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
btnArchived = view.findViewById(R.id.btnArchived) btnArchived = view.findViewById(R.id.btnArchived)
adapter = ProjectAdapter( adapter = ProjectAdapter(
onClick = { p -> (activity as? MainActivity)?.openProjectTasks(p.id) }, onToggleExpand = { p ->
val opening = expandedProjectId != p.id
expandedProjectId = if (opening) p.id else -1L
if (opening) showDoneInProject = false
reload()
},
onLongClick = { p -> showActions(p) }, onLongClick = { p -> showActions(p) },
onMore = { p -> showActions(p) }, onMore = { p -> showActions(p) },
onStart = { t -> (activity as? MainActivity)?.startFocusFrom(t.id) },
onEdit = { t -> TaskSheet(requireContext(), t, 0L) { reload() }.show() },
onToggleDone = {
showDoneInProject = !showDoneInProject
reload()
},
) )
recycler.layoutManager = LinearLayoutManager(requireContext()) recycler.layoutManager = LinearLayoutManager(requireContext())
recycler.adapter = adapter recycler.adapter = adapter
@@ -68,10 +90,16 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
val archived = all.filter { it.archived } val archived = all.filter { it.archived }
val shown = if (showArchived) all else active val shown = if (showArchived) all else active
adapter.submit(shown) // 展开态只在可见项目上加载统计;项目被删/归档后自动收起,不留悬空 id
if (expandedProjectId != -1L && shown.none { it.id == expandedProjectId }) {
expandedProjectId = -1L
}
taskStats = shown.associate { it.id to Store.projectTaskRows(it.id) }
completions = shown.associate { it.id to Store.projectCompletions(it.id) }
adapter.submit(shown, expandedProjectId, taskStats, completions, showDoneInProject)
tvSummary.text = getString( tvSummary.text = getString(
R.string.project_summary, active.size, active.sumOf { it.openTasks } R.string.project_summary, active.size, active.sumOf { it.totalTasks }
) )
tvEmpty.visible(shown.isEmpty()) tvEmpty.visible(shown.isEmpty())
@@ -79,7 +107,7 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
btnArchived.visible(false) btnArchived.visible(false)
} else { } else {
btnArchived.visible(true) btnArchived.visible(true)
btnArchived.text = if (showArchived) "隐藏已归档" else "已归档 ${archived.size}" btnArchived.text = if (showArchived) "隐藏已归档" else "已归档${archived.size}"
} }
} }
@@ -148,6 +176,11 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
) { which -> ) { which ->
if (which == 1) { if (which == 1) {
Store.deleteProject(p.id) Store.deleteProject(p.id)
// 项目下的任务行已随之删除:正在计时的若属于它们,先解绑,
// 否则这一轮结束会写成一条挂不到任务的「未关联」记录
if (TimerCore.taskId > 0 && Store.task(TimerCore.taskId) == null) {
TimerCore.setTask(0, 0)
}
reload() reload()
} }
} }

View File

@@ -94,7 +94,17 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
toggle(getString(R.string.vibrate), Prefs.vibrateOn) { Prefs.vibrateOn = it }, toggle(getString(R.string.vibrate), Prefs.vibrateOn) { Prefs.vibrateOn = it },
toggle(getString(R.string.keep_screen_on), Prefs.keepScreenOn) { Prefs.keepScreenOn = it }, toggle(getString(R.string.keep_screen_on), Prefs.keepScreenOn) { Prefs.keepScreenOn = it },
toggle(getString(R.string.lock_fullscreen_title), Prefs.lockFullscreen) { Prefs.lockFullscreen = it }, toggle(getString(R.string.lock_fullscreen_title), Prefs.lockFullscreen) { Prefs.lockFullscreen = it },
// 华为/鸿蒙默认拦截后台拉起页面,锁屏倒计时需要手动开两个权限; // 悬浮窗权限:锁屏倒计时主链路(鸿蒙拦 Activity 后台启动,悬浮窗不受限)。
// 已授权时既没有右侧箭头也不可点——权限本身没有应用内开关,免得误以为能点进去设置
run {
val granted = com.focusbox.app.service.LockOverlay.canShow(requireContext())
if (granted) {
action(getString(R.string.overlay_perm_title), getString(R.string.perm_granted), showArrow = false)
} else {
action(getString(R.string.overlay_perm_title), getString(R.string.go_set)) { openOverlayPerm() }
}
},
// 华为/鸿蒙默认拦截后台拉起页面,无悬浮窗权限时的 Activity 兜底链路也要这两项权限;
// 放在开关正下方,用户开了开关不生效时第一眼就能看到入口 // 放在开关正下方,用户开了开关不生效时第一眼就能看到入口
action(getString(R.string.lock_perm_title), getString(R.string.lock_perm_value)) { openLockPerm() }, action(getString(R.string.lock_perm_title), getString(R.string.lock_perm_value)) { openLockPerm() },
) )
@@ -104,6 +114,8 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
stepper( stepper(
getString(R.string.daily_goal), getString(R.string.daily_goal),
getString(R.string.value_minutes, Prefs.dailyGoalMinutes), getString(R.string.value_minutes, Prefs.dailyGoalMinutes),
// 数值支持直接点击输入;步进用于微调。Prefs 里没有上限
onEdit = { inputDailyGoal() },
) { delta -> ) { delta ->
Prefs.dailyGoalMinutes += delta * 15 Prefs.dailyGoalMinutes += delta * 15
build() build()
@@ -126,6 +138,9 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
section(R.string.section_data) section(R.string.section_data)
card( card(
// 清理旧版本删除任务后残留的孤儿记录,排在「清空所有数据」前面:
// 它只动查不到任务的记录,比全清安全一档
action(getString(R.string.purge_orphan), "", danger = true) { confirmPurgeOrphan() },
action(getString(R.string.clear_data), "", danger = true) { confirmClear() }, action(getString(R.string.clear_data), "", danger = true) { confirmClear() },
) )
@@ -175,7 +190,8 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
setBackgroundColor(col(R.color.divider)) setBackgroundColor(col(R.color.divider))
} }
private fun stepper(title: String, value: String, onChange: (Int) -> Unit): View { /** onEdit 非空时点击数值可直接输入(目前只有每日目标用);onChange 为加减步进 */
private fun stepper(title: String, value: String, onEdit: (() -> Unit)? = null, onChange: (Int) -> Unit): View {
val ctx = requireContext() val ctx = requireContext()
val row = LinearLayout(ctx).apply { val row = LinearLayout(ctx).apply {
orientation = LinearLayout.HORIZONTAL orientation = LinearLayout.HORIZONTAL
@@ -196,6 +212,7 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
gravity = Gravity.CENTER gravity = Gravity.CENTER
setTextColor(col(R.color.title)) setTextColor(col(R.color.title))
layoutParams = LinearLayout.LayoutParams(dpi(74f), LinearLayout.LayoutParams.WRAP_CONTENT) layoutParams = LinearLayout.LayoutParams(dpi(74f), LinearLayout.LayoutParams.WRAP_CONTENT)
if (onEdit != null) setOnClickListener { onEdit() }
}) })
row.addView(stepButton("+") { onChange(1) }) row.addView(stepButton("+") { onChange(1) })
return row return row
@@ -237,13 +254,19 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
return row return row
} }
private fun action(title: String, value: String, danger: Boolean = false, onClick: () -> Unit): View { private fun action(
title: String,
value: String,
danger: Boolean = false,
showArrow: Boolean = true,
onClick: (() -> Unit)? = null,
): View {
val ctx = requireContext() val ctx = requireContext()
val row = LinearLayout(ctx).apply { val row = LinearLayout(ctx).apply {
orientation = LinearLayout.HORIZONTAL orientation = LinearLayout.HORIZONTAL
gravity = Gravity.CENTER_VERTICAL gravity = Gravity.CENTER_VERTICAL
minimumHeight = dpi(54f) minimumHeight = dpi(54f)
setOnClickListener { onClick() } if (onClick != null) setOnClickListener { onClick() }
} }
row.addView(TextView(ctx).apply { row.addView(TextView(ctx).apply {
text = title text = title
@@ -259,11 +282,13 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
setPadding(0, 0, dpi(6f), 0) setPadding(0, 0, dpi(6f), 0)
}) })
} }
row.addView(android.widget.ImageView(ctx).apply { if (showArrow) {
setImageResource(R.drawable.ic_chevron_right) row.addView(android.widget.ImageView(ctx).apply {
tint(col(R.color.text_tertiary)) setImageResource(R.drawable.ic_chevron_right)
layoutParams = LinearLayout.LayoutParams(dpi(15f), dpi(15f)) tint(col(R.color.text_tertiary))
}) layoutParams = LinearLayout.LayoutParams(dpi(15f), dpi(15f))
})
}
return row return row
} }
@@ -319,6 +344,92 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
dialog.show() dialog.show()
} }
/** 每日目标:弹小窗直接输入分钟数(无上限,下限 15 由 Prefs 兜底) */
private fun inputDailyGoal() {
val ctx = requireContext()
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 = getString(R.string.daily_goal)
textSize = 16f
typeface = Typeface.DEFAULT_BOLD
setTextColor(col(R.color.text))
})
val et = android.widget.EditText(ctx).apply {
inputType = android.text.InputType.TYPE_CLASS_NUMBER
setText(Prefs.dailyGoalMinutes.toString())
textSize = 15f
setTextColor(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)
et.requestFocus()
val btnRow = LinearLayout(ctx).apply {
orientation = LinearLayout.HORIZONTAL
gravity = Gravity.END
setPadding(0, dpi(12f), 0, 0)
}
fun btn(labelRes: Int, onClick: () -> Unit) = TextView(ctx).apply {
text = getString(labelRes)
textSize = 14f
typeface = Typeface.DEFAULT_BOLD
gravity = Gravity.CENTER
setTextColor(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) {
Prefs.dailyGoalMinutes = input
dialog.dismiss()
build()
} else {
et.error = " "
}
}, LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT).apply {
marginStart = dpi(10f)
})
panel.addView(btnRow)
dialog.setContentView(panel)
dialog.show()
// 弹窗不自动抢输入法焦点,手动拉起软键盘
et.postDelayed({
val imm = ctx.getSystemService(android.content.Context.INPUT_METHOD_SERVICE)
as? android.view.inputmethod.InputMethodManager
imm?.showSoftInput(et, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT)
}, 100L)
}
/** 悬浮窗权限:标准 Android 特殊权限,有公开检测 API 和授权页,一键直达本应用 */
private fun openOverlayPerm() {
val ctx = requireContext()
if (com.focusbox.app.service.LockOverlay.canShow(ctx)) return
runCatching {
startActivity(
android.content.Intent(
android.provider.Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
android.net.Uri.parse("package:${ctx.packageName}"),
).addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
)
}
}
/** 锁屏显示权限:弹说明后直达华为「应用启动管理」,非华为/直达失败退回应用详情页 */ /** 锁屏显示权限:弹说明后直达华为「应用启动管理」,非华为/直达失败退回应用详情页 */
private fun openLockPerm() { private fun openLockPerm() {
val ctx = requireContext() val ctx = requireContext()
@@ -373,6 +484,71 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
dialog.show() dialog.show()
} }
/**
* 清空未关联数据:弹窗结构与「清空所有数据」完全一致,只是正文会说清要删多少条。
*
* 删的是「找不到任务」的专注记录(旧版本删任务时把 task_id 清零留下的残骸、
* 以及没选任务直接开始的那几轮)。它们只能堆成饼图里的「未关联任务」,
* 占一块地方又查不到是谁的,所以单独给一个清理入口。
*/
private fun confirmPurgeOrphan() {
val ctx = requireContext()
val stat = Store.orphanSessions()
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 = getString(R.string.purge_orphan)
textSize = 16f
typeface = Typeface.DEFAULT_BOLD
setTextColor(col(R.color.text))
})
panel.addView(TextView(ctx).apply {
text = if (stat.count > 0) {
getString(R.string.purge_confirm, stat.count, Dates.duration(stat.seconds))
} else {
getString(R.string.purge_none)
}
textSize = 14f
setTextColor(col(R.color.text_secondary))
setPadding(0, dpi(10f), 0, dpi(6f))
})
val btnRow = LinearLayout(ctx).apply {
orientation = LinearLayout.HORIZONTAL
gravity = Gravity.END
setPadding(0, dpi(12f), 0, 0)
}
fun btn(labelRes: Int, danger: Boolean, onClick: () -> Unit) = TextView(ctx).apply {
text = getString(labelRes)
textSize = 14f
typeface = Typeface.DEFAULT_BOLD
gravity = Gravity.CENTER
setTextColor(col(if (danger) R.color.danger else 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, false) { dialog.dismiss() })
btnRow.addView(btn(R.string.delete, true) {
dialog.dismiss()
if (stat.count > 0) Store.purgeOrphanSessions()
(activity as? MainActivity)?.refreshAll()
build()
}, LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT).apply {
marginStart = dpi(10f)
})
panel.addView(btnRow)
dialog.setContentView(panel)
dialog.show()
}
private fun confirmClear() { private fun confirmClear() {
val ctx = requireContext() val ctx = requireContext()
val dialog = android.app.Dialog(ctx) val dialog = android.app.Dialog(ctx)
@@ -431,6 +607,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
} }
companion object { companion object {
const val VERSION = "1.2" const val VERSION = "3.3"
} }
} }

View File

@@ -2,6 +2,7 @@ package com.focusbox.app.ui.stats
import android.content.Context import android.content.Context
import android.graphics.Typeface import android.graphics.Typeface
import android.graphics.drawable.GradientDrawable
import android.util.AttributeSet import android.util.AttributeSet
import android.util.TypedValue import android.util.TypedValue
import android.view.Gravity import android.view.Gravity
@@ -15,6 +16,7 @@ import com.focusbox.app.util.Dates
import com.focusbox.app.util.col import com.focusbox.app.util.col
import com.focusbox.app.util.dpi import com.focusbox.app.util.dpi
import com.focusbox.app.widget.LabelDonutView import com.focusbox.app.widget.LabelDonutView
import kotlin.math.roundToInt
/** /**
* 「项目分布 / 任务分布」卡片:自带 日 / 周 / 月 / 年 四档与左右翻页。 * 「项目分布 / 任务分布」卡片:自带 日 / 周 / 月 / 年 四档与左右翻页。
@@ -42,6 +44,12 @@ class PeriodDistributionCard @JvmOverloads constructor(
private val btnNext = ImageView(context) private val btnNext = ImageView(context)
private val donut = LabelDonutView(context) private val donut = LabelDonutView(context)
/**
* 环下方明细列表:环只标占比最高的 6 条,剩下的全部在这里逐条列出。
* 不合并成「其他」——被合并掉的任务在页面上等于消失,用户根本不知道自己漏了什么。
*/
private val legend = LinearLayout(context)
/** 当前粒度,默认按天 */ /** 当前粒度,默认按天 */
var scale = Scale.DAY var scale = Scale.DAY
private set private set
@@ -145,6 +153,90 @@ class PeriodDistributionCard @JvmOverloads constructor(
addView(donut, LayoutParams(LayoutParams.MATCH_PARENT, context.dpi(222f)).apply { addView(donut, LayoutParams(LayoutParams.MATCH_PARENT, context.dpi(222f)).apply {
topMargin = context.dpi(2f) topMargin = context.dpi(2f)
}) })
legend.apply {
orientation = VERTICAL
visibility = GONE
}
addView(legend, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT).apply {
topMargin = context.dpi(6f)
})
}
// ------------------------------------------------------------------ 明细列表
/**
* 把环上没有牵线的切片按「圆点 + 名称 / 时长 · 占比」两列铺开(参考图版式)。
* 每格宽度均分,名称超长省略,保证列对齐不来回跳。
*/
private fun renderLegend(rest: List<LabelDonutView.Slice>, total: Int) {
legend.removeAllViews()
if (rest.isEmpty() || total <= 0) {
legend.visibility = GONE
return
}
legend.visibility = VISIBLE
rest.chunked(2).forEach { pair ->
val row = LinearLayout(context).apply { orientation = HORIZONTAL }
legend.addView(row, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT))
pair.forEach { slice ->
row.addView(buildLegendCell(slice, total), LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f))
}
// 单数时补一个空位,最后一行不会因为权重拉伸变成通栏
if (pair.size == 1) {
row.addView(android.view.View(context), LayoutParams(0, 1, 1f))
}
}
}
private fun buildLegendCell(slice: LabelDonutView.Slice, total: Int): LinearLayout {
val cell = LinearLayout(context).apply {
orientation = HORIZONTAL
setPadding(0, context.dpi(7f), context.dpi(8f), context.dpi(7f))
}
val dot = android.view.View(context).apply {
background = GradientDrawable().apply {
shape = GradientDrawable.OVAL
setColor(slice.color)
}
}
// 8dp 圆点,下移 5dp 与名称首行的视觉中心对齐
cell.addView(dot, LayoutParams(context.dpi(8f), context.dpi(8f)).apply {
topMargin = context.dpi(5f)
})
val text = LinearLayout(context).apply {
orientation = VERTICAL
setPadding(context.dpi(8f), 0, 0, 0)
}
cell.addView(text, LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f))
text.addView(TextView(context).apply {
this.text = slice.name
setTextSize(TypedValue.COMPLEX_UNIT_SP, 13f)
setTextColor(context.col(R.color.title))
maxLines = 1
ellipsize = android.text.TextUtils.TruncateAt.END
includeFontPadding = false
})
val pct = slice.seconds * 100f / total
val pctText = if (pct < 1f) "<1%" else "${pct.roundToInt()}%"
text.addView(TextView(context).apply {
this.text = context.getString(
R.string.legend_meta,
Dates.duration(slice.seconds),
pctText,
)
setTextSize(TypedValue.COMPLEX_UNIT_SP, 11f)
setTextColor(context.col(R.color.text_secondary))
maxLines = 1
includeFontPadding = false
})
return cell
} }
// ------------------------------------------------------------------ 交互 // ------------------------------------------------------------------ 交互
@@ -204,9 +296,9 @@ class PeriodDistributionCard @JvmOverloads constructor(
) )
} }
) )
donut.centerText = Dates.durationBrief(raw.sumOf { it.seconds }) val total = raw.sumOf { it.seconds }
donut.centerCaption = donut.centerText = Dates.durationBrief(total)
context.getString(if (byTask) R.string.task_share else R.string.total_focus) renderLegend(donut.unlabeled, total)
tvPeriod.text = periodLabel(from, to) tvPeriod.text = periodLabel(from, to)
applySegments() applySegments()

View File

@@ -71,6 +71,25 @@ class TaskAdapter(
} }
} }
/**
* 标题与图标之间的间距:旧版用三个空格,视觉偏宽。
* 改用无字形占位,宽度精确等于三个空格的一半,避免随字体变化忽大忽小。
*/
private fun appendIconGap(title: SpannableStringBuilder) {
title.append(" ")
title.setSpan(IconGapSpan(), title.length - 1, title.length, 0)
}
/**
* 间距与图标必须各占一个字符。若把两个 ReplacementSpan 套在同一字符上,
* 后设置的图标会覆盖间距,视觉上就贴住了。
*/
private fun appendIconSpan(title: SpannableStringBuilder, span: Any) {
appendIconGap(title)
title.append(" ")
title.setSpan(span, title.length - 1, title.length, 0)
}
private inner class TaskViewHolder(v: View) : RecyclerView.ViewHolder(v) { private inner class TaskViewHolder(v: View) : RecyclerView.ViewHolder(v) {
private val tvTitle: TextView = v.findViewById(R.id.tvTitle) private val tvTitle: TextView = v.findViewById(R.id.tvTitle)
private val tvMeta: TextView = v.findViewById(R.id.tvMeta) private val tvMeta: TextView = v.findViewById(R.id.tvMeta)
@@ -85,23 +104,25 @@ class TaskAdapter(
val ctx = itemView.context val ctx = itemView.context
// 标题右侧的属性图标,未完成与已完成都显示: // 标题右侧的属性图标,未完成与已完成都显示:
// 重要度圆圈数字(③ 高 / ② 中 / ① 普通,颜色与紧急度同色系)→ // 置顶圆圈箭头(「随时」未完成任务)→ 重要度圆圈数字 → 紧急度五角星。
// 紧急度五角星 → 随时上箭头。 // 置顶与重要度两个圆圈统一自绘:同一尺寸(0.85 倍字号)、同一描边(s/10),
// 各字形在字体里的字面尺寸不同:以圆圈数字 0.85 为基准, // 保证粗细与高度完全一致;五角星仍用字形,0.95 倍不作参照。
// 上箭头与圆圈同高;五角星 0.95 不作参照
val title = SpannableStringBuilder(task.title) val title = SpannableStringBuilder(task.title)
val iconSize = tvTitle.textSize * 0.85f
val (badge, badgeColor) = when (task.priority) { // 置顶图标前移到重要度圆圈之前(品牌蓝圆圈内向上箭头)
2 -> " ③" to R.color.urgent_high if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
1 -> " ②" to R.color.urgent_mid appendIconSpan(title, PinIconSpan(ctx.col(R.color.brand), iconSize))
else -> " ①" to R.color.urgent_low
} }
title.append(badge)
title.setSpan( // 重要度圆圈:3 高 / 2 中 / 1 普通,颜色与紧急度同色系
android.text.style.ForegroundColorSpan(ctx.col(badgeColor)), val (digit, badgeColor) = when (task.priority) {
title.length - badge.length, title.length, 0 2 -> "3" to R.color.urgent_high
) 1 -> "2" to R.color.urgent_mid
title.setSpan(RelativeSizeSpan(0.85f), title.length - badge.length, title.length, 0) else -> "1" to R.color.urgent_low
}
// 与标题、与置顶圆圈各留半个旧间距,避免图标贴在一起又不显得散
appendIconSpan(title, PriorityBadgeSpan(ctx.col(badgeColor), iconSize, digit))
// 紧急度五角星:紧急三颗红 / 中两颗绿 / 不急一颗灰 // 紧急度五角星:紧急三颗红 / 中两颗绿 / 不急一颗灰
val (stars, starColor) = when (task.urgency) { val (stars, starColor) = when (task.urgency) {
@@ -116,24 +137,15 @@ class TaskAdapter(
) )
title.setSpan(RelativeSizeSpan(0.95f), title.length - stars.length, title.length, 0) title.setSpan(RelativeSizeSpan(0.95f), title.length - stars.length, title.length, 0)
// 「随时」任务:标题后带品牌蓝上箭头表示置顶,列表里排在未完成最前面。 // 完成横线只画任务名本身(MidStrikeSpan 限定区间,且划线取文字墨迹
// ↑ 字形窄、两侧留白大,全角空格会显得左边距比五角星宽, // 的垂直中点——系统 StrikethroughSpan 用整字面半高定位,数字/汉字
// 改用细空格(U+2009)让两侧间隙与星标一致。 // 会让线显得偏下)。重要度/紧急度/置顶图标不跟着划线。
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) { // 注意:span 必须在 tvTitle.text = title 之前挂好
title.append("\u2009↑") if (task.done) {
title.setSpan( title.setSpan(MidStrikeSpan(), 0, task.title.length, 0)
android.text.style.ForegroundColorSpan(ctx.col(R.color.brand)),
title.length - 2, title.length, 0
)
title.setSpan(RelativeSizeSpan(0.85f), title.length - 2, title.length, 0)
} }
tvTitle.text = title tvTitle.text = title
tvTitle.paintFlags = if (task.done) { tvTitle.paintFlags = tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
tvTitle.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
} else {
tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
}
tvTitle.setTextColor(ctx.col(if (task.done) R.color.text_tertiary else R.color.text)) tvTitle.setTextColor(ctx.col(if (task.done) R.color.text_tertiary else R.color.text))
tvTitle.typeface = if (task.priority >= 2 && !task.done) Typeface.DEFAULT_BOLD else Typeface.DEFAULT tvTitle.typeface = if (task.priority >= 2 && !task.done) Typeface.DEFAULT_BOLD else Typeface.DEFAULT
@@ -203,3 +215,156 @@ class TaskAdapter(
private const val TYPE_FOOTER = 1 private const val TYPE_FOOTER = 1
} }
} }
/**
* 图标间距占位:宽度等于旧版三个空格的一半,且不绘制任何字形。
* 用 ReplacementSpan 而不是固定 dp,间距会随字号等比缩放。
*/
private class IconGapSpan : android.text.style.ReplacementSpan() {
override fun getSize(
paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?,
): Int = (paint.measureText(" ") / 2f).toInt().coerceAtLeast(1)
override fun draw(
canvas: android.graphics.Canvas, text: CharSequence, start: Int, end: Int,
x: Float, top: Int, baseline: Int, bottom: Int, paint: Paint,
) = Unit
}
/**
* 任务名删除线:系统 StrikethroughSpan 的划线位置按"字体半高"(baseline + ascent/2)
* 计算,但数字/汉字的实际墨迹顶比字体 ascent 低不少,划线视觉上偏下。
* 这里自绘:按实际墨迹边界(getTextBounds)取垂直中点,线严格穿过文字中间。
*/
private class MidStrikeSpan : android.text.style.ReplacementSpan() {
override fun getSize(
paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?,
): Int = paint.measureText(text, start, end).toInt()
override fun draw(
canvas: android.graphics.Canvas, text: CharSequence, start: Int, end: Int,
x: Float, top: Int, baseline: Int, bottom: Int, paint: Paint,
) {
// 先按原样式画字(无删除线标志)
canvas.drawText(text, start, end, x, baseline.toFloat(), paint)
val s = text.toString()
val bounds = android.graphics.Rect()
paint.getTextBounds(s, start, end, bounds)
// 墨迹垂直中点:bounds.top/bottom 相对基线的偏移(top 为负)
val lineY = baseline + (bounds.top + bounds.bottom) / 2f
val w = paint.measureText(text, start, end)
val line = Paint(Paint.ANTI_ALIAS_FLAG)
line.color = paint.color
line.strokeWidth = (paint.textSize / 28f).coerceAtLeast(1f)
canvas.drawLine(x, lineY, x + w, lineY, line)
}
}
/** 置顶与重要度共用的圆环绘制:同尺寸、同描边(s/10),保证两个圆圈粗细一致。 */
private fun drawBadgeRing(
canvas: android.graphics.Canvas, cx: Float, cy: Float, size: Float, ringColor: Int,
) {
val ring = android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG).apply {
this.color = ringColor
style = android.graphics.Paint.Style.STROKE
strokeWidth = size / 10f
strokeCap = android.graphics.Paint.Cap.ROUND
}
canvas.drawCircle(cx, cy, size / 2f - ring.strokeWidth / 2f, ring)
}
/**
* 重要度圆圈数字:自绘圆环 + 数字,与置顶圆圈共用 drawBadgeRing,
* 高度(0.85 倍字号)与描边(s/10)严格一致,不再依赖系统字形 ①②③ 的墨迹差异。
*/
private class PriorityBadgeSpan(
private val badgeColor: Int,
private val size: Float,
private val digit: String,
) : android.text.style.ReplacementSpan() {
override fun getSize(
paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?,
): Int {
val s = size.toInt()
if (fm != null) {
fm.ascent = -s
fm.descent = 0
fm.top = fm.ascent
fm.bottom = fm.descent
}
return s
}
override fun draw(
canvas: android.graphics.Canvas, text: CharSequence, start: Int, end: Int,
x: Float, top: Int, baseline: Int, bottom: Int, paint: Paint,
) {
val s = size
val cy = baseline - s * 0.45f
val cx = x + s / 2f
drawBadgeRing(canvas, cx, cy, s, badgeColor)
val num = Paint(Paint.ANTI_ALIAS_FLAG).apply {
this.color = badgeColor
textSize = s * 0.60f
typeface = Typeface.DEFAULT
textAlign = Paint.Align.CENTER
}
val fm = num.fontMetrics
canvas.drawText(digit, cx, cy - (fm.ascent + fm.descent) / 2f, num)
}
}
/**
* 置顶图标:圆圈内向上箭头。
* 自绘而不是用字体字形——常用字体里没有"圆圈+箭头"的组合字符,
* 画出来才能精确控制圆圈与箭头同色、且和重要度圆圈数字(0.85 倍字号)等高。
* 颜色用品牌蓝(R.color.brand,深浅色主题各有一版),与之前的 ↑ 字符颜色一致。
*/
private class PinIconSpan(
private val iconColor: Int,
private val size: Float,
) : android.text.style.ReplacementSpan() {
override fun getSize(
paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?,
): Int {
val s = size.toInt()
if (fm != null) {
// 占位与字形等高(顶部到基线),避免行高被图标撑开
fm.ascent = -s
fm.descent = 0
fm.top = fm.ascent
fm.bottom = fm.descent
}
return s
}
override fun draw(
canvas: android.graphics.Canvas, text: CharSequence, start: Int, end: Int,
x: Float, top: Int, baseline: Int, bottom: Int, paint: Paint,
) {
val s = size
// 与 ①②③ 底部对齐:字体里的圆圈数字底缘略微越过基线(约 -0.05 个图标高),
// 圆心取基线上方 0.45 个图标高,比之前 0.50 略下移,底部不再"悬空"显偏上
val cx = x + s / 2f
val cy = baseline - s * 0.45f
// 与重要度圆圈共用同一绘制函数:同尺寸、同 1/10 描边,粗细与高度严格一致
drawBadgeRing(canvas, cx, cy, s, iconColor)
// 箭头比圈线更细(约 1/15 图标高),整体落在圆内
val arrow = Paint(Paint.ANTI_ALIAS_FLAG)
arrow.color = iconColor
arrow.style = Paint.Style.STROKE
arrow.strokeWidth = s / 15f
arrow.strokeCap = Paint.Cap.ROUND
val head = s * 0.18f
val yTop = cy - s * 0.16f
val yBot = cy + s * 0.18f
canvas.drawLine(cx, yBot, cx, yTop, arrow)
canvas.drawLine(cx - head, yTop + head, cx, yTop, arrow)
canvas.drawLine(cx + head, yTop + head, cx, yTop, arrow)
}
}

View File

@@ -32,7 +32,7 @@ class TaskSheet(
context: Context, context: Context,
private val existing: Task?, private val existing: Task?,
presetProjectId: Long, presetProjectId: Long,
private val onSaved: () -> Unit, private val onSaved: (Long) -> Unit,
) : SheetDialog(context) { ) : SheetDialog(context) {
private val root = LayoutInflater.from(context).inflate(R.layout.sheet_task, null) private val root = LayoutInflater.from(context).inflate(R.layout.sheet_task, null)
@@ -105,12 +105,13 @@ class TaskSheet(
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.delete) { _, _ -> .setPositiveButton(R.string.delete) { _, _ ->
existing?.let { existing?.let {
Store.deleteTask(it.id) // 删除会连同整个任务系列(重复实例 + 完成记录副本)及其专注记录一起删掉,
// 删除的正是当前选中任务时必须解除绑定: // 只要当前计时绑在这一系列的任意一行上就要解绑,
// 否则计时继续走,到点后完成记录会落成"未关联任务" // 否则到点后完成记录会挂到一个已经不存在的任务上
if (TimerCore.taskId == it.id) TimerCore.setTask(0, 0) val removed = Store.deleteTask(it.id)
if (TimerCore.taskId in removed) TimerCore.setTask(0, 0)
} }
onSaved() onSaved(0L)
dismiss() dismiss()
} }
.show() .show()
@@ -258,7 +259,8 @@ class TaskSheet(
periodic && due <= 0 -> Dates.todayStart() periodic && due <= 0 -> Dates.todayStart()
else -> due else -> due
} }
if (existing == null) { // 回传任务 id:专注页「没有任务 → 立即创建」需要拿新行 id 自动选中
val savedId = if (existing == null) {
Store.addTask(title, note, projectId, priority, focusMin, effectiveDue, repeatType, every, urgency) Store.addTask(title, note, projectId, priority, focusMin, effectiveDue, repeatType, every, urgency)
} else { } else {
Store.updateTask( Store.updateTask(
@@ -274,8 +276,9 @@ class TaskSheet(
repeatEvery = every, repeatEvery = every,
) )
) )
existing.id
} }
onSaved() onSaved(savedId)
dismiss() dismiss()
} }
} }

View File

@@ -28,8 +28,8 @@ import com.focusbox.app.util.visible
* *
* 项目 / 时间 / 重要度 / 紧急度 / 状态,每栏单选,行内放不下自动换行。 * 项目 / 时间 / 重要度 / 紧急度 / 状态,每栏单选,行内放不下自动换行。
* 筛选面板默认收起,只显示一行当前条件摘要;点摘要展开,选中任意胶囊后自动收起。 * 筛选面板默认收起,只显示一行当前条件摘要;点摘要展开,选中任意胶囊后自动收起。
* 默认「项目=全部 · 时间=全部 · 重要度=全部 · 紧急度=全部 · 状态=未完成」, * 默认「项目=全部 · 时间=全部 · 重要度=全部 · 紧急度=全部 · 状态=全部」,
* 与旧版「完成后从列表消失」的行为一致;想看历史切到「已完成」。 * 逾期任务与完成记录都在同一列表里;只想看待办可切到「未完成」。
*/ */
class TasksFragment : Fragment(R.layout.fragment_tasks) { class TasksFragment : Fragment(R.layout.fragment_tasks) {
@@ -83,7 +83,8 @@ class TasksFragment : Fragment(R.layout.fragment_tasks) {
adapter = TaskAdapter( adapter = TaskAdapter(
onEdit = { openSheet(it) }, onEdit = { openSheet(it) },
onToggle = { task -> onToggle = { task ->
Store.setTaskDone(task.id, !task.done) // 手动勾选完成:备注写「手动完成」,这一次不算专注,不进累计与饼图
Store.setTaskDone(task.id, !task.done, markManual = true)
reload() reload()
}, },
onStart = { task -> (activity as? MainActivity)?.startFocusOn(task) }, onStart = { task -> (activity as? MainActivity)?.startFocusOn(task) },
@@ -282,7 +283,7 @@ class TasksFragment : Fragment(R.layout.fragment_tasks) {
// 有任一条件偏离默认值时摘要高亮,提示当前列表被筛过 // 有任一条件偏离默认值时摘要高亮,提示当前列表被筛过
val filtered = filterProjectId > 0L || timeFilter != TIME_ALL || val filtered = filterProjectId > 0L || timeFilter != TIME_ALL ||
priorityFilter >= 0 || urgencyFilter >= 0 || statusFilter != 0 priorityFilter >= 0 || urgencyFilter >= 0 || statusFilter != -1
tvFilterSummary.setTextColor( tvFilterSummary.setTextColor(
ctx.col(if (filtered) R.color.brand else R.color.text_secondary) ctx.col(if (filtered) R.color.brand else R.color.text_secondary)
) )
@@ -382,7 +383,10 @@ class TasksFragment : Fragment(R.layout.fragment_tasks) {
private fun toRow(task: Task, spans: Map<Long, SessionSpan>): TaskAdapter.Row.Item { private fun toRow(task: Task, spans: Map<Long, SessionSpan>): TaskAdapter.Row.Item {
val project = projects.firstOrNull { it.id == task.projectId } val project = projects.firstOrNull { it.id == task.projectId }
val overdue = task.due > 0 && task.due < Dates.todayStart() // 重复任务按周期滚动,本轮没做不算逾期(下一轮生成时会自动结束旧实例);
// 只有不重复的任务才标「已逾期」
val overdue = task.due > 0 && task.due < Dates.todayStart() &&
task.repeatType == com.focusbox.app.model.Repeat.NONE
return TaskAdapter.Row.Item( return TaskAdapter.Row.Item(
task = task, task = task,
projectName = project?.name ?: getString(R.string.inbox), projectName = project?.name ?: getString(R.string.inbox),
@@ -414,7 +418,7 @@ class TasksFragment : Fragment(R.layout.fragment_tasks) {
} }
private fun openSheet(task: Task?) { private fun openSheet(task: Task?) {
// 新建任务时默认归到当前筛选的项目;全部/收件箱则不预选 // 新建任务时默认归到当前筛选的项目;全部/未分类则不预选
TaskSheet(requireContext(), task, filterProjectId.takeIf { it > 0 } ?: 0L) { reload() }.show() TaskSheet(requireContext(), task, filterProjectId.takeIf { it > 0 } ?: 0L) { reload() }.show()
} }
} }

View File

@@ -1,9 +1,19 @@
package com.focusbox.app.util package com.focusbox.app.util
/** 项目配色。八色一组,两两之间在色相上有足够间距,圆点上也能分辨。 */ /**
* 项目配色:20 色,按色相环顺序排列,冷暖交替铺开。
*
* 排布原则:
* 1. 前 8 个保持 v3.13 及以前的顺序不变 —— 老项目的颜色不能因为扩容而整体位移;
* 2. 新增 12 个按色相插空补齐(红橙 → 黄绿 → 青 → 蓝紫 → 紫红 → 酒红),
* 相邻两个至少差 15° 色相,圆点(20dp)和饼图上都能分清;
* 3. 统一压到中等明度(HSB 的 B ≈ 60–75%,S ≈ 40–65%),
* 深色主题下不刺眼、浅色主题下不吃掉白字,也不会盖过品牌色。
*/
object Palette { object Palette {
val colors = intArrayOf( val colors = intArrayOf(
// ---- 原有 8 色(顺序保持不变)
0xFFC75B45.toInt(), // 陶土红 0xFFC75B45.toInt(), // 陶土红
0xFFD98324.toInt(), // 琥珀 0xFFD98324.toInt(), // 琥珀
0xFFC9A227.toInt(), // 芥黄 0xFFC9A227.toInt(), // 芥黄
@@ -12,9 +22,22 @@ object Palette {
0xFF3B7DD8.toInt(), // 靛蓝 0xFF3B7DD8.toInt(), // 靛蓝
0xFF6C5CE7.toInt(), // 紫 0xFF6C5CE7.toInt(), // 紫
0xFFB7548E.toInt(), // 玫红 0xFFB7548E.toInt(), // 玫红
// ---- 新增 12 色:暖色 6 个 + 冷色 6 个
0xFFE0703C.toInt(), // 柚橙(暖)
0xFFA8B33A.toInt(), // 柠黄绿(暖偏中性)
0xFF6E8B3D.toInt(), // 橄榄(暖绿)
0xFFA34A52.toInt(), // 酒红(暖)
0xFFD96C93.toInt(), // 玫瑰粉(暖)
0xFFA9663A.toInt(), // 焦糖(暖)
0xFF2E7D57.toInt(), // 森林绿(冷)
0xFF45B08C.toInt(), // 薄荷(冷)
0xFF2E9AAE.toInt(), // 青蓝(冷)
0xFF4B9CD3.toInt(), // 天蓝(冷)
0xFF5B6BC0.toInt(), // 靛紫(冷)
0xFF9A7BD0.toInt(), // 丁香紫(冷)
) )
/** 收件箱用中性灰,避免和自建项目争注意力 */ /** 未分类用中性灰,避免和自建项目争注意力 */
const val INBOX = 0xFF7A756C.toInt() const val INBOX = 0xFF7A756C.toInt()
fun colorAt(index: Int): Int = colors[index.mod(colors.size)] fun colorAt(index: Int): Int = colors[index.mod(colors.size)]

View File

@@ -15,6 +15,14 @@ object Prefs {
fun init(context: Context) { fun init(context: Context) {
sp = context.getSharedPreferences("focusbox", Context.MODE_PRIVATE) sp = context.getSharedPreferences("focusbox", Context.MODE_PRIVATE)
// 一次性把旧的默认「未完成」改为「全部」:任务页要同时看到逾期与完成记录。
// 用户之后仍可手动切回「未完成」,迁移只执行一次。
if (!sp.getBoolean("ui_filter_status_all_migrated", false)) {
if (sp.getInt("ui_filter_status", 0) == 0) {
sp.edit().putInt("ui_filter_status", -1).apply()
}
sp.edit().putBoolean("ui_filter_status_all_migrated", true).apply()
}
} }
// ---- 时长 ---- // ---- 时长 ----
@@ -62,9 +70,10 @@ object Prefs {
set(v) = sp.edit().putBoolean("lock_fullscreen", v).apply() set(v) = sp.edit().putBoolean("lock_fullscreen", v).apply()
// ---- 目标 ---- // ---- 目标 ----
// 无上限:输入多大存多大(下限 15 防止误输 0/负数把目标显示搞崩)
var dailyGoalMinutes: Int var dailyGoalMinutes: Int
get() = sp.getInt("daily_goal", 120) get() = sp.getInt("daily_goal", 120)
set(v) = sp.edit().putInt("daily_goal", v.coerceIn(15, 720)).apply() set(v) = sp.edit().putInt("daily_goal", v.coerceAtLeast(15)).apply()
/** 0 跟随系统 / 1 浅色 / 2 深色 */ /** 0 跟随系统 / 1 浅色 / 2 深色 */
var themeMode: Int var themeMode: Int
@@ -164,7 +173,7 @@ object Prefs {
set(v) = sp.edit().putInt("ui_filter_urgency", v).apply() set(v) = sp.edit().putInt("ui_filter_urgency", v).apply()
var uiFilterStatus: Int var uiFilterStatus: Int
get() = sp.getInt("ui_filter_status", 0) get() = sp.getInt("ui_filter_status", -1)
set(v) = sp.edit().putInt("ui_filter_status", v).apply() set(v) = sp.edit().putInt("ui_filter_status", v).apply()
var uiFilterExpanded: Boolean var uiFilterExpanded: Boolean

View File

@@ -15,6 +15,7 @@ import com.focusbox.app.util.col
import com.focusbox.app.util.dpf import com.focusbox.app.util.dpf
import com.focusbox.app.util.spf import com.focusbox.app.util.spf
import kotlin.math.cos import kotlin.math.cos
import kotlin.math.roundToInt
import kotlin.math.sin import kotlin.math.sin
/** /**
@@ -43,16 +44,28 @@ class LabelDonutView @JvmOverloads constructor(
invalidate() invalidate()
} }
/** 环中心的小字(总专注 / 任务占比) */ /**
var centerCaption: String = "" * 环上最多给几条切片牵引线标注(取占比最高的若干条)。
set(value) { *
field = value * 超出部分**不再合并成「其他」**:环本身照旧把每一块都按真实占比画出来,
invalidate() * 只是没牵到线的切片记进 [unlabeled],由调用方在图表下方完整列出。
} * 6 条(每侧 3 条)在 222dp 高度里间距仍舒展,再往上夹逼会把相邻标注压到一起。
*/
/** 最多画几条引线标注,多出来的合并成「其他」,避免标注挤成一团 */
var maxLabels: Int = 6 var maxLabels: Int = 6
/** 扇区张角小于该值时不牵线:引线会叠在同一个点上,约 0.8% 以下的占比 */
private val minLabelSweep = 3f
/**
* 环上没能牵线的切片(占比排在 [maxLabels] 之外,或扇区太窄),按占比从高到低。
* 调用方必须把它们全部列在图表下方,否则这些任务/项目在视觉上就"消失"了。
*/
var unlabeled: List<Slice> = emptyList()
private set
/** 已经牵到线的切片,按同一套规则算出,供绘制使用 */
private var labeled: List<Slice> = emptyList()
private val strokeW = context.dpf(28f) private val strokeW = context.dpf(28f)
private val arcPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { private val arcPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
@@ -76,13 +89,7 @@ class LabelDonutView @JvmOverloads constructor(
textAlign = Paint.Align.CENTER textAlign = Paint.Align.CENTER
isFakeBoldText = true isFakeBoldText = true
} }
private val captionPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { private val linePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.STROKE
textSize = context.spf(10f)
color = context.col(R.color.text_tertiary)
textAlign = Paint.Align.CENTER
}
private val linePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
style = Paint.Style.STROKE
strokeWidth = context.dpf(1.2f) strokeWidth = context.dpf(1.2f)
} }
private val dotPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.FILL } private val dotPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.FILL }
@@ -96,9 +103,29 @@ class LabelDonutView @JvmOverloads constructor(
fun setSlices(list: List<Slice>) { fun setSlices(list: List<Slice>) {
slices = list slices = list
plan(list)
invalidate() invalidate()
} }
/**
* 标注计划:按占比排序,前 [maxLabels] 名里扇区够宽的才牵线,
* 其余(含前 N 名但太窄的)全部落到 [unlabeled]。
*/
private fun plan(list: List<Slice>) {
val total = list.sumOf { it.seconds }
val sorted = list.sortedByDescending { it.seconds }
val head = if (total <= 0) emptyList() else sorted.take(maxLabels).filter {
it.seconds.toFloat() / total * 360f >= minLabelSweep
}
labeled = head
// 用「逐个摘除」而不是 toSet 差集:同名同色同时长的两条切片也能各算一次
val left = head.toMutableList()
unlabeled = sorted.filter { s ->
val i = left.indexOf(s)
if (i >= 0) { left.removeAt(i); false } else true
}
}
private data class Tag( private data class Tag(
val slice: Slice, val slice: Slice,
val midDeg: Float, val midDeg: Float,
@@ -123,21 +150,25 @@ class LabelDonutView @JvmOverloads constructor(
return return
} }
val shown = collapse(slices)
val box = RectF(cx - r, cy - r, cx + r, cy + r) val box = RectF(cx - r, cy - r, cx + r, cy + r)
val gapDeg = if (shown.size > 1) 2.2f else 0f // 不再合并「其他」后切片可能有几十条,固定 2.2° 的缝隙累计起来会吃掉小半个环
// (40 条就是 88°),因此按条数摊薄,总缝隙不超过约 14°
val gapDeg = if (slices.size > 1) minOf(2.2f, 14f / slices.size) else 0f
// ---- 弧与百分比 // ---- 弧与百分比:每一块都按真实占比画,绝不合并
var start = -90f var start = -90f
val tags = ArrayList<Tag>(shown.size) val tags = ArrayList<Tag>(labeled.size)
shown.forEach { s -> val pending = labeled.toMutableList()
slices.forEach { s ->
val sweep = s.seconds.toFloat() / total * 360f val sweep = s.seconds.toFloat() / total * 360f
val midDeg = start + sweep / 2f val midDeg = start + sweep / 2f
arcPaint.color = s.color arcPaint.color = s.color
canvas.drawArc(box, start + gapDeg / 2f, (sweep - gapDeg).coerceAtLeast(0.5f), false, arcPaint) canvas.drawArc(box, start + gapDeg / 2f, (sweep - gapDeg).coerceAtLeast(0.2f), false, arcPaint)
val arcLen = sweep / 360f * (2 * Math.PI.toFloat() * r) val arcLen = sweep / 360f * (2 * Math.PI.toFloat() * r)
val pct = "${(s.seconds * 100f / total).toInt().coerceAtLeast(1)}%" // 与下方明细用同一套舍入(四舍五入),否则 7.6% 环上写 7、列表写 8,
// 看起来就像「排第 7 的都牵了线,前 6 反而没牵」
val pct = "${(s.seconds * 100.0 / total).roundToInt().coerceAtLeast(1)}%"
// 环加粗后百分比必须完整落在色带里:按实测字宽缩字号,两侧各留 5dp 边距 // 环加粗后百分比必须完整落在色带里:按实测字宽缩字号,两侧各留 5dp 边距
var pctSize = 11f var pctSize = 11f
pctPaint.textSize = context.spf(pctSize) pctPaint.textSize = context.spf(pctSize)
@@ -154,14 +185,16 @@ class LabelDonutView @JvmOverloads constructor(
canvas.drawText(pct, px, py - (fm.ascent + fm.descent) / 2f, pctPaint) canvas.drawText(pct, px, py - (fm.ascent + fm.descent) / 2f, pctPaint)
} }
// 太薄的扇区不牵线,否则几条线会叠在同一个点上 // 只有进了标注计划的切片才牵线;pending 逐个摘除,重复切片也各算一次
if (sweep >= 5f) { if (sweep >= minLabelSweep && pending.remove(s)) {
val cosA = cos(radians(midDeg)) val cosA = cos(radians(midDeg))
val sinA = sin(radians(midDeg)) val sinA = sin(radians(midDeg))
tags.add( tags.add(
Tag( Tag(
slice = s, slice = s,
midDeg = midDeg, midDeg = midDeg,
// 只看扇区中线在左半还是右半:标注就该贴在自己那块色旁边。
// v3.14 试过强行左右均分,被分到对面的扇区引线必然横穿圆环,已撤回。
side = if (cosA >= 0.0) 1 else -1, side = if (cosA >= 0.0) 1 else -1,
anchorY = cy + ((r + strokeW) * sinA).toFloat(), anchorY = cy + ((r + strokeW) * sinA).toFloat(),
) )
@@ -177,24 +210,15 @@ class LabelDonutView @JvmOverloads constructor(
private fun radians(deg: Float): Double = Math.toRadians(deg.toDouble()) private fun radians(deg: Float): Double = Math.toRadians(deg.toDouble())
private fun collapse(list: List<Slice>): List<Slice> { /**
if (list.size <= maxLabels) return list * 环中心只画一行:累计时间(或空态提示)。
val head = list.take(maxLabels - 1) * 之前按 cy + 2dp 硬偏移定位,字面重心偏下;改为按字体度量
val rest = list.drop(maxLabels - 1) * 把墨迹垂直中心落在圆心,并删除原来的小字说明行。
return head + Slice( */
name = context.getString(R.string.slice_other),
seconds = rest.sumOf { it.seconds },
color = context.col(R.color.text_tertiary),
)
}
private fun drawCenter(canvas: Canvas, cx: Float, cy: Float, emptyHint: String?) { private fun drawCenter(canvas: Canvas, cx: Float, cy: Float, emptyHint: String?) {
val big = centerText.takeIf { it.isNotBlank() } ?: "0m" val text = emptyHint ?: centerText.ifBlank { "0m" }
canvas.drawText(big, cx, cy + context.dpf(2f), centerPaint) val fm = centerPaint.fontMetrics
val cap = emptyHint ?: centerCaption canvas.drawText(text, cx, cy - (fm.ascent + fm.descent) / 2f, centerPaint)
if (cap.isNotBlank()) {
canvas.drawText(cap, cx, cy + context.dpf(18f), captionPaint)
}
} }
/** /**
@@ -256,7 +280,8 @@ class LabelDonutView @JvmOverloads constructor(
linePaint.color = color linePaint.color = color
linePaint.alpha = 200 linePaint.alpha = 200
// 从环外缘斜出到折点,再水平指向外侧圆点 // 标注永远在扇区自己那一侧,从环外缘斜出到折点,再水平指向外侧圆点,
// 引线不会跨过圆环(v3.14 的三段式是为强制左右均分服务的,已随均分一起撤回)。
canvas.drawLine(startX, startY, kneeX, tag.y, linePaint) canvas.drawLine(startX, startY, kneeX, tag.y, linePaint)
canvas.drawLine(kneeX, tag.y, dotX, tag.y, linePaint) canvas.drawLine(kneeX, tag.y, dotX, tag.y, linePaint)

View File

@@ -1,8 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
锁屏全屏倒计时·横屏专属排版(区别于竖屏的纯纵向堆叠): 锁屏全屏倒计时·横屏专属排版(区别于竖屏的纯纵向堆叠):
左右对称分栏 —— 左侧倒计时(大)+ 任务名,右侧时钟(大)+ 日期星期, 左右对称分栏——左侧倒计时(大)+ 任务名,右侧时钟(大)+ 日期星期,
两侧主字号统一 96sp,视觉左右对应;无「工作中/休息中」提示。 两侧主字号统一 130sp,视觉左右对应;无「工作中/休息中」提示。
分割线:保持最初可见版本的原始实现——静态 View 直接放在两栏之间,
固定 dp 高度,无任何运行时改动(此前的 View.post / fontMetrics /
match_parent 结构化三版方案在锁屏/悬浮窗链路上全部失效)。
高度 150dp ≈ 130sp 时间文字的墨迹高度(1.17 × 130sp),仅分割两块大时间。
v2.2/v2.3 位置对齐:分割线作为横排直系子 View 时,center_vertical 相对「整个
左右两栏(时间+10dp间距+15sp小字)」居中,下方多出的一截把线的中心往下拉。
v2.2 只在分割线外套锚点 FrameLayout,但锚点列比侧栏矮(没有补小字占位),
三列各自居中后锚点中心仍落在屏幕中心,位置不变、修复无效。
v2.3 改为中列完整镜像左右两栏(时间锚点 + 同规格小字占位),三列同高同顶,
锚点中心严格等于时间文字中心;纯静态 XML,不受锁屏/悬浮窗特殊窗口运行时
调整失效问题影响,字体缩放变化也同步。
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lockRoot" android:id="@+id/lockRoot"
@@ -28,26 +41,22 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:includeFontPadding="false" android:includeFontPadding="false"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textSize="96sp" android:textSize="130sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tvLockTask" android:id="@+id/tvLockTask"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="20dp" android:layout_marginTop="10dp"
android:ellipsize="end" android:ellipsize="end"
android:maxWidth="320dp" android:maxWidth="320dp"
android:maxLines="1" android:maxLines="1"
android:textColor="#CCFFFFFF" android:textColor="#99FFFFFF"
android:textSize="17sp" /> android:textSize="15sp" />
</LinearLayout> </LinearLayout>
<!-- 中:细分隔线 --> <!-- 中列分割线已按用户要求移除(v2.9):左右两栏各占一半宽度,文字各自居中 -->
<View
android:layout_width="1dp"
android:layout_height="180dp"
android:background="#26FFFFFF" />
<!-- 右:时钟(大)+ 日期星期在时钟下面 --> <!-- 右:时钟(大)+ 日期星期在时钟下面 -->
<LinearLayout <LinearLayout
@@ -63,15 +72,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:includeFontPadding="false" android:includeFontPadding="false"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textSize="96sp" android:textSize="130sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tvLockDate" android:id="@+id/tvLockDate"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="20dp" android:layout_marginTop="10dp"
android:letterSpacing="0.08"
android:textColor="#99FFFFFF" android:textColor="#99FFFFFF"
android:textSize="15sp" /> android:textSize="15sp" />
</LinearLayout> </LinearLayout>

View File

@@ -38,15 +38,6 @@
android:textSize="96sp" android:textSize="96sp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView
android:id="@+id/tvLockMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:letterSpacing="0.2"
android:textColor="#66FFFFFF"
android:textSize="13sp" />
<TextView <TextView
android:id="@+id/tvLockTask" android:id="@+id/tvLockTask"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@@ -2,8 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="vertical"
android:gravity="center_vertical"
android:background="@drawable/bg_card" android:background="@drawable/bg_card"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
@@ -13,6 +12,15 @@
android:paddingTop="14dp" android:paddingTop="14dp"
android:paddingBottom="14dp"> android:paddingBottom="14dp">
<!-- 项目头:点击整行展开/收起任务列表 -->
<LinearLayout
android:id="@+id/projectHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="?attr/selectableItemBackground">
<View <View
android:id="@+id/colorBar" android:id="@+id/colorBar"
android:layout_width="4dp" android:layout_width="4dp"
@@ -63,4 +71,25 @@
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_more" android:src="@drawable/ic_more"
android:contentDescription="@string/edit" /> android:contentDescription="@string/edit" />
</LinearLayout>
<!-- 展开区:该项目下添加过的任务(含已完成),默认收起 -->
<LinearLayout
android:id="@+id/taskList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone" />
<TextView
android:id="@+id/tvTaskEmpty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="18dp"
android:paddingEnd="12dp"
android:paddingBottom="12dp"
android:text="@string/project_no_tasks"
android:textColor="@color/text_tertiary"
android:textSize="12sp"
android:visibility="gone" />
</LinearLayout> </LinearLayout>

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 项目卡展开后的任务行:结构与任务列表一致,但不显示分类(项目名)。
顶部任务行 meta =「专注时长 · 最近完成 · 累计次数+累计专注」,不划线;
完成记录行同一布局,任务名划线、meta 为「日期 周几 起-止 · 专注X」。
两种行右侧都常驻开始键(btnTaskPlay),点击即开始该任务。 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="?attr/selectableItemBackground"
android:paddingStart="18dp"
android:paddingEnd="10dp"
android:paddingTop="9dp"
android:paddingBottom="9dp">
<View
android:id="@+id/taskColorBar"
android:layout_width="3dp"
android:layout_height="30dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="11dp"
android:orientation="vertical">
<TextView
android:id="@+id/tvTaskTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="@color/text"
android:maxLines="2"
android:ellipsize="end" />
<TextView
android:id="@+id/tvTaskMeta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:maxLines="2"
android:ellipsize="end"
style="@style/T.Caption" />
</LinearLayout>
<ImageView
android:id="@+id/btnTaskPlay"
android:layout_width="34dp"
android:layout_height="34dp"
android:layout_marginStart="6dp"
android:padding="9dp"
android:background="@drawable/bg_play_circle"
android:scaleType="fitCenter"
android:src="@drawable/ic_play"
android:contentDescription="@string/start" />
</LinearLayout>

View File

@@ -102,7 +102,7 @@
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:background="@drawable/bg_btn_ghost" android:background="@drawable/bg_btn_ghost"
android:gravity="center" android:gravity="center"
android:text="@string/clear_task" android:text="@string/create_now"
android:textSize="14sp" android:textSize="14sp"
android:textColor="@color/text_secondary" android:textColor="@color/text_secondary"
android:visibility="gone" /> android:visibility="gone" />

View File

@@ -91,7 +91,7 @@
android:text="@string/project_color" android:text="@string/project_color"
style="@style/T.Section" /> style="@style/T.Section" />
<!-- 八色圆点横向可滑,末位颜色不再被弹层右边缘裁掉 --> <!-- 20 色圆点排成两行(每行 10 个),屏幕再窄也是在容器内横向滑动,不会被弹层右边缘裁掉 -->
<HorizontalScrollView <HorizontalScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -104,7 +104,7 @@
android:id="@+id/colorRow" android:id="@+id/colorRow"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="vertical"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingBottom="4dp" /> android:paddingBottom="4dp" />
</HorizontalScrollView> </HorizontalScrollView>

View File

@@ -14,6 +14,8 @@
<string name="mode_long_break">长休息</string> <string name="mode_long_break">长休息</string>
<string name="start">开始专注</string> <string name="start">开始专注</string>
<string name="create_now">立即创建</string>
<string name="task_created">任务已创建,已选为当前任务</string>
<string name="start_break">开始休息</string> <string name="start_break">开始休息</string>
<string name="start_timing">开始计时</string> <string name="start_timing">开始计时</string>
<string name="pause">暂停</string> <string name="pause">暂停</string>
@@ -49,14 +51,16 @@
<string name="no_task">未选择任务 · 直接开始也可以</string> <string name="no_task">未选择任务 · 直接开始也可以</string>
<string name="pick_task">选择任务</string> <string name="pick_task">选择任务</string>
<string name="task_selected">已选任务</string> <string name="task_selected">已选任务</string>
<!-- 计时进行中,任务已锁定:右侧不再显示「已选任务」 -->
<string name="task_focusing">正在专注</string>
<string name="pick_project">选择项目</string> <string name="pick_project">选择项目</string>
<string name="pick_back">返回上一步</string> <string name="pick_back">返回上一步</string>
<string name="clear_task">不选择任务,直接开始</string> <string name="clear_task">立即创建</string>
<string name="pick_step">第 %1$d 步 / 共 2 步</string> <string name="pick_step">第 %1$d 步 / 共 2 步</string>
<string name="pick_project_hint">先选项目,再从这个项目里挑一件要做的事</string> <string name="pick_project_hint">先选项目,再从这个项目里挑一件要做的事</string>
<string name="pick_task_hint">选中的任务会自动套用它设定的专注时长</string> <string name="pick_task_hint">选中的任务会自动套用它设定的专注时长</string>
<string name="pick_project_meta">%1$d 项待办</string> <string name="pick_project_meta">%1$d 项任务</string>
<string name="pick_task_empty">这个项目还没有待办任务,点返回换个项目</string> <string name="pick_task_empty">这个项目还没有任务,点返回换个项目</string>
<string name="no_task_to_pick">还没有待办任务,先去「任务」新建一个</string> <string name="no_task_to_pick">还没有待办任务,先去「任务」新建一个</string>
<string name="rounds_today">今天第 %1$d 个番茄</string> <string name="rounds_today">今天第 %1$d 个番茄</string>
@@ -122,14 +126,21 @@
<string name="archive">归档</string> <string name="archive">归档</string>
<string name="unarchive">取消归档</string> <string name="unarchive">取消归档</string>
<string name="archived">已归档</string> <string name="archived">已归档</string>
<string name="delete_task_confirm">删除这个任务?专注记录会保留。</string> <string name="delete_task_confirm">删除这个任务?该任务的专注记录与统计会一并删除,不可恢复。</string>
<string name="delete_project_confirm">删除项目「%1$s」?项目下的任务会移到收件箱。</string> <string name="delete_project_confirm">删除项目「%1$s」?项目下的任务、这些任务的专注记录与统计会一并删除,不可恢复。</string>
<string name="projects_title">项目</string> <string name="projects_title">项目</string>
<string name="project_summary">%1$d 个项目 · %2$d 个待办</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_task_last_done">最近%1$s完成</string>
<string name="project_task_done_count">累计%1$d次</string>
<string name="project_expand_done">展开完成记录(%1$d)</string>
<string name="project_collapse_done">收起完成记录(%1$d)</string>
<string name="project_summary">%1$d个项目 · %2$d个任务</string>
<string name="add_project">新建项目</string> <string name="add_project">新建项目</string>
<string name="project_name_hint">项目名称</string> <string name="project_name_hint">项目名称</string>
<string name="inbox">收件箱</string> <string name="inbox">未分类</string>
<string name="project_color">颜色</string> <string name="project_color">颜色</string>
<string name="show_archived">显示已归档</string> <string name="show_archived">显示已归档</string>
<string name="empty_projects">还没有项目\n按用途分组,统计里就能看到时间花在哪</string> <string name="empty_projects">还没有项目\n按用途分组,统计里就能看到时间花在哪</string>
@@ -160,9 +171,11 @@
<string name="period_month">%1$d年%2$d月</string> <string name="period_month">%1$d年%2$d月</string>
<string name="period_year">%1$d年</string> <string name="period_year">%1$d年</string>
<string name="slice_other">其他</string> <string name="slice_other">其他</string>
<!-- 环图下方明细行:「时长 · 占比」 -->
<string name="legend_meta">%1$s · %2$s</string>
<string name="no_record">暂无记录</string> <string name="no_record">暂无记录</string>
<string name="summary_title">累计</string> <string name="summary_title">累计</string>
<string name="streak_days">连续打卡</string> <string name="streak_days">连续专注</string>
<string name="streak_value">%1$d天</string> <string name="streak_value">%1$d天</string>
<string name="total_focus">总专注</string> <string name="total_focus">总专注</string>
<string name="total_pomo">总番茄</string> <string name="total_pomo">总番茄</string>
@@ -190,6 +203,8 @@
<string name="lock_fullscreen_title">锁屏全屏倒计时</string> <string name="lock_fullscreen_title">锁屏全屏倒计时</string>
<string name="lock_perm_title">锁屏显示权限</string> <string name="lock_perm_title">锁屏显示权限</string>
<string name="lock_perm_value">去开启</string> <string name="lock_perm_value">去开启</string>
<string name="overlay_perm_title">悬浮窗权限(锁屏显示)</string>
<string name="perm_granted">已开启</string>
<string name="go_set">去设置</string> <string name="go_set">去设置</string>
<string name="project_sort_index">排序序号</string> <string name="project_sort_index">排序序号</string>
<string name="sort_index_hint">序号,越小越靠前</string> <string name="sort_index_hint">序号,越小越靠前</string>
@@ -203,6 +218,9 @@
<string name="theme_light">浅色</string> <string name="theme_light">浅色</string>
<string name="theme_dark">深色</string> <string name="theme_dark">深色</string>
<string name="clear_data">清空所有数据</string> <string name="clear_data">清空所有数据</string>
<string name="purge_orphan">清空未关联数据</string>
<string name="purge_confirm">将删除 %1$d 条没有关联任务的专注记录(合计 %2$s)。\n这些记录在统计里只记作「未关联任务」,删掉后饼图对应分块会消失,此操作不可恢复。</string>
<string name="purge_none">当前没有未关联任务的专注记录,无需清理。</string>
<string name="clear_data_hint">项目、任务、专注记录全部删除,不可恢复</string> <string name="clear_data_hint">项目、任务、专注记录全部删除,不可恢复</string>
<string name="clear_confirm">确定清空全部数据?此操作不可恢复。</string> <string name="clear_confirm">确定清空全部数据?此操作不可恢复。</string>
<string name="about_version">V%1$s</string> <string name="about_version">V%1$s</string>
@@ -220,7 +238,7 @@
<string name="notif_action_stop">结束</string> <string name="notif_action_stop">结束</string>
<string name="notif_no_task">未选择任务</string> <string name="notif_no_task">未选择任务</string>
<string name="notif_focus_done">任务完成</string> <string name="notif_focus_done">任务完成</string>
<string name="notif_focus_done_text">恭喜你,再接再厉,休息下再继续</string> <string name="notif_focus_done_text">再接再厉,短暂的休息下再继续</string>
<string name="notif_break_done">休息结束</string> <string name="notif_break_done">休息结束</string>
<string name="notif_break_done_text">准备好就开始下一轮</string> <string name="notif_break_done_text">准备好就开始下一轮</string>
@@ -234,5 +252,5 @@
<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> <string name="stat_today_minutes">%1$d分钟</string>
<!-- %1$d 连续天数 / %2$d 每日目标分钟 --> <!-- %1$d 连续天数 / %2$d 每日目标分钟 -->
<string name="stat_streak">连续打卡%1$d天 · 目标%2$d分钟</string> <string name="stat_streak">连续专注%1$d天 · 目标%2$d分钟</string>
</resources> </resources>