P30 适配:锁屏页服务直启/去提示/工作中/横竖屏;到点结算加 setAlarmClock 双保险与亮屏补结算(v0.17)

This commit is contained in:
XIGE
2026-11-29 13:09:06 +08:00
parent c5f5233ca0
commit b315dfdd36
7 changed files with 35 additions and 13 deletions

View File

@@ -1,5 +1,9 @@
# 变更记录
## 2026-11-29 · P30 适配:锁屏页服务直启/去提示/工作中/横竖屏;到点结算加 setAlarmClock 双保险与亮屏补结算(v0.17)
- 同步源码更新 6 个文件(新增/修改 6,删除 0)。
## 2026-11-29 · 新增锁屏全屏倒计时:计时中锁屏亮屏即全屏显示日期/时钟/倒计时/任务(v0.16)
- 新增 LockScreenActivity:纯黑极简全屏页(日期+星期、时钟、96sp 大号倒计时、专注/休息状态、任务名),showWhenLocked + turnScreenOn 盖在锁屏上,点按任意处退出,计时结束后自动关闭

View File

@@ -44,9 +44,9 @@
<activity
android:name=".ui.lockscreen.LockScreenActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:excludeFromRecents="true"
android:exported="false"
android:screenOrientation="portrait"
android:showWhenLocked="true"
android:taskAffinity=""
android:theme="@style/LockScreenTheme"

View File

@@ -119,6 +119,21 @@ object TimerCore {
} else {
am.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, at, 60_000L, deadlinePI)
}
// setAlarmClock 双保险:EMUI/HarmonyOS 会把"冻结"应用的普通精确闹钟
// 推迟到应用解冻才投递(表现为通知滚负数、打开 APP 才结算),
// 但用户级闹钟(闹钟应用走的通道)有最高投递优先级,冻结也照响。
// tick 幂等(结算后 running=false 直接返回),两路同时触发无害。
runCatching {
val show = android.app.PendingIntent.getActivity(
ctx,
9,
android.content.Intent(ctx, com.focusbox.app.ui.MainActivity::class.java)
.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK),
android.app.PendingIntent.FLAG_UPDATE_CURRENT
or android.app.PendingIntent.FLAG_IMMUTABLE,
)
am.setAlarmClock(AlarmManager.AlarmClockInfo(at, show), deadlinePI)
}
}
}

View File

@@ -82,11 +82,24 @@ class TimerService : Service() {
}
private fun showLockPeek() {
// 先补结算:EMUI 冻结进程后到点闹钟可能被推迟,用户按电源键亮屏
// 这一瞬进程已解冻,正好把过期的倒计时立刻结算掉,
// 通知/锁屏卡片就不会再滚负数
TimerCore.tick()
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)
}

View File

@@ -374,6 +374,6 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
}
companion object {
const val VERSION = "0.16"
const val VERSION = "0.17"
}
}

View File

@@ -58,13 +58,4 @@
android:textColor="#CCFFFFFF"
android:textSize="17sp" />
<TextView
android:id="@+id/tvLockHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:text="@string/lock_hint"
android:textColor="#40FFFFFF"
android:textSize="12sp" />
</LinearLayout>

View File

@@ -188,9 +188,8 @@
<string name="vibrate">振动</string>
<string name="keep_screen_on">计时时保持屏幕常亮</string>
<string name="lock_fullscreen_title">锁屏全屏倒计时</string>
<string name="lock_mode_focus">专注中</string>
<string name="lock_mode_focus">工作中</string>
<string name="lock_mode_break">休息中</string>
<string name="lock_hint">点按任意处退出 · 倒计时在后台继续</string>
<string name="daily_goal">每日目标</string>
<string name="theme">深浅色</string>
<string name="theme_follow">跟随系统</string>