From 7f226d3f0ce4d19ec08812e3f35864d281e01dd9 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 19 Dec 2014 17:32:00 +0800 Subject: [PATCH] replace crouton with snackbar --- build.sbt | 4 +++- src/main/res/values-zh/strings.xml | 3 ++- src/main/res/values/strings.xml | 3 ++- .../com/github/shadowsocks/Shadowsocks.scala | 23 ++++++++----------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/build.sbt b/build.sbt index 31577d83..a3a9e9cc 100644 --- a/build.sbt +++ b/build.sbt @@ -14,6 +14,8 @@ ndkJavah in Android := List() ndkBuild in Android := List() +typedResources in Android := false + resolvers += "JRAF" at "http://JRAF.org/static/maven/2" resolvers += "madeye private releases" at "http://madeye-maven-repository.googlecode.com/git/" @@ -32,7 +34,7 @@ libraryDependencies ++= Seq( ) libraryDependencies ++= Seq( - "de.keyboardsurfer.android.widget" % "crouton" % "1.8.4" exclude("com.google.android", "support-v4"), + "com.github.mrengineer13" % "snackbar" % "0.5.0", "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/res/values-zh/strings.xml b/src/main/res/values-zh/strings.xml index c89c2154..aab5e96c 100755 --- a/src/main/res/values-zh/strings.xml +++ b/src/main/res/values-zh/strings.xml @@ -47,7 +47,7 @@ 无法连接远程服务器 停止服务 正在关闭... - 后台服务启动失败:\"%s\"。 + 后台服务启动失败:%s 确定 端口号应大于1024 端口号不能为空 @@ -94,5 +94,6 @@ 导出失败 导入成功 导入失败 + 错误 diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 4e51f063..e100e55b 100755 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -58,9 +58,10 @@ Failed to connect the remote server Stop the service Shutting down... - Error: \"%s\". + %s Turn on NAT mode. Turn off NAT mode. + ERROR OK diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala index c628bb89..1204f44f 100644 --- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala +++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala @@ -56,6 +56,7 @@ import android.view.View.OnLongClickListener import android.view._ import android.webkit.{WebView, WebViewClient} import android.widget._ +import com.github.mrengineer13.snackbar._ import com.github.shadowsocks.aidl.{IShadowsocksService, IShadowsocksServiceCallback} import com.github.shadowsocks.database._ import com.github.shadowsocks.preferences.{PasswordEditTextPreference, ProfileEditTextPreference, SummaryEditTextPreference} @@ -64,7 +65,6 @@ import com.google.android.gms.ads.{AdRequest, AdSize, AdView} import com.google.android.gms.analytics.HitBuilders import com.google.zxing.integration.android.IntentIntegrator import com.nostra13.universalimageloader.core.download.BaseImageDownloader -import de.keyboardsurfer.android.widget.crouton.{Configuration, Crouton, Style} import net.simonvt.menudrawer.MenuDrawer import scala.collection.mutable.{ArrayBuffer, ListBuffer} @@ -205,7 +205,6 @@ class Shadowsocks // Update the UI if (switchButton != null) switchButton.setEnabled(true) if (State.isAvailable(bgService.getState)) { - Crouton.cancelAllCroutons() setPreferenceEnabled(enabled = true) } else { changeSwitch(checked = true) @@ -367,7 +366,7 @@ class Shadowsocks def isTextEmpty(s: String, msg: String): Boolean = { if (s == null || s.length <= 0) { - Crouton.makeText(this, msg, Style.ALERT).show() + new SnackBar.Builder(this).withMessage(msg).withStyle(SnackBar.Style.ALERT).show() return true } false @@ -828,7 +827,6 @@ class Shadowsocks override def onDestroy() { super.onDestroy() deattachService() - Crouton.cancelAllCroutons() unregisterReceiver(preferenceReceiver) new BackupManager(this).dataChanged() if (handler != null) { @@ -927,12 +925,12 @@ class Shadowsocks try { val port: Int = Integer.valueOf(text) if (!low && port <= 1024) { - Crouton.makeText(this, R.string.port_alert, Style.ALERT).show() + new SnackBar.Builder(this).withMessageId(R.string.port_alert).withStyle(SnackBar.Style.ALERT).show() return false } } catch { case ex: Exception => - Crouton.makeText(this, R.string.port_alert, Style.ALERT).show() + new SnackBar.Builder(this).withMessageId(R.string.port_alert).withStyle(SnackBar.Style.ALERT).show() return false } true @@ -1014,15 +1012,12 @@ class Shadowsocks case State.STOPPED => clearDialog() changeSwitch(checked = false) - Crouton.cancelAllCroutons() if (m != null) { - val style = new Style.Builder().setBackgroundColorValue(Style.holoRedLight).build() - val config = new Configuration.Builder() - .setDuration(Configuration.DURATION_LONG) - .build() - Crouton - .makeText(Shadowsocks.this, getString(R.string.vpn_error).formatLocal(Locale.ENGLISH, m), style) - .setConfiguration(config) + new SnackBar.Builder(Shadowsocks.this) + .withMessage(getString(R.string.vpn_error).formatLocal(Locale.ENGLISH, m)) + .withActionMessageId(R.string.error) + .withStyle(SnackBar.Style.ALERT) + .withDuration(SnackBar.LONG_SNACK) .show() } setPreferenceEnabled(enabled = true)