From f45ee8d1418cf252f27566322bb308e44c41bee9 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Thu, 17 Oct 2013 12:47:36 +0800 Subject: [PATCH] fix #46 --- build.sbt | 2 +- .../com/github/shadowsocks/Shadowsocks.scala | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 1db72bac..0ea3380c 100644 --- a/build.sbt +++ b/build.sbt @@ -13,7 +13,7 @@ libraryDependencies ++= Seq( ) libraryDependencies ++= Seq( - "de.keyboardsurfer.android.widget" % "crouton" % "1.7", + "de.keyboardsurfer.android.widget" % "crouton" % "1.8.1", "com.nostra13.universalimageloader" % "universal-image-loader" % "1.8.4", "com.j256.ormlite" % "ormlite-core" % "4.47", "com.j256.ormlite" % "ormlite-android" % "4.47" diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala index 9ea7c0b8..fe6ec473 100644 --- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala +++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala @@ -48,8 +48,7 @@ import android.util.Log import android.view._ import android.widget._ import com.google.analytics.tracking.android.{MapBuilder, EasyTracker} -import de.keyboardsurfer.android.widget.crouton.Crouton -import de.keyboardsurfer.android.widget.crouton.Style +import de.keyboardsurfer.android.widget.crouton.{Crouton, Style, Configuration} import java.io._ import java.util.Hashtable import net.saik0.android.unifiedpreference.UnifiedPreferenceFragment @@ -714,10 +713,14 @@ class Shadowsocks if (ShadowVpnService.isServiceStarted(this)) { val style = new Style.Builder() .setBackgroundColorValue(Style.holoBlueLight) - .setDuration(Style.DURATION_INFINITE) + .build() + val config = new Configuration.Builder() + .setDuration(Configuration.DURATION_LONG) .build() switchButton.setEnabled(false) - Crouton.makeText(Shadowsocks.this, R.string.vpn_status, style).show() + Crouton.makeText(Shadowsocks.this, R.string.vpn_status, style) + .setConfiguration(config) + .show() } setPreferenceEnabled(enabled = false) onStateChanged(State.CONNECTED, null) @@ -878,9 +881,13 @@ class Shadowsocks startService(intent) val style = new Style.Builder() .setBackgroundColorValue(Style.holoBlueLight) - .setDuration(Style.DURATION_INFINITE) .build() - Crouton.makeText(Shadowsocks.this, R.string.vpn_status, style).show() + val config = new Configuration.Builder() + .setDuration(Configuration.DURATION_LONG) + .build() + Crouton.makeText(Shadowsocks.this, R.string.vpn_status, style) + .setConfiguration(config) + .show() switchButton.setEnabled(false) } else { if (ShadowsocksService.isServiceStarted(this)) return false @@ -972,10 +979,13 @@ class Shadowsocks Crouton.cancelAllCroutons() val style = new Style.Builder() .setBackgroundColorValue(Style.holoRedLight) - .setDuration(Style.DURATION_INFINITE) + .build() + val config = new Configuration.Builder() + .setDuration(Configuration.DURATION_LONG) .build() Crouton .makeText(Shadowsocks.this, getString(R.string.vpn_error).format(m), style) + .setConfiguration(config) .show() } setPreferenceEnabled(enabled = true)