Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8cc773fef | ||
|
|
c0182de5e5 | ||
|
|
65dd5bfe91 | ||
|
|
fd674322a1 | ||
|
|
bc01e0ac67 |
35
CHANGELOG.md
35
CHANGELOG.md
@@ -1,8 +1,39 @@
|
||||
# 变更记录
|
||||
|
||||
## 2026-11-29 · 锁屏权限引导:设置页新增锁屏显示权限入口一键跳应用启动管理,版本 1.0
|
||||
## 2026-11-29 · 竖屏删「工作中」提示;横屏时间加大、下方文字统一规格并收紧间距(v1.3)
|
||||
|
||||
- 同步源码更新 3 个文件(新增/修改 3,删除 0)。
|
||||
- 竖屏锁屏页删除「工作中/休息中」字样(代码同步移除 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)
|
||||
|
||||
|
||||
@@ -44,13 +44,12 @@
|
||||
|
||||
<activity
|
||||
android:name=".ui.lockscreen.LockScreenActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTask"
|
||||
android:showWhenLocked="true"
|
||||
android:taskAffinity=""
|
||||
android:theme="@style/LockScreenTheme"
|
||||
android:turnScreenOn="true" />
|
||||
android:theme="@style/LockScreenTheme" />
|
||||
|
||||
<service
|
||||
android:name=".service.TimerService"
|
||||
|
||||
@@ -26,7 +26,7 @@ object Store {
|
||||
const val INBOX_ID = 1L
|
||||
|
||||
private const val DB_NAME = "focusbox.db"
|
||||
private const val DB_VERSION = 6
|
||||
private const val DB_VERSION = 7
|
||||
|
||||
private lateinit var helper: Helper
|
||||
|
||||
@@ -46,6 +46,8 @@ object Store {
|
||||
color INTEGER NOT NULL,
|
||||
archived 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
|
||||
)
|
||||
""".trimIndent()
|
||||
@@ -125,6 +127,11 @@ object Store {
|
||||
if (oldVersion < 6) {
|
||||
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> {
|
||||
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 = 1) AS done_tasks,
|
||||
(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
|
||||
FROM projects p
|
||||
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()
|
||||
val list = ArrayList<Project>()
|
||||
db.rawQuery(sql, null).use { c ->
|
||||
@@ -151,10 +161,12 @@ object Store {
|
||||
color = c.getInt(2),
|
||||
archived = c.getInt(3) == 1,
|
||||
sort = c.getInt(4),
|
||||
openTasks = c.getInt(5),
|
||||
doneTasks = c.getInt(6),
|
||||
focusSeconds = c.getInt(7),
|
||||
pomodoros = c.getInt(8),
|
||||
sortIndex = c.getInt(5),
|
||||
pinnedAt = c.getLong(6),
|
||||
openTasks = c.getInt(7),
|
||||
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 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 {
|
||||
put("name", name)
|
||||
put("color", color)
|
||||
put("archived", 0)
|
||||
put("sort", System.currentTimeMillis() / 1000)
|
||||
put("created_at", System.currentTimeMillis())
|
||||
put("sort", now / 1000)
|
||||
put("sort_index", sortIndex)
|
||||
put("pinned_at", if (pinned) now else 0L)
|
||||
put("created_at", now)
|
||||
}
|
||||
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 {
|
||||
put("name", name)
|
||||
put("color", color)
|
||||
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()))
|
||||
}
|
||||
|
||||
@@ -11,6 +11,10 @@ data class Project(
|
||||
val doneTasks: Int,
|
||||
val focusSeconds: Int,
|
||||
val pomodoros: Int,
|
||||
/** 排序序号:非置顶项目按它升序排,数字越小越靠前 */
|
||||
val sortIndex: Int = 0,
|
||||
/** 置顶时间戳:0 未置顶;置顶项目排最前,多个置顶按它倒序(越近越靠前) */
|
||||
val pinnedAt: Long = 0,
|
||||
) {
|
||||
val totalTasks: Int get() = openTasks + doneTasks
|
||||
val progress: Float get() = if (totalTasks == 0) 0f else doneTasks.toFloat() / totalTasks
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.os.IBinder
|
||||
import android.os.Looper
|
||||
import android.os.PowerManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.focusbox.app.ui.lockscreen.LockScreenActivity
|
||||
import com.focusbox.app.util.Prefs
|
||||
|
||||
/**
|
||||
@@ -75,37 +76,55 @@ class TimerService : Service() {
|
||||
private val screenReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
when (intent.action) {
|
||||
Intent.ACTION_SCREEN_ON -> showLockPeek()
|
||||
Intent.ACTION_SCREEN_OFF -> Notif.cancelFullscreen(context)
|
||||
Intent.ACTION_SCREEN_ON -> onScreenOn()
|
||||
Intent.ACTION_SCREEN_OFF -> onScreenOff()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showLockPeek() {
|
||||
// 先补结算:EMUI 冻结进程后到点闹钟可能被推迟,用户按电源键亮屏
|
||||
// 这一瞬进程已解冻,正好把过期的倒计时立刻结算掉,
|
||||
// 通知/锁屏卡片就不会再滚负数
|
||||
TimerCore.tick()
|
||||
if (!Prefs.lockFullscreen) return
|
||||
/**
|
||||
* 灭屏瞬间投递全屏意图通知——这是鸿蒙唯一会直接拉起 LockScreenActivity 的窗口。
|
||||
* 鸿蒙 4.0 的规则:全屏意图只在「锁屏 + 灭屏」时投递才直接把页面盖在锁屏上;
|
||||
* 亮屏后投递永远只出横幅;服务直接 startActivity 则被"后台弹出界面"策略静默拦截
|
||||
* (实测开了权限也一样)。所以改成灭屏时就投递:页面(turnScreenOn=false)
|
||||
* 悄悄盖在锁屏底下、屏幕保持熄灭,用户按电源键亮屏就直接看到倒计时,
|
||||
* 不会再出现任何通知横幅。
|
||||
*/
|
||||
private fun onScreenOff() {
|
||||
if (!Prefs.lockFullscreen || !TimerCore.running) return
|
||||
TimerCore.tick() // 灭屏一瞬先补结算,避免到点边界上拉出 00:00 的空页面
|
||||
if (!TimerCore.running) return
|
||||
val km = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
// 只有真在锁屏界面才拉全屏页;用户正在用手机时不打扰
|
||||
if (!km.inKeyguardRestrictedInputMode()) return
|
||||
// 鸿蒙上全屏意图只在"锁屏且灭屏时投递"才会直接拉起 Activity,
|
||||
// 亮屏后投递只会出横幅通知——所以直接从服务启动页面(鸿蒙允许
|
||||
// 前台服务拉起自己的 Activity),全屏意图通知保留作兜底
|
||||
if (!km.isKeyguardLocked()) return
|
||||
Notif.updateFullscreen(this)
|
||||
}
|
||||
|
||||
/** 亮屏:先补结算(冻结进程的到点闹钟被推迟时,靠这一下止损,不再滚负数) */
|
||||
private fun onScreenOn() {
|
||||
TimerCore.tick()
|
||||
if (LockScreenActivity.showing) {
|
||||
// 页面已经盖在锁屏上(灭屏投递拉起的),抽屉里的触发通知清掉
|
||||
Notif.cancelFullscreen(this)
|
||||
} else if (Prefs.lockFullscreen && TimerCore.running) {
|
||||
val km = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
if (km.isKeyguardLocked()) {
|
||||
// 灭屏投递没拉起来(个别 ROM 拦全屏意图)的兜底:
|
||||
// 先试服务直启,再留一条全屏意图通知让用户点进同一页面
|
||||
runCatching {
|
||||
startActivity(
|
||||
Intent(this, com.focusbox.app.ui.lockscreen.LockScreenActivity::class.java)
|
||||
Intent(this, LockScreenActivity::class.java)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
)
|
||||
}
|
||||
Notif.updateFullscreen(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val onStateChanged: () -> Unit = {
|
||||
Notif.updateOngoing(this)
|
||||
// 暂停/结束时同步停掉 1 秒轮询,别让 Handler 空转
|
||||
// 计时结束/暂停时清掉锁屏触发通知,抽屉里不留垃圾
|
||||
if (!TimerCore.running) Notif.cancelFullscreen(this)
|
||||
syncTicker()
|
||||
syncWakeLock()
|
||||
}
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
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.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.text.format.DateFormat
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.focusbox.app.R
|
||||
import com.focusbox.app.data.Store
|
||||
import com.focusbox.app.service.Notif
|
||||
import com.focusbox.app.service.TimerCore
|
||||
import com.focusbox.app.util.Dates
|
||||
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() {
|
||||
|
||||
companion object {
|
||||
/** 服务用来判断页面是否已盖在锁屏上(避免重复拉起/多报通知) */
|
||||
@Volatile
|
||||
var showing: Boolean = false
|
||||
private set
|
||||
}
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
private lateinit var tvDate: TextView
|
||||
private lateinit var tvClock: TextView
|
||||
private lateinit var tvCountdown: TextView
|
||||
private lateinit var tvMode: TextView
|
||||
private lateinit var tvTask: TextView
|
||||
|
||||
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?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
// 盖在锁屏上显示(API 27+ 用官方方法,清单里的 showWhenLocked/turnScreenOn 双保险)
|
||||
// 盖在锁屏上显示(API 27+ 用官方方法,清单里的 showWhenLocked 双保险)。
|
||||
// 注意不能开 turnScreenOn:灭屏投递拉起本页时屏幕要保持熄灭,
|
||||
// 等用户按电源键才亮,否则每次锁屏都会自动亮屏耗电
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
setShowWhenLocked(true)
|
||||
setTurnScreenOn(true)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
window.addFlags(
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
||||
or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
)
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
|
||||
}
|
||||
setContentView(R.layout.activity_lock_screen)
|
||||
|
||||
tvDate = findViewById(R.id.tvLockDate)
|
||||
tvClock = findViewById(R.id.tvLockClock)
|
||||
tvCountdown = findViewById(R.id.tvLockCountdown)
|
||||
tvMode = findViewById(R.id.tvLockMode)
|
||||
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() {
|
||||
super.onStart()
|
||||
showing = true
|
||||
// 页面已经实际盖到锁屏上了,抽屉里那条触发通知清掉
|
||||
Notif.cancelFullscreen(this)
|
||||
applyImmersive()
|
||||
handler.post(tick)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
showing = false
|
||||
handler.removeCallbacks(tick)
|
||||
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() {
|
||||
val now = TimerCore.displayNow()
|
||||
// 计时已结束且没有剩余读数:页面使命完成,自动关闭
|
||||
@@ -93,10 +156,6 @@ class LockScreenActivity : AppCompatActivity() {
|
||||
tvClock.text = clockFmt.format(cal.time)
|
||||
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
|
||||
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 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 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
|
||||
)
|
||||
etName.setText(existing?.name ?: "")
|
||||
// 编辑已有序号才回填;未设置过序号显示空,保存时按 0 处理(同级按创建先后排)
|
||||
if (existing != null && existing.sortIndex > 0) {
|
||||
etSortIndex.setText(existing.sortIndex.toString())
|
||||
}
|
||||
swPinned.isChecked = (existing?.pinnedAt ?: 0L) > 0L
|
||||
renderColors()
|
||||
|
||||
val btnDelete = root.findViewById<TextView>(R.id.btnDelete)
|
||||
@@ -62,10 +69,20 @@ class ProjectSheet(
|
||||
etName.error = context.getString(R.string.project_name_hint)
|
||||
return@setOnClickListener
|
||||
}
|
||||
val sortIndex = etSortIndex.text.toString().trim().toIntOrNull() ?: 0
|
||||
val pinned = swPinned.isChecked
|
||||
if (existing == null) {
|
||||
Store.addProject(name, color)
|
||||
// 新建置顶:置顶时间取当下,排进置顶组
|
||||
Store.addProject(name, color, sortIndex, pinned)
|
||||
} 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()
|
||||
dismiss()
|
||||
|
||||
@@ -128,7 +128,11 @@ class ProjectsFragment : Fragment(R.layout.fragment_projects) {
|
||||
when {
|
||||
which == 0 -> ProjectSheet(requireContext(), p) { reload() }.show()
|
||||
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()
|
||||
}
|
||||
which == 2 && !isInbox -> confirmDelete(p)
|
||||
|
||||
@@ -431,6 +431,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "1.0"
|
||||
const val VERSION = "1.3"
|
||||
}
|
||||
}
|
||||
|
||||
78
src/main/res/layout-land/activity_lock_screen.xml
Normal file
78
src/main/res/layout-land/activity_lock_screen.xml
Normal file
@@ -0,0 +1,78 @@
|
||||
<?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: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: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
|
||||
android:id="@+id/tvLockTask"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -45,6 +45,45 @@
|
||||
android:inputType="text"
|
||||
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
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -191,6 +191,9 @@
|
||||
<string name="lock_perm_title">锁屏显示权限</string>
|
||||
<string name="lock_perm_value">去开启</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_mode_focus">工作中</string>
|
||||
<string name="lock_mode_break">休息中</string>
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
<!-- 锁屏全屏倒计时页:纯黑底、白色字,不随深浅色主题切换 -->
|
||||
<style name="LockScreenTheme" parent="Theme.AppCompat.NoActionBar">
|
||||
<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:navigationBarColor">@android:color/black</item>
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
|
||||
Reference in New Issue
Block a user