pull/457/head
gedoor 4 years ago
parent 7cd44122dd
commit 711bc3919a
  1. 1
      app/src/main/java/io/legado/app/App.kt
  2. 42
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 3
      app/src/main/java/io/legado/app/help/storage/Restore.kt
  4. 4
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  5. 3
      app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt
  6. 3
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt

@ -67,6 +67,7 @@ class App : MultiDexApplication() {
}
fun applyDayNight() {
AppConfig.upEInkMode()
ReadBookConfig.upBg()
ThemeConfig.applyTheme(this)
initNightMode()

@ -7,7 +7,26 @@ import io.legado.app.R
import io.legado.app.constant.PreferKey
import io.legado.app.utils.*
@Suppress("MemberVisibilityCanBePrivate")
object AppConfig {
var isEInkMode: Boolean = false
var clickAllNext: Boolean = false
var isGooglePlay: Boolean
var isCoolApk: Boolean
var replaceEnableDefault: Boolean = true
val sysElevation = App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt()
init {
upConfig()
isGooglePlay = App.INSTANCE.channel == "google"
isCoolApk = App.INSTANCE.channel == "coolApk"
}
fun upConfig() {
upEInkMode()
upClickAllNext()
upReplaceEnableDefault()
}
fun isNightTheme(context: Context): Boolean {
return when (context.getPrefString(PreferKey.themeMode, "0")) {
@ -30,8 +49,9 @@ object AppConfig {
}
}
val isEInkMode: Boolean
get() = App.INSTANCE.getPrefString(PreferKey.themeMode) == "3"
fun upEInkMode() {
isEInkMode = App.INSTANCE.getPrefString(PreferKey.themeMode) == "3"
}
var isTransparentStatusBar: Boolean
get() = App.INSTANCE.getPrefBoolean(PreferKey.transparentStatusBar)
@ -83,7 +103,9 @@ object AppConfig {
App.INSTANCE.putPrefInt(PreferKey.ttsSpeechRate, value)
}
val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false)
fun upClickAllNext() {
clickAllNext = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false)
}
var chineseConverterType: Int
get() = App.INSTANCE.getPrefInt(PreferKey.chineseConverterType)
@ -99,23 +121,19 @@ object AppConfig {
var elevation: Int
@SuppressLint("PrivateResource")
get() = App.INSTANCE.getPrefInt(
PreferKey.barElevation,
App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt()
)
get() = App.INSTANCE.getPrefInt(PreferKey.barElevation, sysElevation)
set(value) {
App.INSTANCE.putPrefInt(PreferKey.barElevation, value)
}
var replaceEnableDefault: Boolean =
App.INSTANCE.getPrefBoolean(PreferKey.replaceEnableDefault, true)
val autoChangeSource: Boolean get() = App.INSTANCE.getPrefBoolean("autoChangeSource", true)
val readBodyToLh: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.readBodyToLh, true)
val isGooglePlay: Boolean get() = App.INSTANCE.channel == "google"
fun upReplaceEnableDefault() {
replaceEnableDefault =
App.INSTANCE.getPrefBoolean(PreferKey.replaceEnableDefault, true)
}
val isCoolApk: Boolean get() = App.INSTANCE.channel == "coolApk"
}

@ -204,8 +204,7 @@ object Restore {
}
}
edit.apply()
AppConfig.replaceEnableDefault =
App.INSTANCE.getPrefBoolean(PreferKey.replaceEnableDefault, true)
AppConfig.upConfig()
}
ReadBookConfig.apply {
styleSelect = App.INSTANCE.getPrefInt(PreferKey.readStyleSelect)

@ -12,6 +12,7 @@ import io.legado.app.R
import io.legado.app.base.BasePreferenceFragment
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.bottomBackground
@ -117,6 +118,9 @@ class MoreConfigDialog : DialogFragment() {
PreferKey.showBrightnessView -> {
postEvent(PreferKey.showBrightnessView, "")
}
PreferKey.clickAllNext -> {
AppConfig.upClickAllNext()
}
}
}

@ -122,8 +122,7 @@ class OtherConfigFragment : BasePreferenceFragment(),
key,
getPrefString(PreferKey.defaultCover)
)
PreferKey.replaceEnableDefault -> AppConfig.replaceEnableDefault =
App.INSTANCE.getPrefBoolean(PreferKey.replaceEnableDefault, true)
PreferKey.replaceEnableDefault -> AppConfig.upReplaceEnableDefault()
PreferKey.language -> listView.postDelayed({
LanguageUtils.setConfiguration(App.INSTANCE)
val intent = Intent(App.INSTANCE, MainActivity::class.java)

@ -161,8 +161,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
.setMinValue(0)
.setValue(AppConfig.elevation)
.setCustomButton((R.string.btn_default_s)) {
AppConfig.elevation =
App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt()
AppConfig.elevation = AppConfig.sysElevation
recreateActivities()
}
.show {

Loading…
Cancel
Save