From a14d3ea99c20b5fae037966c943629e9aa076284 Mon Sep 17 00:00:00 2001 From: Mygod Date: Tue, 10 Nov 2015 18:40:18 +0800 Subject: [PATCH 1/2] Fix crashing bug --- src/main/scala/com/github/shadowsocks/Shadowsocks.scala | 5 ----- .../com/github/shadowsocks/database/ProfileManager.scala | 6 ------ 2 files changed, 11 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala index 5c6a6e0d..ccab7de1 100644 --- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala +++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala @@ -350,11 +350,6 @@ class Shadowsocks super.onCreate(savedInstanceState) - // Update the profile - if (!ShadowsocksApplication.settings.getBoolean(ShadowsocksApplication.getVersionName, false)) { - currentProfile = ShadowsocksApplication.profileManager.create() - } - // Initialize the profile currentProfile = { ShadowsocksApplication.currentProfile getOrElse currentProfile diff --git a/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala b/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala index 24da9121..2370153f 100644 --- a/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala +++ b/src/main/scala/com/github/shadowsocks/database/ProfileManager.scala @@ -163,10 +163,4 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) { updateProfile(profile) profile } - - def create(): Profile = { - val profile = loadFromPreferences - createOrUpdateProfile(profile) - profile - } } From 4059b785b04d71865e4b6ffe1a2039461447ac48 Mon Sep 17 00:00:00 2001 From: Mygod Date: Tue, 10 Nov 2015 18:57:29 +0800 Subject: [PATCH 2/2] Switch to another profile while connected --- src/main/scala/com/github/shadowsocks/Shadowsocks.scala | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala index ccab7de1..853cef0f 100644 --- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala +++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala @@ -387,12 +387,6 @@ class Shadowsocks changeSwitch(checked = false) case false => serviceStop() - if (fab.isEnabled) { - fab.setEnabled(false) - handler.postDelayed(() => { - fab.setEnabled(true) - }, 1000) - } } }) fab.setOnLongClickListener((v: View) => { @@ -439,6 +433,8 @@ class Shadowsocks } updatePreferenceScreen() + + serviceStop() } def addProfile(profile: Profile) { @@ -493,7 +489,6 @@ class Shadowsocks } private def setPreferenceEnabled(enabled: Boolean) { - preferences.findPreference(Key.profiles).setEnabled(enabled) preferences.findPreference(Key.isNAT).setEnabled(enabled) for (name <- Shadowsocks.PROXY_PREFS) { val pref = preferences.findPreference(name)