Commit 88b87537 authored by Max Lv's avatar Max Lv

Fix #478

parent 063d97b2
resolvers += Resolver.url("scalasbt releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots"))(Resolver.ivyStylePatterns) resolvers += Resolver.url("scalasbt releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots"))(Resolver.ivyStylePatterns)
addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.5.10") addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.5.11")
resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/" resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.7.0-SNAPSHOT") addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.7.0-SNAPSHOT")
......
...@@ -150,6 +150,10 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC ...@@ -150,6 +150,10 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
handler.removeCallbacksAndMessages(null) handler.removeCallbacksAndMessages(null)
handler = null handler = null
} }
if (overlay != null) {
getWindowManager.removeViewImmediate(overlay)
overlay = null
}
} }
def onMenuItemClick(item: MenuItem): Boolean = { def onMenuItemClick(item: MenuItem): Boolean = {
...@@ -210,7 +214,7 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC ...@@ -210,7 +214,7 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
toolbar.inflateMenu(R.menu.app_manager_menu) toolbar.inflateMenu(R.menu.app_manager_menu)
toolbar.setOnMenuItemClickListener(this) toolbar.setOnMenuItemClickListener(this)
this.overlay = View.inflate(this, R.layout.overlay, null).asInstanceOf[TextView] overlay = View.inflate(this, R.layout.overlay, null).asInstanceOf[TextView]
getWindowManager.addView(overlay, new getWindowManager.addView(overlay, new
WindowManager.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.TYPE_APPLICATION,
...@@ -219,7 +223,7 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC ...@@ -219,7 +223,7 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
findViewById(R.id.onSwitch).asInstanceOf[Switch] findViewById(R.id.onSwitch).asInstanceOf[Switch]
.setOnCheckedChangeListener((button: CompoundButton, checked: Boolean) => { .setOnCheckedChangeListener((button: CompoundButton, checked: Boolean) => {
ShadowsocksApplication.settings.edit().putBoolean(Key.isProxyApps, checked).apply() ShadowsocksApplication.settings.edit().putBoolean(Key.isProxyApps, checked).commit()
finish() finish()
}) })
......
...@@ -24,10 +24,6 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan ...@@ -24,10 +24,6 @@ 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.setOnPreferenceChangeListener((preference: Preference, newValue: Any) => {
startActivity(new Intent(activity, classOf[AppManager]))
newValue.asInstanceOf[Boolean] // keep it ON
})
findPreference("recovery").setOnPreferenceClickListener((preference: Preference) => { findPreference("recovery").setOnPreferenceClickListener((preference: Preference) => {
ShadowsocksApplication.track(Shadowsocks.TAG, "reset") ShadowsocksApplication.track(Shadowsocks.TAG, "reset")
...@@ -67,8 +63,19 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan ...@@ -67,8 +63,19 @@ 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 {
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