diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index cbe836e8..574a0d74 100755
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -57,6 +57,7 @@
Shadowsocks stopped.
Please check your network status and try again.
Stop the service
+ You can only disable the VPN service through the notification bar.
OK
diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
index 8b317f93..c72b2205 100644
--- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
@@ -252,16 +252,16 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton.
checked match {
case true => {
if (isVpnEnabled) {
- if (!serviceStart) {
- switchButton.setChecked(false)
- }
- } else {
val intent = VpnService.prepare(this)
if (intent != null) {
startActivityForResult(intent, Shadowsocks.REQUEST_CONNECT)
} else {
onActivityResult(Shadowsocks.REQUEST_CONNECT, Activity.RESULT_OK, null)
}
+ } else {
+ if (!serviceStart) {
+ switchButton.setChecked(false)
+ }
}
}
case false => {
@@ -364,6 +364,14 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton.
val settings: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
if (isServiceStarted) {
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 {
if (settings.getBoolean("isRunning", false)) {
@@ -448,6 +456,11 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton.
}
}
+ override def onDestroy() {
+ super.onDestroy()
+ Crouton.cancelAllCroutons()
+ }
+
def reset() {
crash_recovery()
copyAssets("")
@@ -538,13 +551,19 @@ class Shadowsocks extends UnifiedSherlockPreferenceActivity with CompoundButton.
}
if (isVpnEnabled) {
- if (ShadowsocksService.isServiceStarted) return false
- val it: Intent = new Intent(this, classOf[ShadowsocksService])
- startService(it)
- } else {
if (ShadowVpnService.isServiceStarted) return false
val it: Intent = new Intent(this, classOf[ShadowVpnService])
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