Commit eb174247 authored by Max Lv's avatar Max Lv

update Crouton

parent 5808d574
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
<string name="forward_stop">Shadowsocks stopped.</string> <string name="forward_stop">Shadowsocks stopped.</string>
<string name="service_failed">Please check your network status and try again.</string> <string name="service_failed">Please check your network status and try again.</string>
<string name="stop">Stop the service</string> <string name="stop">Stop the service</string>
<string name="vpn_status">You can only disable the VPN service through the notification bar.</string>
<!-- alert category --> <!-- alert category -->
<string name="ok_iknow">OK</string> <string name="ok_iknow">OK</string>
......
...@@ -252,16 +252,16 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton. ...@@ -252,16 +252,16 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton.
checked match { checked match {
case true => { case true => {
if (isVpnEnabled) { if (isVpnEnabled) {
if (!serviceStart) {
switchButton.setChecked(false)
}
} else {
val intent = VpnService.prepare(this) val intent = VpnService.prepare(this)
if (intent != null) { if (intent != null) {
startActivityForResult(intent, Shadowsocks.REQUEST_CONNECT) startActivityForResult(intent, Shadowsocks.REQUEST_CONNECT)
} else { } else {
onActivityResult(Shadowsocks.REQUEST_CONNECT, Activity.RESULT_OK, null) onActivityResult(Shadowsocks.REQUEST_CONNECT, Activity.RESULT_OK, null)
} }
} else {
if (!serviceStart) {
switchButton.setChecked(false)
}
} }
} }
case false => { case false => {
...@@ -364,6 +364,14 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton. ...@@ -364,6 +364,14 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton.
val settings: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(this) val settings: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
if (isServiceStarted) { if (isServiceStarted) {
switchButton.setChecked(true) switchButton.setChecked(true)
if (ShadowVpnService.isServiceStarted) {
val style = new Style.Builder()
.setBackgroundColorValue(Style.holoBlueLight)
.setDuration(Style.DURATION_INFINITE)
.build()
switchButton.setEnabled(false)
Crouton.makeText(Shadowsocks.this, R.string.vpn_status, style).show()
}
} }
else { else {
if (settings.getBoolean("isRunning", false)) { if (settings.getBoolean("isRunning", false)) {
...@@ -448,6 +456,11 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton. ...@@ -448,6 +456,11 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton.
} }
} }
override def onDestroy() {
super.onDestroy()
Crouton.cancelAllCroutons()
}
def reset() { def reset() {
crash_recovery() crash_recovery()
copyAssets("") copyAssets("")
...@@ -538,13 +551,19 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton. ...@@ -538,13 +551,19 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton.
} }
if (isVpnEnabled) { if (isVpnEnabled) {
if (ShadowsocksService.isServiceStarted) return false
val it: Intent = new Intent(this, classOf[ShadowsocksService])
startService(it)
} else {
if (ShadowVpnService.isServiceStarted) return false if (ShadowVpnService.isServiceStarted) return false
val it: Intent = new Intent(this, classOf[ShadowVpnService]) val it: Intent = new Intent(this, classOf[ShadowVpnService])
startService(it) startService(it)
val style = new Style.Builder()
.setBackgroundColorValue(Style.holoBlueLight)
.setDuration(Style.DURATION_INFINITE)
.build()
Crouton.makeText(Shadowsocks.this, R.string.vpn_status, style).show()
switchButton.setEnabled(false)
} else {
if (ShadowsocksService.isServiceStarted) return false
val it: Intent = new Intent(this, classOf[ShadowsocksService])
startService(it)
} }
true true
......
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