37 lines
No EOL
1.3 KiB
Kotlin
37 lines
No EOL
1.3 KiB
Kotlin
package cn.super12138.todo.views
|
|
|
|
import android.os.Build
|
|
import android.os.Bundle
|
|
import android.view.WindowManager
|
|
import androidx.activity.SystemBarStyle
|
|
import androidx.activity.enableEdgeToEdge
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.appcompat.app.AppCompatDelegate
|
|
import cn.super12138.todo.constant.GlobalValues
|
|
|
|
open class BaseActivity : AppCompatActivity() {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
/*if (GlobalValues.springFestivalTheme) {
|
|
setTheme(R.style.Theme_SpringFestival)
|
|
}*/
|
|
enableEdgeToEdge()
|
|
super.onCreate(savedInstanceState)
|
|
|
|
// 深色模式
|
|
when (GlobalValues.darkMode) {
|
|
"0" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
|
|
|
"1" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
|
|
|
"2" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
|
}
|
|
|
|
// 适配刘海屏
|
|
val lp = window.attributes
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
lp.layoutInDisplayCutoutMode =
|
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
|
}
|
|
window.attributes = lp
|
|
}
|
|
} |