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 { ...@@ -186,8 +186,8 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
snackbar.show snackbar.show
} }
if (!app.settings.getBoolean(BuildConfig.VERSION_NAME, false)) { if (app.settings.getInt(Key.currentVersionCode, -1) != BuildConfig.VERSION_CODE) {
app.editor.putBoolean(BuildConfig.VERSION_NAME, true).apply() app.editor.putInt(Key.currentVersionCode, BuildConfig.VERSION_CODE).apply()
recovery() recovery()
......
...@@ -208,21 +208,18 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan ...@@ -208,21 +208,18 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
def refreshProfile() { def refreshProfile() {
profile = app.currentProfile match { profile = app.currentProfile match {
case Some(profile) => profile case Some(p) => p
case None => { case None =>
app.profileManager.getFirstProfile match { app.profileManager.getFirstProfile match {
case Some(profile) => { case Some(p) =>
app.profileId(profile.id) app.profileId(p.id)
profile p
} case None =>
case None => {
val default = app.profileManager.createDefault() val default = app.profileManager.createDefault()
app.profileId(default.id) app.profileId(default.id)
default default
} }
} }
}
}
isProxyApps.setChecked(profile.proxyApps) isProxyApps.setChecked(profile.proxyApps)
} }
......
...@@ -173,6 +173,7 @@ object Key { ...@@ -173,6 +173,7 @@ object Key {
val kcpcli = "kcpcli" val kcpcli = "kcpcli"
val tfo = "tcp_fastopen" val tfo = "tcp_fastopen"
val currentVersionCode = "currentVersionCode"
} }
object State { 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