Commit 02d5951f authored by Mygod's avatar Mygod

Auto reset when downgrading

While it's theoretically impossible to downgrade without reinstalling the app, there are ways to bypass this mechanism. And don't forget users can restore their app data as well.
parent b126c623
......@@ -186,8 +186,8 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
snackbar.show
}
if (!app.settings.getBoolean(BuildConfig.VERSION_NAME, false)) {
app.editor.putBoolean(BuildConfig.VERSION_NAME, true).apply()
if (app.settings.getInt(Key.currentVersionCode, -1) != BuildConfig.VERSION_CODE) {
app.editor.putInt(Key.currentVersionCode, BuildConfig.VERSION_CODE).apply()
recovery()
......
......@@ -208,20 +208,17 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
def refreshProfile() {
profile = app.currentProfile match {
case Some(profile) => profile
case None => {
case Some(p) => p
case None =>
app.profileManager.getFirstProfile match {
case Some(profile) => {
app.profileId(profile.id)
profile
}
case None => {
case Some(p) =>
app.profileId(p.id)
p
case None =>
val default = app.profileManager.createDefault()
app.profileId(default.id)
default
}
}
}
}
isProxyApps.setChecked(profile.proxyApps)
}
......
......@@ -173,6 +173,7 @@ object Key {
val kcpcli = "kcpcli"
val tfo = "tcp_fastopen"
val currentVersionCode = "currentVersionCode"
}
object State {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment