pull/32/head
gedoor 6 years ago
parent ec49c73e81
commit 3fb20d551c
  1. 2
      app/src/main/java/io/legado/app/App.kt
  2. 16
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt

@ -74,8 +74,8 @@ class App : Application() {
}
fun applyDayNight(){
initNightTheme()
upThemeStore()
initNightTheme()
}
/**

@ -2,6 +2,8 @@ package io.legado.app.ui.config
import android.content.SharedPreferences
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AlertDialog
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.App
@ -32,7 +34,8 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
sharedPreferences ?: return
when (key) {
"colorPrimary", "colorAccent", "colorBackground" -> if (!ColorUtils.isColorLight(
"colorPrimary", "colorAccent", "colorBackground" ->
if (!ColorUtils.isColorLight(
sharedPreferences.getInt(
"colorBackground",
App.INSTANCE.getCompatColor(R.color.md_grey_100)
@ -42,16 +45,17 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar
AlertDialog.Builder(App.INSTANCE)
.setTitle("白天背景太暗")
.setMessage("将会恢复默认背景?")
.setPositiveButton(R.string.ok) { dialog, which ->
.setPositiveButton(R.string.ok) { _, _ ->
App.INSTANCE.putPrefInt("colorBackground", App.INSTANCE.getCompatColor(R.color.md_grey_100))
upTheme(false)
}
.setNegativeButton(R.string.cancel) { dialogInterface, i -> upTheme(false) }
.setNegativeButton(R.string.cancel) { _, _ -> upTheme(false) }
.show().upTint
} else {
upTheme(false)
}
"colorPrimaryNight", "colorAccentNight", "colorBackgroundNight" -> if (ColorUtils.isColorLight(
"colorPrimaryNight", "colorAccentNight", "colorBackgroundNight" ->
if (ColorUtils.isColorLight(
sharedPreferences.getInt(
"colorBackgroundNight",
App.INSTANCE.getCompatColor(R.color.md_grey_800)
@ -61,14 +65,14 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar
AlertDialog.Builder(App.INSTANCE)
.setTitle("夜间背景太亮")
.setMessage("将会恢复默认背景?")
.setPositiveButton(R.string.ok) { dialog, which ->
.setPositiveButton(R.string.ok) { _, _ ->
App.INSTANCE.putPrefInt(
"colorBackgroundNight",
App.INSTANCE.getCompatColor(R.color.md_grey_800)
)
upTheme(true)
}
.setNegativeButton(R.string.cancel) { dialogInterface, i -> upTheme(true) }
.setNegativeButton(R.string.cancel) { _, _ -> upTheme(true) }
.show()
} else {
upTheme(true)

Loading…
Cancel
Save