diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 1f99d7cba..6a47308d5 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.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" diff --git a/app/src/main/java/io/legado/app/help/LocalConfig.kt b/app/src/main/java/io/legado/app/help/LocalConfig.kt index 11c9ce430..686dd93f4 100644 --- a/app/src/main/java/io/legado/app/help/LocalConfig.kt +++ b/app/src/main/java/io/legado/app/help/LocalConfig.kt @@ -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) diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index cd100503b..8c535926e 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -52,7 +52,6 @@ object Restore { //默认忽略keys private val ignorePrefKeys = arrayOf( - PreferKey.versionCode, PreferKey.defaultCover ) private val readPrefKeys = arrayOf( diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 66970d7cc..028506550 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -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(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)