feat: 优化代码

pull/121/head
kunfei 5 years ago
parent a17cd1fb7b
commit c380d1e7e7
  1. 7
      app/src/main/java/io/legado/app/App.kt
  2. 3
      app/src/main/java/io/legado/app/utils/ContextExtensions.kt

@ -5,6 +5,7 @@ import android.app.Application
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import androidx.annotation.RequiresApi
@ -62,6 +63,11 @@ class App : Application() {
registerActivityLife()
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
initNightMode()
}
/**
* 更新主题
*/
@ -91,7 +97,6 @@ class App : Application() {
)
.apply()
}
// ChapterProvider.upReadAloudSpan()
}
fun applyDayNight() {

@ -133,6 +133,9 @@ fun Context.sendToClip(text: String) {
}
}
/**
* 系统是否暗色主题
*/
fun Context.sysIsDarkMode(): Boolean {
val mode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
return mode == Configuration.UI_MODE_NIGHT_YES

Loading…
Cancel
Save