Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d355693be | ||
|
|
93faf6d21e | ||
|
|
a5cd605a5c | ||
|
|
05a3462c6e | ||
|
|
c8cc773fef | ||
|
|
c0182de5e5 | ||
|
|
65dd5bfe91 | ||
|
|
fd674322a1 |
34
CHANGELOG.md
34
CHANGELOG.md
@@ -1,5 +1,39 @@
|
|||||||
# 变更记录
|
# 变更记录
|
||||||
|
|
||||||
|
## 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
|
## 2026-11-29 · 锁屏倒计时改灭屏投递拉起不再出横幅;沉浸式遮状态栏;横屏专属排版;版本 1.1
|
||||||
|
|
||||||
- 同步源码更新 5 个文件(新增/修改 5,删除 0)。
|
- 同步源码更新 5 个文件(新增/修改 5,删除 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" />
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
147
src/main/java/com/focusbox/app/service/LockOverlay.kt
Normal file
147
src/main/java/com/focusbox/app/service/LockOverlay.kt
Normal 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
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (!LockOverlay.isShowing() && !LockScreenActivity.showing) {
|
||||||
|
// 悬浮窗和直启都失败:留全屏意图通知兜底(点进同一页面)
|
||||||
Notif.updateFullscreen(this)
|
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()
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ class LockScreenActivity : AppCompatActivity() {
|
|||||||
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())
|
||||||
@@ -86,11 +85,12 @@ class LockScreenActivity : AppCompatActivity() {
|
|||||||
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<View>(R.id.lockRoot).setOnClickListener { finish() }
|
findViewById<View>(R.id.lockRoot).setOnClickListener { finish() }
|
||||||
|
|
||||||
|
applyImmersive()
|
||||||
|
|
||||||
ContextCompat.registerReceiver(
|
ContextCompat.registerReceiver(
|
||||||
this,
|
this,
|
||||||
unlockReceiver,
|
unlockReceiver,
|
||||||
@@ -156,10 +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)
|
||||||
|
|
||||||
tvMode.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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,16 @@ 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 后台启动,悬浮窗不受限)
|
||||||
|
action(
|
||||||
|
getString(R.string.overlay_perm_title),
|
||||||
|
if (com.focusbox.app.service.LockOverlay.canShow(requireContext())) {
|
||||||
|
getString(R.string.perm_granted)
|
||||||
|
} else {
|
||||||
|
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() },
|
||||||
)
|
)
|
||||||
@@ -319,6 +328,20 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
|||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 悬浮窗权限:标准 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 +454,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val VERSION = "1.1"
|
const val VERSION = "1.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
锁屏全屏倒计时·横屏专属排版(区别于竖屏的纯纵向堆叠):
|
锁屏全屏倒计时·横屏专属排版(区别于竖屏的纯纵向堆叠):
|
||||||
左右分栏 —— 左侧主角是大号倒计时 + 任务名,细竖线分隔,
|
左右对称分栏 —— 左侧倒计时(大)+ 任务名,右侧时钟(大)+ 日期星期,
|
||||||
右侧信息栏纵向排日期/时钟/状态,重心靠左、信息靠右。
|
两侧主字号统一 96sp,视觉左右对应;无「工作中/休息中」提示。
|
||||||
-->
|
-->
|
||||||
<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"
|
||||||
@@ -14,11 +14,11 @@
|
|||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<!-- 左:倒计时 + 任务名(主角区) -->
|
<!-- 左:倒计时 + 任务名 -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1.2"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
@@ -28,19 +28,19 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:textColor="#FFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
android:textSize="120sp"
|
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="18dp"
|
android:layout_marginTop="10dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxWidth="360dp"
|
android:maxWidth="320dp"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="#CCFFFFFF"
|
android:textColor="#99FFFFFF"
|
||||||
android:textSize="17sp" />
|
android:textSize="15sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 中:细分隔线 -->
|
<!-- 中:细分隔线 -->
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
android:layout_height="180dp"
|
android:layout_height="180dp"
|
||||||
android:background="#26FFFFFF" />
|
android:background="#26FFFFFF" />
|
||||||
|
|
||||||
<!-- 右:信息栏(日期 / 时钟 / 状态) -->
|
<!-- 右:时钟(大)+ 日期星期在时钟下面 -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -57,32 +57,22 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvLockDate"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:letterSpacing="0.08"
|
|
||||||
android:textColor="#99FFFFFF"
|
|
||||||
android:textSize="15sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvLockClock"
|
android:id="@+id/tvLockClock"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:includeFontPadding="false"
|
android:includeFontPadding="false"
|
||||||
android:textColor="#CCFFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
android:textSize="64sp"
|
android:textSize="130sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvLockMode"
|
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="18dp"
|
android:layout_marginTop="10dp"
|
||||||
android:letterSpacing="0.2"
|
android:textColor="#99FFFFFF"
|
||||||
android:textColor="#66FFFFFF"
|
android:textSize="15sp" />
|
||||||
android:textSize="13sp" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</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>
|
||||||
|
|||||||
@@ -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