Commit e82c7ccb authored by Max Lv's avatar Max Lv

Refine #478

parent 88b87537
...@@ -221,8 +221,10 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC ...@@ -221,8 +221,10 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT)) WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT))
findViewById(R.id.onSwitch).asInstanceOf[Switch] ShadowsocksApplication.settings.edit().putBoolean(Key.isProxyApps, true).commit()
.setOnCheckedChangeListener((button: CompoundButton, checked: Boolean) => { val onSwitch = findViewById(R.id.onSwitch).asInstanceOf[Switch]
onSwitch.setChecked(true)
onSwitch.setOnCheckedChangeListener((button: CompoundButton, checked: Boolean) => {
ShadowsocksApplication.settings.edit().putBoolean(Key.isProxyApps, checked).commit() ShadowsocksApplication.settings.edit().putBoolean(Key.isProxyApps, checked).commit()
finish() finish()
}) })
......
...@@ -24,6 +24,11 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan ...@@ -24,6 +24,11 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
getPreferenceManager.getSharedPreferences.registerOnSharedPreferenceChangeListener(this) getPreferenceManager.getSharedPreferences.registerOnSharedPreferenceChangeListener(this)
isProxyApps = findPreference(Key.isProxyApps).asInstanceOf[SwitchPreference] 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) => { findPreference("recovery").setOnPreferenceClickListener((preference: Preference) => {
ShadowsocksApplication.track(Shadowsocks.TAG, "reset") ShadowsocksApplication.track(Shadowsocks.TAG, "reset")
...@@ -65,17 +70,10 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan ...@@ -65,17 +70,10 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
override def onResume { override def onResume {
super.onResume() super.onResume()
isProxyApps.setChecked(ShadowsocksApplication.settings.getBoolean(Key.isProxyApps, false)) // update isProxyApps.setChecked(ShadowsocksApplication.settings.getBoolean(Key.isProxyApps, false)) // update
isProxyApps.setOnPreferenceChangeListener((preference: Preference, newValue: Any) => {
if (newValue.asInstanceOf[Boolean] == true) {
startActivity(new Intent(activity, classOf[AppManager]))
}
true
})
} }
override def onPause { override def onPause {
super.onPause() super.onPause()
isProxyApps.setOnPreferenceChangeListener(null)
} }
def onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) = key match { def onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) = key match {
......
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