Compare commits

...
8 Commits
Author SHA1 Message Date
Max Lv 3facb73cf1 Bump version 2016-01-13 09:55:32 +08:00
Max Lv 8f10e95329 Refine #530 2016-01-13 09:54:52 +08:00
Max Lv b620a2e666 Fix #530 2016-01-12 12:18:52 +08:00
Max Lv 9cf8c4c483 Drop the broken support of autostart below Lolipop
Close #525
2016-01-11 10:26:22 +08:00
Max Lv bfbbb90ac3 Fix #523 2016-01-08 19:56:29 +08:00
Max Lv dc840fd0e9 Fix #517 2016-01-06 15:28:44 +08:00
Max Lv 79d1ccba23 Workaround for the crash caused by ProgressCircle
It's safe to ignore the exception throwed by hide().
Because the init state of the ProgressCircle is hidden.
2016-01-05 17:28:38 +08:00
Max Lv 19df6caa93 Fix #509 2016-01-04 08:25:58 +08:00
10 changed files with 32 additions and 25 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
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.12")
addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.5.13")
resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.7.0-SNAPSHOT")
+2 -2
View File
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.shadowsocks"
android:versionCode="127"
android:versionName="2.9.5">
android:versionCode="128"
android:versionName="2.9.6">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
+1 -1
View File
@@ -41,7 +41,7 @@
<string name="vpn_error">后台服务启动失败:%s</string>
<string name="reboot_required">VPN 服务启动失败。你可能需要重启设备。</string>
<string name="close">关闭</string>
<string name="proxy_empty">代理服务器地址不能为空</string>
<string name="proxy_empty">代理服务器地址及密码不能为空</string>
<string name="connect">连接</string>
<string name="initializing">正在初始化……</string>
<string name="recovering">重置中……</string>
+1 -1
View File
@@ -74,7 +74,7 @@
<!-- alert category -->
<string name="close">Close</string>
<string name="proxy_empty">Proxy should not be empty</string>
<string name="proxy_empty">Proxy/Password should not be empty</string>
<string name="connect">Connect</string>
<string name="initializing">Initializing…</string>
<string name="recovering">Resetting…</string>
@@ -4,6 +4,7 @@ import android.content.{ComponentName, Context, Intent, ServiceConnection}
import android.os.{RemoteException, IBinder}
import com.github.shadowsocks.aidl.{IShadowsocksServiceCallback, IShadowsocksService}
import com.github.shadowsocks.utils.Action
import com.github.shadowsocks.utils.Utils
/**
* @author Mygod
@@ -60,6 +61,7 @@ trait ServiceBoundContext extends Context {
connection = new ShadowsocksServiceConnection()
bindService(intent, connection, Context.BIND_AUTO_CREATE)
startService(intent)
}
}
@@ -126,14 +126,14 @@ class Shadowsocks
if (state == State.CONNECTING) {
fabProgressCircle.beginFinalAnimation()
} else {
handler.postDelayed(() => fabProgressCircle.hide(), 1000)
fabProgressCircle.postDelayed(hideCircle, 1000)
}
fab.setEnabled(true)
changeSwitch(checked = true)
preferences.setEnabled(false)
case State.STOPPED =>
fab.setBackgroundTintList(greyTint)
handler.postDelayed(() => fabProgressCircle.hide(), 1000)
fabProgressCircle.postDelayed(hideCircle, 1000)
fab.setEnabled(true)
changeSwitch(checked = false)
if (m != null) {
@@ -176,7 +176,7 @@ class Shadowsocks
override def onServiceConnected() {
// Update the UI
if (fab != null) fab.setEnabled(true)
stateUpdate()
updateState()
if (!ShadowsocksApplication.settings.getBoolean(ShadowsocksApplication.getVersionName, false)) {
ShadowsocksApplication.settings.edit.putBoolean(ShadowsocksApplication.getVersionName, true).apply()
@@ -404,7 +404,15 @@ class Shadowsocks
ShadowsocksApplication.profileManager.save
}
private def stateUpdate() {
private def hideCircle() {
try {
fabProgressCircle.hide()
} catch {
case _: java.lang.NullPointerException => // Ignore
}
}
private def updateState() {
if (bgService != null) {
bgService.getState match {
case State.CONNECTING =>
@@ -418,7 +426,7 @@ class Shadowsocks
serviceStarted = true
fab.setImageResource(R.drawable.ic_cloud)
preferences.setEnabled(false)
fabProgressCircle.postDelayed(fabProgressCircle.hide, 100)
fabProgressCircle.postDelayed(hideCircle, 100)
case State.STOPPING =>
fab.setBackgroundTintList(greyTint)
serviceStarted = false
@@ -430,7 +438,7 @@ class Shadowsocks
serviceStarted = false
fab.setImageResource(R.drawable.ic_cloud_off)
preferences.setEnabled(true)
fabProgressCircle.postDelayed(fabProgressCircle.hide, 100)
fabProgressCircle.postDelayed(hideCircle, 100)
}
state = bgService.getState
}
@@ -438,13 +446,13 @@ class Shadowsocks
protected override def onResume() {
super.onResume()
stateUpdate()
ConfigUtils.refresh(this)
// Check if current profile changed
if (ShadowsocksApplication.profileId != currentProfile.id) reloadProfile()
updateTraffic()
updateState()
}
private def updatePreferenceScreen() {
@@ -89,5 +89,6 @@ class ShadowsocksNotification(private val service: BaseService, profileName: Str
}
unregisterCallback
service.stopForeground(true)
nm.cancel(1)
}
}
@@ -43,11 +43,10 @@ import android.app.{Activity, KeyguardManager}
import android.content.{Intent, IntentFilter, Context, BroadcastReceiver}
import android.net.VpnService
import android.os.{Bundle, Handler}
import android.support.v7.app.AppCompatActivity
import android.util.Log
import com.github.shadowsocks.utils.ConfigUtils
class ShadowsocksRunnerActivity extends AppCompatActivity with ServiceBoundContext {
class ShadowsocksRunnerActivity extends Activity with ServiceBoundContext {
val handler = new Handler()
// Variables
@@ -144,7 +144,11 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
web.loadUrl("file:///android_asset/pages/about.html")
web.setWebViewClient(new WebViewClient() {
override def shouldOverrideUrlLoading(view: WebView, url: String): Boolean = {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)))
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)))
} catch {
case _: android.content.ActivityNotFoundException => // Ignore
}
true
}
})
@@ -55,7 +55,7 @@ import android.util.{DisplayMetrics, Base64, Log}
import android.view.View.MeasureSpec
import android.view.{Gravity, View, Window}
import android.widget.Toast
import com.github.shadowsocks.{ShadowsocksRunnerActivity, ShadowsocksRunnerService, ShadowsocksApplication, BuildConfig}
import com.github.shadowsocks.{ShadowsocksRunnerService, ShadowsocksApplication, BuildConfig}
import org.xbill.DNS._
@@ -405,15 +405,8 @@ object Utils {
val isInstalled: Boolean = ShadowsocksApplication.settings.getBoolean(ShadowsocksApplication.getVersionName, false)
if (!isInstalled) return
if (Utils.isLollipopOrAbove) {
val intent = new Intent(context, classOf[ShadowsocksRunnerService])
context.startService(intent)
} else {
val intent = new Intent(context, classOf[ShadowsocksRunnerActivity])
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
context.startActivity(intent)
}
val intent = new Intent(context, classOf[ShadowsocksRunnerService])
context.startService(intent)
}
def stopSsService(context: Context): Unit = {