32 lines
889 B
Kotlin
32 lines
889 B
Kotlin
|
|
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)
|
||
|
|
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
|
||
|
|
}
|
||
|
|
)
|
||
|
|
}
|
||
|
|
}
|