Commit 461a0bda authored by Mygod's avatar Mygod

Remove unnecessary app.settings param in ConfigUtils.load

parent c878d4da
...@@ -605,7 +605,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext { ...@@ -605,7 +605,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
/** Called when connect button is clicked. */ /** Called when connect button is clicked. */
def serviceLoad() { def serviceLoad() {
bgService.use(ConfigUtils.load(app.settings)) bgService.use(ConfigUtils.loadFromSharedPreferences)
if (app.isVpnEnabled) { if (app.isVpnEnabled) {
changeSwitch(checked = false) changeSwitch(checked = false)
......
...@@ -73,7 +73,7 @@ class ShadowsocksRunnerActivity extends Activity with ServiceBoundContext { ...@@ -73,7 +73,7 @@ class ShadowsocksRunnerActivity extends Activity with ServiceBoundContext {
onActivityResult(REQUEST_CONNECT, Activity.RESULT_OK, null) onActivityResult(REQUEST_CONNECT, Activity.RESULT_OK, null)
} }
} else { } else {
bgService.use(ConfigUtils.load(app.settings)) bgService.use(ConfigUtils.loadFromSharedPreferences)
finish() finish()
} }
} }
...@@ -109,7 +109,7 @@ class ShadowsocksRunnerActivity extends Activity with ServiceBoundContext { ...@@ -109,7 +109,7 @@ class ShadowsocksRunnerActivity extends Activity with ServiceBoundContext {
resultCode match { resultCode match {
case Activity.RESULT_OK => case Activity.RESULT_OK =>
if (bgService != null) { if (bgService != null) {
bgService.use(ConfigUtils.load(app.settings)) bgService.use(ConfigUtils.loadFromSharedPreferences)
} }
case _ => case _ =>
Log.e(TAG, "Failed to start VpnService") Log.e(TAG, "Failed to start VpnService")
......
...@@ -62,11 +62,11 @@ class ShadowsocksRunnerService extends Service with ServiceBoundContext { ...@@ -62,11 +62,11 @@ class ShadowsocksRunnerService extends Service with ServiceBoundContext {
val intent = VpnService.prepare(ShadowsocksRunnerService.this) val intent = VpnService.prepare(ShadowsocksRunnerService.this)
if (intent == null) { if (intent == null) {
if (bgService != null) { if (bgService != null) {
bgService.use(ConfigUtils.load(app.settings)) bgService.use(ConfigUtils.loadFromSharedPreferences)
} }
} }
} else { } else {
bgService.use(ConfigUtils.load(app.settings)) bgService.use(ConfigUtils.loadFromSharedPreferences)
} }
stopSelf() stopSelf()
} }
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
package com.github.shadowsocks.utils package com.github.shadowsocks.utils
import android.content.{Context, SharedPreferences} import android.content.Context
import com.github.kevinsawicki.http.HttpRequest import com.github.kevinsawicki.http.HttpRequest
import com.github.shadowsocks.R import com.github.shadowsocks.R
import com.github.shadowsocks.ShadowsocksApplication.app import com.github.shadowsocks.ShadowsocksApplication.app
...@@ -200,24 +200,24 @@ object ConfigUtils { ...@@ -200,24 +200,24 @@ object ConfigUtils {
config.profileName, host, password, method, config.proxiedAppString, config.route, port, config.localPort, 0) config.profileName, host, password, method, config.proxiedAppString, config.route, port, config.localPort, 0)
} }
def load(settings: SharedPreferences): Config = { def loadFromSharedPreferences = {
val isProxyApps = settings.getBoolean(Key.isProxyApps, false) val isProxyApps = app.settings.getBoolean(Key.isProxyApps, false)
val isBypassApps = settings.getBoolean(Key.isBypassApps, false) val isBypassApps = app.settings.getBoolean(Key.isBypassApps, false)
val isUdpDns = settings.getBoolean(Key.isUdpDns, false) val isUdpDns = app.settings.getBoolean(Key.isUdpDns, false)
val isAuth = settings.getBoolean(Key.isAuth, false) val isAuth = app.settings.getBoolean(Key.isAuth, false)
val isIpv6 = settings.getBoolean(Key.isIpv6, false) val isIpv6 = app.settings.getBoolean(Key.isIpv6, false)
val profileName = settings.getString(Key.profileName, "default") val profileName = app.settings.getString(Key.profileName, "default")
val proxy = settings.getString(Key.proxy, "127.0.0.1") val proxy = app.settings.getString(Key.proxy, "127.0.0.1")
val sitekey = settings.getString(Key.sitekey, "default") val sitekey = app.settings.getString(Key.sitekey, "default")
val encMethod = settings.getString(Key.encMethod, "table") val encMethod = app.settings.getString(Key.encMethod, "table")
val route = settings.getString(Key.route, "all") val route = app.settings.getString(Key.route, "all")
val remotePort = settings.getInt(Key.remotePort, 1984) val remotePort = app.settings.getInt(Key.remotePort, 1984)
val localPort = settings.getInt(Key.localPort, 1984) val localPort = app.settings.getInt(Key.localPort, 1984)
val proxiedAppString = settings.getString(Key.proxied, "") val proxiedAppString = app.settings.getString(Key.proxied, "")
val profileId = settings.getInt(Key.profileId, -1) val profileId = app.settings.getInt(Key.profileId, -1)
new Config(isProxyApps, isBypassApps, isUdpDns, isAuth, isIpv6, profileName, proxy, sitekey, encMethod, new Config(isProxyApps, isBypassApps, isUdpDns, isAuth, isIpv6, profileName, proxy, sitekey, encMethod,
proxiedAppString, route, remotePort, localPort, profileId) proxiedAppString, route, remotePort, localPort, profileId)
......
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