|
|
@ -1,15 +1,14 @@ |
|
|
|
package io.legado.app.help.config |
|
|
|
package io.legado.app.help.config |
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
|
|
|
|
import android.content.SharedPreferences |
|
|
|
import androidx.core.content.edit |
|
|
|
import androidx.core.content.edit |
|
|
|
import splitties.init.appCtx |
|
|
|
import splitties.init.appCtx |
|
|
|
|
|
|
|
|
|
|
|
object LocalConfig { |
|
|
|
object LocalConfig : |
|
|
|
|
|
|
|
SharedPreferences by appCtx.getSharedPreferences("local", Context.MODE_PRIVATE) { |
|
|
|
private const val versionCodeKey = "appVersionCode" |
|
|
|
private const val versionCodeKey = "appVersionCode" |
|
|
|
|
|
|
|
|
|
|
|
private val localConfig = |
|
|
|
|
|
|
|
appCtx.getSharedPreferences("local", Context.MODE_PRIVATE) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val readHelpVersionIsLast: Boolean |
|
|
|
val readHelpVersionIsLast: Boolean |
|
|
|
get() = isLastVersion(1, "readHelpVersion", "firstRead") |
|
|
|
get() = isLastVersion(1, "readHelpVersion", "firstRead") |
|
|
|
|
|
|
|
|
|
|
@ -35,18 +34,16 @@ object LocalConfig { |
|
|
|
get() = !isLastVersion(4, "rssSourceVersion") |
|
|
|
get() = !isLastVersion(4, "rssSourceVersion") |
|
|
|
|
|
|
|
|
|
|
|
var versionCode |
|
|
|
var versionCode |
|
|
|
get() = localConfig.getLong(versionCodeKey, 0) |
|
|
|
get() = getLong(versionCodeKey, 0) |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
localConfig.edit { |
|
|
|
edit { putLong(versionCodeKey, value) } |
|
|
|
putLong(versionCodeKey, value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val isFirstOpenApp: Boolean |
|
|
|
val isFirstOpenApp: Boolean |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
val value = localConfig.getBoolean("firstOpen", true) |
|
|
|
val value = getBoolean("firstOpen", true) |
|
|
|
if (value) { |
|
|
|
if (value) { |
|
|
|
localConfig.edit { putBoolean("firstOpen", false) } |
|
|
|
edit { putBoolean("firstOpen", false) } |
|
|
|
} |
|
|
|
} |
|
|
|
return value |
|
|
|
return value |
|
|
|
} |
|
|
|
} |
|
|
@ -57,14 +54,14 @@ object LocalConfig { |
|
|
|
versionKey: String, |
|
|
|
versionKey: String, |
|
|
|
firstOpenKey: String? = null |
|
|
|
firstOpenKey: String? = null |
|
|
|
): Boolean { |
|
|
|
): Boolean { |
|
|
|
var version = localConfig.getInt(versionKey, 0) |
|
|
|
var version = getInt(versionKey, 0) |
|
|
|
if (version == 0 && firstOpenKey != null) { |
|
|
|
if (version == 0 && firstOpenKey != null) { |
|
|
|
if (!localConfig.getBoolean(firstOpenKey, true)) { |
|
|
|
if (!getBoolean(firstOpenKey, true)) { |
|
|
|
version = 1 |
|
|
|
version = 1 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (version < lastVersion) { |
|
|
|
if (version < lastVersion) { |
|
|
|
localConfig.edit { putInt(versionKey, lastVersion) } |
|
|
|
edit { putInt(versionKey, lastVersion) } |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
return true |
|
|
|
return true |
|
|
|