pull/480/head
gedoor 4 years ago
parent 6c782107fc
commit e7a0a212e2
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 9
      app/src/main/java/io/legado/app/help/LocalConfig.kt
  3. 1
      app/src/main/java/io/legado/app/help/storage/Restore.kt
  4. 8
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -1,7 +1,6 @@
package io.legado.app.constant
object PreferKey {
const val versionCode = "versionCode"
const val language = "language"
const val themeMode = "themeMode"
const val hideStatusBar = "hideStatusBar"

@ -5,10 +5,19 @@ import androidx.core.content.edit
import io.legado.app.App
object LocalConfig {
private const val versionCodeKey = "versionCode"
private val localConfig =
App.INSTANCE.getSharedPreferences("local", Context.MODE_PRIVATE)
var versionCode
get() = localConfig.getInt(versionCodeKey, 0)
set(value) {
localConfig.edit {
putInt(versionCodeKey, value)
}
}
val isFirstOpenApp: Boolean
get() {
val value = localConfig.getBoolean("firstOpen", true)

@ -52,7 +52,6 @@ object Restore {
//默认忽略keys
private val ignorePrefKeys = arrayOf(
PreferKey.versionCode,
PreferKey.defaultCover
)
private val readPrefKeys = arrayOf(

@ -27,7 +27,9 @@ import io.legado.app.ui.main.explore.ExploreFragment
import io.legado.app.ui.main.my.MyFragment
import io.legado.app.ui.main.rss.RssFragment
import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.*
import io.legado.app.utils.getViewModel
import io.legado.app.utils.hideSoftInput
import io.legado.app.utils.observeEvent
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.toast
@ -101,8 +103,8 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
}
private fun upVersion() {
if (getPrefInt(PreferKey.versionCode) != App.versionCode) {
putPrefInt(PreferKey.versionCode, App.versionCode)
if (LocalConfig.versionCode != App.versionCode) {
LocalConfig.versionCode = App.versionCode
if (LocalConfig.isFirstOpenApp) {
val text = String(assets.open("help/appHelp.md").readBytes())
TextDialog.show(supportFragmentManager, text, TextDialog.MD)

Loading…
Cancel
Save