diff --git a/src/main/scala/com/github/shadowsocks/AppManager.scala b/src/main/scala/com/github/shadowsocks/AppManager.scala index 2a3b5a55..7e86eb9f 100644 --- a/src/main/scala/com/github/shadowsocks/AppManager.scala +++ b/src/main/scala/com/github/shadowsocks/AppManager.scala @@ -221,6 +221,7 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT)) + ShadowsocksApplication.settings.edit().putBoolean(Key.isProxyApps, true).commit() findViewById(R.id.onSwitch).asInstanceOf[Switch] .setOnCheckedChangeListener((button: CompoundButton, checked: Boolean) => { ShadowsocksApplication.settings.edit().putBoolean(Key.isProxyApps, checked).commit() diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala index bfbc3d68..8af9db6a 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala @@ -1,7 +1,6 @@ package com.github.shadowsocks import java.lang.System.currentTimeMillis -import java.lang.{Long => jLong} import java.net.{HttpURLConnection, URL} import java.util.Locale @@ -67,6 +66,11 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan }) isProxyApps = findPreference(Key.isProxyApps).asInstanceOf[SwitchPreference] + isProxyApps.setOnPreferenceClickListener((preference: Preference) => { + startActivity(new Intent(activity, classOf[AppManager])) + isProxyApps.setChecked(true) + false + }) findPreference("recovery").setOnPreferenceClickListener((preference: Preference) => { ShadowsocksApplication.track(Shadowsocks.TAG, "reset") @@ -108,15 +112,10 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan override def onResume { super.onResume() isProxyApps.setChecked(ShadowsocksApplication.settings.getBoolean(Key.isProxyApps, false)) // update - isProxyApps.setOnPreferenceChangeListener((preference: Preference, newValue: Any) => { - startActivity(new Intent(activity, classOf[AppManager])) - newValue.asInstanceOf[Boolean] // keep it ON - }) } override def onPause { super.onPause() - isProxyApps.setOnPreferenceChangeListener(null) } def onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) = key match {