2026-11-28 00:25:22 +08:00
|
|
|
package com.focusbox.app
|
|
|
|
|
|
|
|
|
|
import android.app.Application
|
|
|
|
|
import androidx.appcompat.app.AppCompatDelegate
|
|
|
|
|
import com.focusbox.app.data.Store
|
|
|
|
|
import com.focusbox.app.service.Notif
|
|
|
|
|
import com.focusbox.app.service.TimerCore
|
|
|
|
|
import com.focusbox.app.util.Prefs
|
|
|
|
|
|
|
|
|
|
class App : Application() {
|
|
|
|
|
|
|
|
|
|
override fun onCreate() {
|
|
|
|
|
super.onCreate()
|
|
|
|
|
Prefs.init(this)
|
|
|
|
|
Store.init(this)
|
2026-11-28 01:07:24 +08:00
|
|
|
// 重复任务按间隔滚到当前周期:冷启动就补齐,避免过期后不再出现在清单里
|
|
|
|
|
runCatching { Store.rollRepeatingTasks() }
|
2026-11-28 00:25:22 +08:00
|
|
|
Notif.createChannels(this)
|
|
|
|
|
applyTheme()
|
|
|
|
|
TimerCore.init(this)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 深色模式在 Activity 创建前定好,避免首帧闪一下浅色再跳深色 */
|
|
|
|
|
fun applyTheme() {
|
|
|
|
|
AppCompatDelegate.setDefaultNightMode(
|
|
|
|
|
when (Prefs.themeMode) {
|
|
|
|
|
1 -> AppCompatDelegate.MODE_NIGHT_NO
|
|
|
|
|
2 -> AppCompatDelegate.MODE_NIGHT_YES
|
|
|
|
|
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|