Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cad26fbdb | ||
|
|
035da90a76 | ||
|
|
68b9961784 | ||
|
|
d03fb45adf | ||
|
|
e7089ae76b | ||
|
|
1d355693be | ||
|
|
93faf6d21e | ||
|
|
a5cd605a5c | ||
|
|
05a3462c6e | ||
|
|
c8cc773fef | ||
|
|
c0182de5e5 | ||
|
|
65dd5bfe91 | ||
|
|
fd674322a1 | ||
|
|
bc01e0ac67 |
80
CHANGELOG.md
80
CHANGELOG.md
@@ -1,8 +1,84 @@
|
|||||||
# 变更记录
|
# 变更记录
|
||||||
|
|
||||||
## 2026-11-29 · 锁屏权限引导:设置页新增锁屏显示权限入口一键跳应用启动管理,版本 1.0
|
## 2026-11-30 · 分割线改fontMetrics直接计算修复消失;删除线按墨迹中点自绘居中;置顶圆圈粗细与底部对齐调整,版本 1.8
|
||||||
|
|
||||||
- 同步源码更新 3 个文件(新增/修改 3,删除 0)。
|
- 同步源码更新 4 个文件(新增/修改 4,删除 0)。
|
||||||
|
|
||||||
|
## 2026-11-29 · 分割线算法化/删除线居中/置顶图标对齐(v1.8)
|
||||||
|
|
||||||
|
- 横屏分割线消失修复:上一版用 View.post 等布局完成后取 height 再赋值,在锁屏/悬浮窗链路上时机不稳导致线整条消失;改为直接由 paint.fontMetrics 算出文字实际高度(includeFontPadding=false 时 TextView 高度即 ascent..descent 跨度),零时序依赖、立即生效(Activity 与悬浮窗两链路同步)
|
||||||
|
- 删除线视觉居中:系统 StrikethroughSpan 按「字体半高」定位(baseline + ascent/2),数字/汉字实际墨迹顶比字体 ascent 低,线看起来偏下;改为 MidStrikeSpan 自绘——按 getTextBounds 实际墨迹边界取垂直中点,线严格穿过文字中间,仍只划任务名不划图标
|
||||||
|
- 置顶图标对齐与粗细:圈线粗细改为 1/10 图标高(贴近重要度圆圈数字的描边),箭头细化为 1/15;圆心从基线上方 0.50 下移到 0.45 个图标高(圆圈数字底缘本就略过基线,底部对齐不再偏上)
|
||||||
|
- versionCode 42
|
||||||
|
|
||||||
|
## 2026-11-29 · 锁屏/通知/任务列表细节修复(v1.7)
|
||||||
|
|
||||||
|
- 任务完成文案:「恭喜你,再接再厉,休息下再继续」→「再接再厉,短暂的休息下再继续」(通知与锁屏共用)
|
||||||
|
- 横屏锁屏分割线:只分割两块大时间——运行时把分割线高度对齐倒计时文字的实际渲染高度(Activity 与悬浮窗两条链路都同步),不再盖住下方任务名/日期行
|
||||||
|
- 置顶图标颜色修复:PinIconSpan 在 `Paint(...).apply { this.color = color }` 里,作用域内 color 被 Paint 自身属性遮蔽,实际画的是 Paint 默认黑色——改名 iconColor 并显式赋值,恢复品牌蓝;深色 #64A8FF / 浅色 #2F80ED 自动适配
|
||||||
|
- 已完成删除线恢复:StrikethroughSpan 之前在 tvTitle.text 赋值之后才挂 span 导致不生效,移到赋值之前;仍然只划任务名、不划图标
|
||||||
|
- versionCode 41
|
||||||
|
|
||||||
|
## 2026-11-29 · 任务列表/统计细节打磨(v1.6)
|
||||||
|
|
||||||
|
- 已完成任务:删除线只画任务名(StrikethroughSpan 限定区间),后面的重要度圆圈/紧急度星标/置顶图标不再被划线
|
||||||
|
- 「随时」置顶图标:由裸 ↑ 字符改为自绘「圆圈内向上箭头」(PinIconSpan,ReplacementSpan 实现)——圆圈与箭头同为品牌蓝,图标大小与重要度圆圈数字一致(0.85 倍字号)
|
||||||
|
- 统计页两个饼图(项目分布/任务分布):环中心的「总专注」「任务占比」小字删除,累计时间按字体度量把墨迹垂直中心落在圆心,真正居中
|
||||||
|
- 设置页悬浮窗权限行:已授权时不再显示右侧箭头、且整行不可点(该权限无应用内开关,避免误以为可点);未授权保持「去设置」可点跳授权页
|
||||||
|
- 每日目标:数值支持点击弹窗直接输入分钟数(软键盘数字盘,非法输入红框提示),加减步进保留;去除 720 分钟上限(下限 15 防误输)
|
||||||
|
- versionCode 40
|
||||||
|
|
||||||
|
## 2026-11-29 · 悬浮窗补齐遮状态栏与横竖屏排版;解锁残留秒级自动关窗(v1.5)
|
||||||
|
|
||||||
|
- 悬浮窗遮状态栏:EMUI 把悬浮窗限制在状态栏以下内容区,顶部时间/信号/电池露出——窗口改为比屏幕更大(高度补状态栏+导航栏)、y 负偏移状态栏高度向上顶出,配 FLAG_LAYOUT_NO_LIMITS 越界绘制,黑底完整盖住状态栏区域(护眼滤镜类 App 同款做法)
|
||||||
|
- 横竖屏排版恢复:TimerService 增加 onConfigurationChanged 回调,旋转时立刻重建悬浮窗窗口换对应布局;update() 内旋转检测保留双保险
|
||||||
|
- 解锁残留修复:悬浮窗每秒刷新时检查 keyguard,解锁后自动关窗(不依赖 USER_PRESENT 广播),不再出现"解锁后全屏界面挡住桌面"
|
||||||
|
- 亮屏时悬浮窗显示中仍尝试直启沉浸式锁屏页(主题级全屏+横竖屏排版),成功则接管显示,被拦无损失
|
||||||
|
- 说明:v1.4 并未删除沉浸式遮状态栏与横屏布局——它们在锁屏 Activity 上完好,问题出在悬浮窗是新窗口没有继承这两个表现,本版补齐
|
||||||
|
- 版本 1.4 → 1.5(versionCode 39)
|
||||||
|
|
||||||
|
## 2026-11-29 · 锁屏倒计时主链路改悬浮窗:WindowManager 直接画在锁屏上,不受"后台弹出界面"限制(v1.4)
|
||||||
|
|
||||||
|
- 根因链补全:鸿蒙 4.0 的"后台弹出界面"策略只拦 startActivity,悬浮窗(WindowManager.addView)不属于 Activity 启动、不在拦截范围——这正是专注清单等 App 锁屏显示稳定的原因(其权限列表含"悬浮窗")
|
||||||
|
- 新增 SYSTEM_ALERT_WINDOW 权限 + service/LockOverlay.kt:计时中锁屏/灭屏时把黑底倒计时窗口(TYPE_APPLICATION_OVERLAY + FLAG_SHOW_WHEN_LOCKED)直接画在锁屏之上;复用锁屏页布局(自动选竖屏/横屏版本,旋转重建窗口);FLAG_NOT_FOCUSABLE 不影响锁屏密码输入;点按任意处关闭;解锁(USER_PRESENT)自动关闭;计时结束自动关闭
|
||||||
|
- 三级降级链路:悬浮窗(有权限,主链路)→ 全屏意图通知/服务直启 → 抽屉通知点进锁屏页
|
||||||
|
- 设置页新增「悬浮窗权限(锁屏显示)」入口:有公开检测 API(canDrawOverlays),显示"已开启/去开启",一键跳本应用授权页
|
||||||
|
- 版本 1.3 → 1.4(versionCode 38)
|
||||||
|
|
||||||
|
## 2026-11-29 · 竖屏删「工作中」提示;横屏时间加大、下方文字统一规格并收紧间距(v1.3)
|
||||||
|
|
||||||
|
- 竖屏锁屏页删除「工作中/休息中」字样(代码同步移除 tvLockMode 赋值,横竖屏均无该控件)
|
||||||
|
- 横屏两个时间(倒计时/时钟)96sp → 130sp,尽可能大
|
||||||
|
- 横屏时间下方文字(左任务名 / 右日期星期)统一为 15sp、同色 #99FFFFFF,与时间距离由 20dp 收紧到 10dp(约一半)
|
||||||
|
- 右侧日期星期去掉 letterSpacing,与时钟严格左右居中(与左侧倒计时/任务名的居中方式一致)
|
||||||
|
- 版本 1.2 → 1.3(versionCode 37)
|
||||||
|
|
||||||
|
## 2026-11-29 · 项目排序模式(序号+置顶);横屏锁屏遮状态栏、排版对称化(v1.2)
|
||||||
|
|
||||||
|
- 项目排序模式:数据库 v6 → v7,projects 新增 sort_index(序号)与 pinned_at(置顶时间)两列,旧数据自动迁移(默认 0 = 不置顶/未设置)
|
||||||
|
- 列表排序规则:归档仍排最后 → 置顶项目排最前(多个置顶按置顶时间倒序,越近越靠前)→ 非置顶按序号升序(同序号按创建先后)
|
||||||
|
- 新增/编辑项目弹窗:序号输入框(数字,留空按 0)+ 置顶开关;已置顶再保存不刷新置顶时间,新勾置顶以保存时刻为准;归档/取消归档切换原样保留序号与置顶状态
|
||||||
|
- 横屏锁屏:主题加 windowFullscreen 强制全屏,横竖屏都彻底遮掉状态栏时间/信号/电池
|
||||||
|
- 横屏排版重排:左侧倒计时(96sp)+ 任务名,右侧时钟(96sp)+ 日期星期移到时钟下面,两侧主字号统一、左右对称;删除横屏「工作中/休息中」提示(竖屏保留)
|
||||||
|
- 版本 1.1 → 1.2(versionCode 36)
|
||||||
|
|
||||||
|
## 2026-11-29 · 锁屏倒计时改灭屏投递拉起不再出横幅;沉浸式遮状态栏;横屏专属排版;版本 1.1
|
||||||
|
|
||||||
|
- 同步源码更新 5 个文件(新增/修改 5,删除 0)。
|
||||||
|
|
||||||
|
## 2026-11-29 · 锁屏倒计时改灭屏投递拉起(不再出通知横幅);沉浸式遮状态栏;横屏专属排版(v1.1)
|
||||||
|
|
||||||
|
- 拉起流程重构:实测鸿蒙 4.0 即使开了"后台弹出界面"等全部权限,亮屏后服务 startActivity 仍被静默拦截,而全屏意图亮屏后投递只出横幅。改为**灭屏瞬间投递**全屏意图(鸿蒙只在"锁屏+灭屏"投递时才直接拉页):LockScreenActivity 悄悄盖在锁屏底下、屏幕保持熄灭(去掉 turnScreenOn 防止自动亮屏耗电),用户按电源键亮屏直接看到倒计时,全程无横幅
|
||||||
|
- TimerService:SCREEN_OFF → 灭屏投递;SCREEN_ON → 只补结算 + 清抽屉触发通知;页面未拉起时保留"服务直启 + 横幅通知"双兜底;计时停止时自动清触发通知
|
||||||
|
- LockScreenActivity:沉浸式全屏(IMMERSIVE_STICKY + LAYOUT_NO_LIMITS),顶部时间/信号/电池彻底遮掉;onWindowFocusChanged 重套沉浸式;监听 USER_PRESENT 解锁即退出;新增 showing 静态标记供服务判断页面是否已在锁屏上
|
||||||
|
- 横屏专属排版:新增 layout-land/activity_lock_screen.xml 左右分栏——左侧大号倒计时(120sp)+ 任务名,细竖线分隔,右侧信息栏纵向排日期/时钟/状态;清单去掉 configChanges 使旋转时重建切换布局,launchMode=singleTask 防重复实例
|
||||||
|
- 版本 1.0 → 1.1(versionCode 35)
|
||||||
|
|
||||||
|
## 2026-11-29 · 华为锁屏权限引导:设置页新增「锁屏显示权限」入口,一键跳应用启动管理(v1.0)
|
||||||
|
|
||||||
|
- 根因:鸿蒙/EMUI 默认拦截"后台弹出界面",前台服务直接 startActivity 被**静默**拦截(runCatching 不报错),只剩全屏意图通知——亮屏后投递只显示横幅,这就是"还是弹出通知"的真正原因。该权限无公开 API 可查询/授予,只能引导手动开启
|
||||||
|
- 设置页「提醒」区「锁屏全屏倒计时」开关下方新增「锁屏显示权限 · 去开启」入口:弹窗说明开启路径,点「去设置」直达华为手机管家应用启动管理页,失败退回系统应用详情页
|
||||||
|
- 新增 util/HuaweiPerms.kt;版本号规则调整为十进制进位:0.9 → 1.0,本次 0.17 → 1.0(versionCode 34)
|
||||||
|
|
||||||
## 2026-11-29 · 华为锁屏权限引导:设置页新增「锁屏显示权限」入口,一键跳应用启动管理(v1.0)
|
## 2026-11-29 · 华为锁屏权限引导:设置页新增「锁屏显示权限」入口,一键跳应用启动管理(v1.0)
|
||||||
|
|
||||||
|
|||||||
@@ -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" />
|
||||||
@@ -44,13 +46,12 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.lockscreen.LockScreenActivity"
|
android:name=".ui.lockscreen.LockScreenActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
android:launchMode="singleTask"
|
||||||
android:showWhenLocked="true"
|
android:showWhenLocked="true"
|
||||||
android:taskAffinity=""
|
android:taskAffinity=""
|
||||||
android:theme="@style/LockScreenTheme"
|
android:theme="@style/LockScreenTheme" />
|
||||||
android:turnScreenOn="true" />
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".service.TimerService"
|
android:name=".service.TimerService"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ object Store {
|
|||||||
const val INBOX_ID = 1L
|
const val INBOX_ID = 1L
|
||||||
|
|
||||||
private const val DB_NAME = "focusbox.db"
|
private const val DB_NAME = "focusbox.db"
|
||||||
private const val DB_VERSION = 6
|
private const val DB_VERSION = 7
|
||||||
|
|
||||||
private lateinit var helper: Helper
|
private lateinit var helper: Helper
|
||||||
|
|
||||||
@@ -46,6 +46,8 @@ object Store {
|
|||||||
color INTEGER NOT NULL,
|
color INTEGER NOT NULL,
|
||||||
archived INTEGER NOT NULL DEFAULT 0,
|
archived INTEGER NOT NULL DEFAULT 0,
|
||||||
sort INTEGER NOT NULL DEFAULT 0,
|
sort INTEGER NOT NULL DEFAULT 0,
|
||||||
|
sort_index INTEGER NOT NULL DEFAULT 0,
|
||||||
|
pinned_at INTEGER NOT NULL DEFAULT 0,
|
||||||
created_at INTEGER NOT NULL
|
created_at INTEGER NOT NULL
|
||||||
)
|
)
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
@@ -125,6 +127,11 @@ object Store {
|
|||||||
if (oldVersion < 6) {
|
if (oldVersion < 6) {
|
||||||
db.execSQL("ALTER TABLE tasks ADD COLUMN urgency INTEGER NOT NULL DEFAULT 1")
|
db.execSQL("ALTER TABLE tasks ADD COLUMN urgency INTEGER NOT NULL DEFAULT 1")
|
||||||
}
|
}
|
||||||
|
// v6 → v7:项目排序模式——序号(非置顶按序号升序)+ 置顶时间(置顶排最前,越近越靠前)
|
||||||
|
if (oldVersion < 7) {
|
||||||
|
db.execSQL("ALTER TABLE projects ADD COLUMN sort_index INTEGER NOT NULL DEFAULT 0")
|
||||||
|
db.execSQL("ALTER TABLE projects ADD COLUMN pinned_at INTEGER NOT NULL DEFAULT 0")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,14 +139,17 @@ object Store {
|
|||||||
|
|
||||||
fun projects(includeArchived: Boolean = false): List<Project> {
|
fun projects(includeArchived: Boolean = false): List<Project> {
|
||||||
val sql = """
|
val sql = """
|
||||||
SELECT p._id, p.name, p.color, p.archived, p.sort,
|
SELECT p._id, p.name, p.color, p.archived, p.sort, p.sort_index, p.pinned_at,
|
||||||
(SELECT COUNT(*) FROM tasks t WHERE t.project_id = p._id AND t.done = 0) AS open_tasks,
|
(SELECT COUNT(*) FROM tasks t WHERE t.project_id = p._id AND t.done = 0) AS open_tasks,
|
||||||
(SELECT COUNT(*) FROM tasks t WHERE t.project_id = p._id AND t.done = 1) AS done_tasks,
|
(SELECT COUNT(*) FROM tasks t WHERE t.project_id = p._id AND t.done = 1) AS done_tasks,
|
||||||
(SELECT IFNULL(SUM(s.seconds), 0) FROM sessions s WHERE s.project_id = p._id) AS focus_sec,
|
(SELECT IFNULL(SUM(s.seconds), 0) FROM sessions s WHERE s.project_id = p._id) AS focus_sec,
|
||||||
(SELECT COUNT(*) FROM sessions s WHERE s.project_id = p._id AND s.completed = 1) AS pomos
|
(SELECT COUNT(*) FROM sessions s WHERE s.project_id = p._id AND s.completed = 1) AS pomos
|
||||||
FROM projects p
|
FROM projects p
|
||||||
WHERE p.archived = 0 OR ${if (includeArchived) 1 else 0} = 1
|
WHERE p.archived = 0 OR ${if (includeArchived) 1 else 0} = 1
|
||||||
ORDER BY p.archived ASC, p.sort ASC, p._id ASC
|
ORDER BY p.archived ASC,
|
||||||
|
CASE WHEN p.pinned_at > 0 THEN 1 ELSE 0 END DESC,
|
||||||
|
CASE WHEN p.pinned_at > 0 THEN p.pinned_at ELSE 0 END DESC,
|
||||||
|
p.sort_index ASC, p.sort ASC, p._id ASC
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
val list = ArrayList<Project>()
|
val list = ArrayList<Project>()
|
||||||
db.rawQuery(sql, null).use { c ->
|
db.rawQuery(sql, null).use { c ->
|
||||||
@@ -151,10 +161,12 @@ object Store {
|
|||||||
color = c.getInt(2),
|
color = c.getInt(2),
|
||||||
archived = c.getInt(3) == 1,
|
archived = c.getInt(3) == 1,
|
||||||
sort = c.getInt(4),
|
sort = c.getInt(4),
|
||||||
openTasks = c.getInt(5),
|
sortIndex = c.getInt(5),
|
||||||
doneTasks = c.getInt(6),
|
pinnedAt = c.getLong(6),
|
||||||
focusSeconds = c.getInt(7),
|
openTasks = c.getInt(7),
|
||||||
pomodoros = c.getInt(8),
|
doneTasks = c.getInt(8),
|
||||||
|
focusSeconds = c.getInt(9),
|
||||||
|
pomodoros = c.getInt(10),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -164,22 +176,34 @@ object Store {
|
|||||||
|
|
||||||
fun project(id: Long): Project? = projects(true).firstOrNull { it.id == id }
|
fun project(id: Long): Project? = projects(true).firstOrNull { it.id == id }
|
||||||
|
|
||||||
fun addProject(name: String, color: Int): Long {
|
fun addProject(name: String, color: Int, sortIndex: Int = 0, pinned: Boolean = false): Long {
|
||||||
|
val now = System.currentTimeMillis()
|
||||||
val cv = ContentValues().apply {
|
val cv = ContentValues().apply {
|
||||||
put("name", name)
|
put("name", name)
|
||||||
put("color", color)
|
put("color", color)
|
||||||
put("archived", 0)
|
put("archived", 0)
|
||||||
put("sort", System.currentTimeMillis() / 1000)
|
put("sort", now / 1000)
|
||||||
put("created_at", System.currentTimeMillis())
|
put("sort_index", sortIndex)
|
||||||
|
put("pinned_at", if (pinned) now else 0L)
|
||||||
|
put("created_at", now)
|
||||||
}
|
}
|
||||||
return db.insert("projects", null, cv)
|
return db.insert("projects", null, cv)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateProject(id: Long, name: String, color: Int, archived: Boolean) {
|
/**
|
||||||
|
* pinnedAt 语义:pinned=true 且原值 0 → 取传入值(新建置顶时由调用方给 now);
|
||||||
|
* 已置顶保持置顶 → 保留原置顶时间(重复保存不刷新排序);取消置顶 → 归 0。
|
||||||
|
*/
|
||||||
|
fun updateProject(
|
||||||
|
id: Long, name: String, color: Int, archived: Boolean,
|
||||||
|
sortIndex: Int = 0, pinned: Boolean = false, pinnedAt: Long = 0,
|
||||||
|
) {
|
||||||
val cv = ContentValues().apply {
|
val cv = ContentValues().apply {
|
||||||
put("name", name)
|
put("name", name)
|
||||||
put("color", color)
|
put("color", color)
|
||||||
put("archived", if (archived) 1 else 0)
|
put("archived", if (archived) 1 else 0)
|
||||||
|
put("sort_index", sortIndex)
|
||||||
|
put("pinned_at", if (pinned) pinnedAt else 0L)
|
||||||
}
|
}
|
||||||
db.update("projects", cv, "_id = ?", arrayOf(id.toString()))
|
db.update("projects", cv, "_id = ?", arrayOf(id.toString()))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ data class Project(
|
|||||||
val doneTasks: Int,
|
val doneTasks: Int,
|
||||||
val focusSeconds: Int,
|
val focusSeconds: Int,
|
||||||
val pomodoros: Int,
|
val pomodoros: Int,
|
||||||
|
/** 排序序号:非置顶项目按它升序排,数字越小越靠前 */
|
||||||
|
val sortIndex: Int = 0,
|
||||||
|
/** 置顶时间戳:0 未置顶;置顶项目排最前,多个置顶按它倒序(越近越靠前) */
|
||||||
|
val pinnedAt: Long = 0,
|
||||||
) {
|
) {
|
||||||
val totalTasks: Int get() = openTasks + doneTasks
|
val totalTasks: Int get() = openTasks + doneTasks
|
||||||
val progress: Float get() = if (totalTasks == 0) 0f else doneTasks.toFloat() / totalTasks
|
val progress: Float get() = if (totalTasks == 0) 0f else doneTasks.toFloat() / totalTasks
|
||||||
|
|||||||
166
src/main/java/com/focusbox/app/service/LockOverlay.kt
Normal file
166
src/main/java/com/focusbox/app/service/LockOverlay.kt
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
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)
|
||||||
|
|
||||||
|
syncDivider(view)
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 横屏排版里的分割线只分割两块大时间:高度直接由 paint.fontMetrics 算出
|
||||||
|
* (includeFontPadding=false 时 TextView 高度就是 ascent..descent 跨度),
|
||||||
|
* 不依赖布局完成时机——上一版 View.post 在悬浮窗链路上时序不稳导致线消失。
|
||||||
|
* 竖屏布局没有这个控件,查找结果为 null 直接跳过。
|
||||||
|
*/
|
||||||
|
private fun syncDivider(view: View) {
|
||||||
|
val divider = view.findViewById<View>(R.id.lockDivider) ?: return
|
||||||
|
val countdown = view.findViewById<TextView>(R.id.tvLockCountdown) ?: return
|
||||||
|
val fm = countdown.paint.fontMetrics
|
||||||
|
val h = (fm.descent - fm.ascent).toInt()
|
||||||
|
if (h > 0 && divider.layoutParams != null && divider.layoutParams.height != h) {
|
||||||
|
divider.layoutParams.height = h
|
||||||
|
divider.requestLayout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Calendar 的 DAY_OF_WEEK(周日=1)转成 weekdayShort 的下标(周一=0 … 周日=6) */
|
||||||
|
private fun weekdayIndex(cal: Calendar): Int = (cal.get(Calendar.DAY_OF_WEEK) + 5) % 7
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import android.os.IBinder
|
|||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import com.focusbox.app.ui.lockscreen.LockScreenActivity
|
||||||
import com.focusbox.app.util.Prefs
|
import com.focusbox.app.util.Prefs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,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,
|
||||||
@@ -70,42 +73,95 @@ 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() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
Intent.ACTION_SCREEN_ON -> showLockPeek()
|
Intent.ACTION_SCREEN_ON -> onScreenOn()
|
||||||
Intent.ACTION_SCREEN_OFF -> Notif.cancelFullscreen(context)
|
Intent.ACTION_SCREEN_OFF -> onScreenOff()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showLockPeek() {
|
private val unlockReceiver = object : BroadcastReceiver() {
|
||||||
// 先补结算:EMUI 冻结进程后到点闹钟可能被推迟,用户按电源键亮屏
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
// 这一瞬进程已解冻,正好把过期的倒计时立刻结算掉,
|
if (intent.action == Intent.ACTION_USER_PRESENT) {
|
||||||
// 通知/锁屏卡片就不会再滚负数
|
LockOverlay.hide()
|
||||||
TimerCore.tick()
|
Notif.cancelFullscreen(this@TimerService)
|
||||||
if (!Prefs.lockFullscreen) return
|
}
|
||||||
if (!TimerCore.running) return
|
|
||||||
val km = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
|
||||||
// 只有真在锁屏界面才拉全屏页;用户正在用手机时不打扰
|
|
||||||
if (!km.inKeyguardRestrictedInputMode()) return
|
|
||||||
// 鸿蒙上全屏意图只在"锁屏且灭屏时投递"才会直接拉起 Activity,
|
|
||||||
// 亮屏后投递只会出横幅通知——所以直接从服务启动页面(鸿蒙允许
|
|
||||||
// 前台服务拉起自己的 Activity),全屏意图通知保留作兜底
|
|
||||||
runCatching {
|
|
||||||
startActivity(
|
|
||||||
Intent(this, com.focusbox.app.ui.lockscreen.LockScreenActivity::class.java)
|
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Notif.updateFullscreen(this)
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 悬浮窗显隐的总开关:锁屏中 + 计时未清零 + 开关打开 + 有悬浮窗权限。
|
||||||
|
* 显示成功时顺手清掉抽屉里的全屏意图触发通知(不再需要)。
|
||||||
|
*/
|
||||||
|
private fun syncLockOverlay() {
|
||||||
|
val km = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||||
|
val want = Prefs.lockFullscreen
|
||||||
|
&& 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() {
|
||||||
|
TimerCore.tick()
|
||||||
|
syncLockOverlay()
|
||||||
|
// 悬浮窗已盖住锁屏时,仍尝试用沉浸式锁屏页接管——
|
||||||
|
// Activity 有主题级全屏(状态栏彻底遮掉)+ 横竖屏专属排版,
|
||||||
|
// 直启成功则显示效果更完整;被鸿蒙拦截也无损失,悬浮窗继续顶着
|
||||||
|
if (Prefs.lockFullscreen && TimerCore.running) {
|
||||||
|
val km = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||||
|
if (km.isKeyguardLocked()) {
|
||||||
|
runCatching {
|
||||||
|
startActivity(
|
||||||
|
Intent(this, LockScreenActivity::class.java)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
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)
|
||||||
// 暂停/结束时同步停掉 1 秒轮询,别让 Handler 空转
|
// 计时结束/暂停时清掉锁屏触发通知,抽屉里不留垃圾
|
||||||
|
if (!TimerCore.running) Notif.cancelFullscreen(this)
|
||||||
|
syncLockOverlay()
|
||||||
syncTicker()
|
syncTicker()
|
||||||
syncWakeLock()
|
syncWakeLock()
|
||||||
}
|
}
|
||||||
@@ -217,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()
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
package com.focusbox.app.ui.lockscreen
|
package com.focusbox.app.ui.lockscreen
|
||||||
|
|
||||||
import android.app.KeyguardManager
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.text.format.DateFormat
|
import android.text.format.DateFormat
|
||||||
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
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.service.Notif
|
||||||
import com.focusbox.app.service.TimerCore
|
import com.focusbox.app.service.TimerCore
|
||||||
import com.focusbox.app.util.Dates
|
import com.focusbox.app.util.Dates
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
@@ -20,21 +26,31 @@ import java.util.Locale
|
|||||||
/**
|
/**
|
||||||
* 锁屏全屏倒计时页。
|
* 锁屏全屏倒计时页。
|
||||||
*
|
*
|
||||||
* 触发链路:计时中按电源键亮屏 → TimerService 收到 SCREEN_ON →
|
* 触发链路:计时中用户锁屏(灭屏)→ TimerService 灭屏瞬间发全屏意图通知 →
|
||||||
* 检查处于锁屏后发一条全屏意图通知 → 系统把本页直接盖在锁屏上展示。
|
* 鸿蒙直接把本页盖在锁屏上(屏幕保持熄灭,本页不设 turnScreenOn)→
|
||||||
|
* 用户按电源键亮屏即见倒计时,全程不出通知横幅。
|
||||||
*
|
*
|
||||||
* 交互极简:黑底上只有日期、时钟、大号倒计时和任务名,
|
* 交互极简:黑底上只有日期、时钟、大号倒计时和任务名,
|
||||||
* 点按任意处退出;倒计时本身在前台服务里走,退出/熄屏都不受影响,
|
* 点按任意处退出、解锁时自动退出;倒计时本身在前台服务里走,
|
||||||
* 计时结束后本页在下一次刷新时自动关闭。
|
* 退出/熄屏都不受影响,计时结束后本页在下一次刷新时自动关闭。
|
||||||
|
*
|
||||||
|
* 沉浸式:STATUS_BAR_HIDDEN + LAYOUT_NO_LIMITS 把顶部的时间/信号/电池
|
||||||
|
* 一起遮掉,整块屏幕只有页面内容。
|
||||||
*/
|
*/
|
||||||
class LockScreenActivity : AppCompatActivity() {
|
class LockScreenActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
/** 服务用来判断页面是否已盖在锁屏上(避免重复拉起/多报通知) */
|
||||||
|
@Volatile
|
||||||
|
var showing: Boolean = false
|
||||||
|
private set
|
||||||
|
}
|
||||||
|
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
|
||||||
private lateinit var tvDate: TextView
|
private lateinit var tvDate: TextView
|
||||||
private lateinit var tvClock: TextView
|
private lateinit var tvClock: TextView
|
||||||
private lateinit var tvCountdown: TextView
|
private lateinit var tvCountdown: TextView
|
||||||
private lateinit var tvMode: TextView
|
|
||||||
private lateinit var tvTask: TextView
|
private lateinit var tvTask: TextView
|
||||||
|
|
||||||
private val clockFmt = SimpleDateFormat("HH:mm", Locale.getDefault())
|
private val clockFmt = SimpleDateFormat("HH:mm", Locale.getDefault())
|
||||||
@@ -46,40 +62,87 @@ class LockScreenActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 用户解锁(输密码/指纹进系统)后页面没有存在意义,立即退出 */
|
||||||
|
private val unlockReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
if (intent.action == Intent.ACTION_USER_PRESENT) finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
// 盖在锁屏上显示(API 27+ 用官方方法,清单里的 showWhenLocked/turnScreenOn 双保险)
|
// 盖在锁屏上显示(API 27+ 用官方方法,清单里的 showWhenLocked 双保险)。
|
||||||
|
// 注意不能开 turnScreenOn:灭屏投递拉起本页时屏幕要保持熄灭,
|
||||||
|
// 等用户按电源键才亮,否则每次锁屏都会自动亮屏耗电
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||||
setShowWhenLocked(true)
|
setShowWhenLocked(true)
|
||||||
setTurnScreenOn(true)
|
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
window.addFlags(
|
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
|
||||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
|
||||||
or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
setContentView(R.layout.activity_lock_screen)
|
setContentView(R.layout.activity_lock_screen)
|
||||||
|
|
||||||
tvDate = findViewById(R.id.tvLockDate)
|
tvDate = findViewById(R.id.tvLockDate)
|
||||||
tvClock = findViewById(R.id.tvLockClock)
|
tvClock = findViewById(R.id.tvLockClock)
|
||||||
tvCountdown = findViewById(R.id.tvLockCountdown)
|
tvCountdown = findViewById(R.id.tvLockCountdown)
|
||||||
tvMode = findViewById(R.id.tvLockMode)
|
|
||||||
tvTask = findViewById(R.id.tvLockTask)
|
tvTask = findViewById(R.id.tvLockTask)
|
||||||
|
|
||||||
findViewById<android.view.View>(R.id.lockRoot).setOnClickListener { finish() }
|
findViewById<View>(R.id.lockRoot).setOnClickListener { finish() }
|
||||||
|
|
||||||
|
applyImmersive()
|
||||||
|
|
||||||
|
ContextCompat.registerReceiver(
|
||||||
|
this,
|
||||||
|
unlockReceiver,
|
||||||
|
IntentFilter(Intent.ACTION_USER_PRESENT),
|
||||||
|
ContextCompat.RECEIVER_NOT_EXPORTED,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
|
showing = true
|
||||||
|
// 页面已经实际盖到锁屏上了,抽屉里那条触发通知清掉
|
||||||
|
Notif.cancelFullscreen(this)
|
||||||
|
applyImmersive()
|
||||||
handler.post(tick)
|
handler.post(tick)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
showing = false
|
||||||
handler.removeCallbacks(tick)
|
handler.removeCallbacks(tick)
|
||||||
super.onStop()
|
super.onStop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
runCatching { unregisterReceiver(unlockReceiver) }
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 沉浸式全屏:状态栏/导航栏全隐藏,且布局延伸到状态栏底下(时间信号电池彻底不见) */
|
||||||
|
private fun applyImmersive() {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
window.setFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
||||||
|
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
||||||
|
)
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
window.decorView.systemUiVisibility = (
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
|
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
|
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||||
|
or View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
|
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 从别的窗口/通知横幅抢回焦点后,沉浸式标记会被系统清掉,重新套一遍 */
|
||||||
|
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||||
|
super.onWindowFocusChanged(hasFocus)
|
||||||
|
if (hasFocus) applyImmersive()
|
||||||
|
}
|
||||||
|
|
||||||
private fun render() {
|
private fun render() {
|
||||||
val now = TimerCore.displayNow()
|
val now = TimerCore.displayNow()
|
||||||
// 计时已结束且没有剩余读数:页面使命完成,自动关闭
|
// 计时已结束且没有剩余读数:页面使命完成,自动关闭
|
||||||
@@ -93,14 +156,29 @@ 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)
|
||||||
|
|
||||||
tvMode.text = getString(
|
syncDivider()
|
||||||
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.post 等布局完成后再取 height,实测在悬浮窗/锁屏链路上
|
||||||
|
* 时机不稳导致分割线整条消失;这里改为直接由 paint.fontMetrics 算出
|
||||||
|
* (includeFontPadding=false 时 TextView 高度就是 ascent..descent 跨度),
|
||||||
|
* 零时序依赖、立即生效。竖屏布局没有这个控件,查找结果为 null 直接跳过。
|
||||||
|
*/
|
||||||
|
private fun syncDivider() {
|
||||||
|
val divider = findViewById<View>(R.id.lockDivider) ?: return
|
||||||
|
val fm = tvCountdown.paint.fontMetrics
|
||||||
|
val h = (fm.descent - fm.ascent).toInt()
|
||||||
|
if (h > 0 && divider.layoutParams != null && divider.layoutParams.height != h) {
|
||||||
|
divider.layoutParams.height = h
|
||||||
|
divider.requestLayout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Calendar 的 DAY_OF_WEEK(周日=1)转成 weekdayShort 的下标(周一=0 … 周日=6) */
|
/** Calendar 的 DAY_OF_WEEK(周日=1)转成 weekdayShort 的下标(周一=0 … 周日=6) */
|
||||||
private fun weekdayIndex(cal: Calendar): Int = (cal.get(Calendar.DAY_OF_WEEK) + 5) % 7
|
private fun weekdayIndex(cal: Calendar): Int = (cal.get(Calendar.DAY_OF_WEEK) + 5) % 7
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ class ProjectSheet(
|
|||||||
|
|
||||||
private val root = LayoutInflater.from(context).inflate(R.layout.sheet_project, null)
|
private val root = LayoutInflater.from(context).inflate(R.layout.sheet_project, null)
|
||||||
private val etName: EditText = root.findViewById(R.id.etName)
|
private val etName: EditText = root.findViewById(R.id.etName)
|
||||||
|
private val etSortIndex: EditText = root.findViewById(R.id.etSortIndex)
|
||||||
|
private val swPinned: androidx.appcompat.widget.SwitchCompat = root.findViewById(R.id.swPinned)
|
||||||
private val colorRow: LinearLayout = root.findViewById(R.id.colorRow)
|
private val colorRow: LinearLayout = root.findViewById(R.id.colorRow)
|
||||||
|
|
||||||
private var color: Int = existing?.color ?: Palette.colorAt(0)
|
private var color: Int = existing?.color ?: Palette.colorAt(0)
|
||||||
@@ -38,6 +40,11 @@ class ProjectSheet(
|
|||||||
if (existing == null) R.string.add_project else R.string.edit
|
if (existing == null) R.string.add_project else R.string.edit
|
||||||
)
|
)
|
||||||
etName.setText(existing?.name ?: "")
|
etName.setText(existing?.name ?: "")
|
||||||
|
// 编辑已有序号才回填;未设置过序号显示空,保存时按 0 处理(同级按创建先后排)
|
||||||
|
if (existing != null && existing.sortIndex > 0) {
|
||||||
|
etSortIndex.setText(existing.sortIndex.toString())
|
||||||
|
}
|
||||||
|
swPinned.isChecked = (existing?.pinnedAt ?: 0L) > 0L
|
||||||
renderColors()
|
renderColors()
|
||||||
|
|
||||||
val btnDelete = root.findViewById<TextView>(R.id.btnDelete)
|
val btnDelete = root.findViewById<TextView>(R.id.btnDelete)
|
||||||
@@ -62,10 +69,20 @@ class ProjectSheet(
|
|||||||
etName.error = context.getString(R.string.project_name_hint)
|
etName.error = context.getString(R.string.project_name_hint)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
val sortIndex = etSortIndex.text.toString().trim().toIntOrNull() ?: 0
|
||||||
|
val pinned = swPinned.isChecked
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
Store.addProject(name, color)
|
// 新建置顶:置顶时间取当下,排进置顶组
|
||||||
|
Store.addProject(name, color, sortIndex, pinned)
|
||||||
} else {
|
} else {
|
||||||
Store.updateProject(existing.id, name, color, existing.archived)
|
// 已置顶且保持置顶 → 保留原置顶时间(重复保存不刷新排序);
|
||||||
|
// 新勾置顶 → 以保存这一刻为置顶时间;取消置顶 → Store 里归 0
|
||||||
|
val pinnedAt = when {
|
||||||
|
!pinned -> 0L
|
||||||
|
existing.pinnedAt > 0L -> existing.pinnedAt
|
||||||
|
else -> System.currentTimeMillis()
|
||||||
|
}
|
||||||
|
Store.updateProject(existing.id, name, color, existing.archived, sortIndex, pinned, pinnedAt)
|
||||||
}
|
}
|
||||||
onSaved()
|
onSaved()
|
||||||
dismiss()
|
dismiss()
|
||||||
|
|||||||
@@ -128,7 +128,11 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
|
|||||||
when {
|
when {
|
||||||
which == 0 -> ProjectSheet(requireContext(), p) { reload() }.show()
|
which == 0 -> ProjectSheet(requireContext(), p) { reload() }.show()
|
||||||
which == 1 && !isInbox -> {
|
which == 1 && !isInbox -> {
|
||||||
Store.updateProject(p.id, p.name, p.color, !p.archived)
|
// 归档/取消归档只切 archived,序号与置顶状态原样保留
|
||||||
|
Store.updateProject(
|
||||||
|
p.id, p.name, p.color, !p.archived,
|
||||||
|
p.sortIndex, p.pinnedAt > 0, p.pinnedAt,
|
||||||
|
)
|
||||||
reload()
|
reload()
|
||||||
}
|
}
|
||||||
which == 2 && !isInbox -> confirmDelete(p)
|
which == 2 && !isInbox -> confirmDelete(p)
|
||||||
|
|||||||
@@ -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()
|
||||||
@@ -175,7 +187,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 +209,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 +251,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 +279,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 +341,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()
|
||||||
@@ -431,6 +539,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val VERSION = "1.0"
|
const val VERSION = "1.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,8 +205,6 @@ class PeriodDistributionCard @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
donut.centerText = Dates.durationBrief(raw.sumOf { it.seconds })
|
donut.centerText = Dates.durationBrief(raw.sumOf { it.seconds })
|
||||||
donut.centerCaption =
|
|
||||||
context.getString(if (byTask) R.string.task_share else R.string.total_focus)
|
|
||||||
|
|
||||||
tvPeriod.text = periodLabel(from, to)
|
tvPeriod.text = periodLabel(from, to)
|
||||||
applySegments()
|
applySegments()
|
||||||
|
|||||||
@@ -116,24 +116,26 @@ 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)
|
||||||
|
|
||||||
// 「随时」任务:标题后带品牌蓝上箭头表示置顶,列表里排在未完成最前面。
|
// 「随时」任务:标题后带品牌蓝圆圈上箭头表示置顶,列表里排在未完成最前面。
|
||||||
// ↑ 字形窄、两侧留白大,全角空格会显得左边距比五角星宽,
|
// 图标与重要度圆圈数字同规格(0.85 倍字号,圆圈里画向上箭头),
|
||||||
// 改用细空格(U+2009)让两侧间隙与星标一致。
|
// 圆圈与箭头同色(品牌蓝);前面的细空格(U+2009)保持与星标的间距一致。
|
||||||
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
|
if (task.repeatType == com.focusbox.app.model.Repeat.ANYTIME && !task.done) {
|
||||||
title.append("\u2009↑")
|
title.append("\u2009 ")
|
||||||
title.setSpan(
|
title.setSpan(
|
||||||
android.text.style.ForegroundColorSpan(ctx.col(R.color.brand)),
|
PinIconSpan(ctx.col(R.color.brand), tvTitle.textSize * 0.85f),
|
||||||
title.length - 2, title.length, 0
|
title.length - 1, title.length, 0,
|
||||||
)
|
)
|
||||||
title.setSpan(RelativeSizeSpan(0.85f), title.length - 2, title.length, 0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tvTitle.text = title
|
// 完成横线只画任务名本身(MidStrikeSpan 限定区间,且划线取文字墨迹
|
||||||
tvTitle.paintFlags = if (task.done) {
|
// 的垂直中点——系统 StrikethroughSpan 用整字面半高定位,数字/汉字
|
||||||
tvTitle.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
|
// 会让线显得偏下)。重要度/紧急度/置顶图标不跟着划线。
|
||||||
} else {
|
// 注意:span 必须在 tvTitle.text = title 之前挂好
|
||||||
tvTitle.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
|
if (task.done) {
|
||||||
|
title.setSpan(MidStrikeSpan(), 0, task.title.length, 0)
|
||||||
}
|
}
|
||||||
|
tvTitle.text = title
|
||||||
|
tvTitle.paintFlags = 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 +205,90 @@ class TaskAdapter(
|
|||||||
private const val TYPE_FOOTER = 1
|
private const val TYPE_FOOTER = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务名删除线:系统 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 置顶图标:圆圈内向上箭头。
|
||||||
|
* 自绘而不是用字体字形——常用字体里没有"圆圈+箭头"的组合字符,
|
||||||
|
* 画出来才能精确控制圆圈与箭头同色、且和重要度圆圈数字(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 图标高)
|
||||||
|
val ring = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
ring.color = iconColor
|
||||||
|
ring.style = Paint.Style.STROKE
|
||||||
|
ring.strokeWidth = s / 10f
|
||||||
|
ring.strokeCap = Paint.Cap.ROUND
|
||||||
|
canvas.drawCircle(cx, cy, s / 2f - ring.strokeWidth / 2f, ring)
|
||||||
|
|
||||||
|
// 箭头比圈线更细(约 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,9 +62,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
|
||||||
|
|||||||
@@ -43,13 +43,6 @@ class LabelDonutView @JvmOverloads constructor(
|
|||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 环中心的小字(总专注 / 任务占比) */
|
|
||||||
var centerCaption: String = ""
|
|
||||||
set(value) {
|
|
||||||
field = value
|
|
||||||
invalidate()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 最多画几条引线标注,多出来的合并成「其他」,避免标注挤成一团 */
|
/** 最多画几条引线标注,多出来的合并成「其他」,避免标注挤成一团 */
|
||||||
var maxLabels: Int = 6
|
var maxLabels: Int = 6
|
||||||
|
|
||||||
@@ -76,13 +69,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 }
|
||||||
@@ -188,13 +175,15 @@ class LabelDonutView @JvmOverloads constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环中心只画一行:累计时间(或空态提示)。
|
||||||
|
* 之前按 cy + 2dp 硬偏移定位,字面重心偏下;改为按字体度量
|
||||||
|
* 把墨迹垂直中心落在圆心,并删除原来的小字说明行。
|
||||||
|
*/
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
79
src/main/res/layout-land/activity_lock_screen.xml
Normal file
79
src/main/res/layout-land/activity_lock_screen.xml
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
锁屏全屏倒计时·横屏专属排版(区别于竖屏的纯纵向堆叠):
|
||||||
|
左右对称分栏 —— 左侧倒计时(大)+ 任务名,右侧时钟(大)+ 日期星期,
|
||||||
|
两侧主字号统一 96sp,视觉左右对应;无「工作中/休息中」提示。
|
||||||
|
-->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/lockRoot"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@android:color/black"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<!-- 左:倒计时 + 任务名 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvLockCountdown"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:textSize="130sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvLockTask"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxWidth="320dp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="#99FFFFFF"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- 中:细分隔线(只分割两块大时间,高度运行时对齐倒计时文字的实际高度) -->
|
||||||
|
<View
|
||||||
|
android:id="@+id/lockDivider"
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="180dp"
|
||||||
|
android:background="#26FFFFFF" />
|
||||||
|
|
||||||
|
<!-- 右:时钟(大)+ 日期星期在时钟下面 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvLockClock"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:textSize="130sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvLockDate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:textColor="#99FFFFFF"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -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"
|
||||||
|
|||||||
@@ -45,6 +45,45 @@
|
|||||||
android:inputType="text"
|
android:inputType="text"
|
||||||
android:maxLines="1" />
|
android:maxLines="1" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="14dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etSortIndex"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/bg_field"
|
||||||
|
android:paddingStart="14dp"
|
||||||
|
android:paddingEnd="14dp"
|
||||||
|
android:paddingTop="13dp"
|
||||||
|
android:paddingBottom="13dp"
|
||||||
|
android:hint="@string/sort_index_hint"
|
||||||
|
android:textColor="@color/text"
|
||||||
|
android:textColorHint="@color/text_tertiary"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLines="1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:text="@string/project_pinned"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textColor="@color/text" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swPinned"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
@@ -190,7 +190,12 @@
|
|||||||
<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="sort_index_hint">序号,越小越靠前</string>
|
||||||
|
<string name="project_pinned">置顶</string>
|
||||||
<string name="lock_perm_hint">华为/鸿蒙默认拦截后台拉起页面,锁屏倒计时需要手动开启。路径:设置 → 应用 → 应用启动管理 → 时间简史 → 关闭「自动管理」,并允许「后台弹出界面」和「锁屏显示」。点「去设置」可直接打开对应页面。</string>
|
<string name="lock_perm_hint">华为/鸿蒙默认拦截后台拉起页面,锁屏倒计时需要手动开启。路径:设置 → 应用 → 应用启动管理 → 时间简史 → 关闭「自动管理」,并允许「后台弹出界面」和「锁屏显示」。点「去设置」可直接打开对应页面。</string>
|
||||||
<string name="lock_mode_focus">工作中</string>
|
<string name="lock_mode_focus">工作中</string>
|
||||||
<string name="lock_mode_break">休息中</string>
|
<string name="lock_mode_break">休息中</string>
|
||||||
@@ -217,7 +222,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>
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
<!-- 锁屏全屏倒计时页:纯黑底、白色字,不随深浅色主题切换 -->
|
<!-- 锁屏全屏倒计时页:纯黑底、白色字,不随深浅色主题切换 -->
|
||||||
<style name="LockScreenTheme" parent="Theme.AppCompat.NoActionBar">
|
<style name="LockScreenTheme" parent="Theme.AppCompat.NoActionBar">
|
||||||
<item name="android:windowBackground">@android:color/black</item>
|
<item name="android:windowBackground">@android:color/black</item>
|
||||||
|
<!-- 主题级全屏:横竖屏都把状态栏(时间/信号/电池)彻底拿掉,横屏同样生效 -->
|
||||||
|
<item name="android:windowFullscreen">true</item>
|
||||||
<item name="android:statusBarColor">@android:color/black</item>
|
<item name="android:statusBarColor">@android:color/black</item>
|
||||||
<item name="android:navigationBarColor">@android:color/black</item>
|
<item name="android:navigationBarColor">@android:color/black</item>
|
||||||
<item name="android:windowLightStatusBar">false</item>
|
<item name="android:windowLightStatusBar">false</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user