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() { fun applyDayNight() {
AppConfig.upEInkMode()
ReadBookConfig.upBg() ReadBookConfig.upBg()
ThemeConfig.applyTheme(this) ThemeConfig.applyTheme(this)
initNightMode() initNightMode()

@ -7,7 +7,26 @@ import io.legado.app.R
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.utils.* import io.legado.app.utils.*
@Suppress("MemberVisibilityCanBePrivate")
object AppConfig { 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 { fun isNightTheme(context: Context): Boolean {
return when (context.getPrefString(PreferKey.themeMode, "0")) { return when (context.getPrefString(PreferKey.themeMode, "0")) {
@ -30,8 +49,9 @@ object AppConfig {
} }
} }
val isEInkMode: Boolean fun upEInkMode() {
get() = App.INSTANCE.getPrefString(PreferKey.themeMode) == "3" isEInkMode = App.INSTANCE.getPrefString(PreferKey.themeMode) == "3"
}
var isTransparentStatusBar: Boolean var isTransparentStatusBar: Boolean
get() = App.INSTANCE.getPrefBoolean(PreferKey.transparentStatusBar) get() = App.INSTANCE.getPrefBoolean(PreferKey.transparentStatusBar)
@ -83,7 +103,9 @@ object AppConfig {
App.INSTANCE.putPrefInt(PreferKey.ttsSpeechRate, value) 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 var chineseConverterType: Int
get() = App.INSTANCE.getPrefInt(PreferKey.chineseConverterType) get() = App.INSTANCE.getPrefInt(PreferKey.chineseConverterType)
@ -99,23 +121,19 @@ object AppConfig {
var elevation: Int var elevation: Int
@SuppressLint("PrivateResource") @SuppressLint("PrivateResource")
get() = App.INSTANCE.getPrefInt( get() = App.INSTANCE.getPrefInt(PreferKey.barElevation, sysElevation)
PreferKey.barElevation,
App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt()
)
set(value) { set(value) {
App.INSTANCE.putPrefInt(PreferKey.barElevation, 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 autoChangeSource: Boolean get() = App.INSTANCE.getPrefBoolean("autoChangeSource", true)
val readBodyToLh: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.readBodyToLh, 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() edit.apply()
AppConfig.replaceEnableDefault = AppConfig.upConfig()
App.INSTANCE.getPrefBoolean(PreferKey.replaceEnableDefault, true)
} }
ReadBookConfig.apply { ReadBookConfig.apply {
styleSelect = App.INSTANCE.getPrefInt(PreferKey.readStyleSelect) 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.base.BasePreferenceFragment
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.bottomBackground import io.legado.app.lib.theme.bottomBackground
@ -117,6 +118,9 @@ class MoreConfigDialog : DialogFragment() {
PreferKey.showBrightnessView -> { PreferKey.showBrightnessView -> {
postEvent(PreferKey.showBrightnessView, "") postEvent(PreferKey.showBrightnessView, "")
} }
PreferKey.clickAllNext -> {
AppConfig.upClickAllNext()
}
} }
} }

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

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

Loading…
Cancel
Save