Update dependencies
This commit is contained in:
@@ -6,6 +6,8 @@ platformTarget in Android := "android-23"
|
||||
|
||||
name := "shadowsocks"
|
||||
|
||||
scalaVersion := "2.11.7"
|
||||
|
||||
compileOrder in Compile := CompileOrder.JavaThenScala
|
||||
|
||||
javacOptions ++= Seq("-source", "1.6", "-target", "1.6")
|
||||
@@ -24,26 +26,20 @@ resolvers += "JRAF" at "http://JRAF.org/static/maven/2"
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"dnsjava" % "dnsjava" % "2.1.7",
|
||||
"com.github.kevinsawicki" % "http-request" % "5.6",
|
||||
"com.github.kevinsawicki" % "http-request" % "6.0",
|
||||
"commons-net" % "commons-net" % "3.3",
|
||||
"com.google.zxing" % "android-integration" % "3.1.0"
|
||||
)
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"com.joanzapata.android" % "android-iconify" % "1.0.9",
|
||||
"com.google.zxing" % "android-integration" % "3.1.0",
|
||||
"com.joanzapata.android" % "android-iconify" % "1.0.11",
|
||||
"net.glxn.qrgen" % "android" % "2.0",
|
||||
"net.simonvt.menudrawer" % "menudrawer" % "3.0.6",
|
||||
"com.google.android.gms" % "play-services-base" % "8.1.0",
|
||||
"com.google.android.gms" % "play-services-ads" % "8.1.0",
|
||||
"com.google.android.gms" % "play-services-analytics" % "8.1.0",
|
||||
"com.android.support" % "support-v4" % "23.0.1"
|
||||
)
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"com.android.support" % "support-v4" % "23.0.1",
|
||||
"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"
|
||||
"com.j256.ormlite" % "ormlite-core" % "4.48",
|
||||
"com.j256.ormlite" % "ormlite-android" % "4.48"
|
||||
)
|
||||
|
||||
proguardOptions in Android ++= Seq("-keep class android.support.v4.app.** { *; }",
|
||||
|
||||
@@ -65,7 +65,8 @@ import com.nostra13.universalimageloader.core.{DisplayImageOptions, ImageLoader,
|
||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer
|
||||
import com.github.shadowsocks.utils.{Utils, Scheme, Key}
|
||||
|
||||
import scala.concurrent.ops._
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
import scala.language.implicitConversions
|
||||
|
||||
case class ProxiedApp(uid: Int, name: String, packageName: String, var proxied: Boolean)
|
||||
@@ -267,9 +268,8 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
|
||||
}
|
||||
|
||||
protected override def onCreateOptionsMenu(menu: Menu): Boolean = {
|
||||
val inflater = getMenuInflater()
|
||||
inflater.inflate(R.menu.app_manager_menu, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
getMenuInflater.inflate(R.menu.app_manager_menu, menu)
|
||||
super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
protected override def onCreate(savedInstanceState: Bundle) {
|
||||
@@ -277,7 +277,7 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
|
||||
|
||||
handler = new Handler()
|
||||
|
||||
val actionBar = getActionBar()
|
||||
val actionBar = getActionBar
|
||||
actionBar.setTitle(R.string.proxied_help)
|
||||
actionBar.setDisplayHomeAsUpEnabled(true)
|
||||
actionBar.setDisplayShowHomeEnabled(false)
|
||||
@@ -309,7 +309,7 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
|
||||
|
||||
protected override def onResume() {
|
||||
super.onResume()
|
||||
spawn {
|
||||
Future {
|
||||
handler.post(loadStartRunnable)
|
||||
if (!appsLoaded) loadApps()
|
||||
handler.post(loadFinishRunnable)
|
||||
|
||||
@@ -39,13 +39,11 @@
|
||||
|
||||
package com.github.shadowsocks
|
||||
|
||||
import android.os.{Handler, RemoteCallbackList}
|
||||
import com.github.shadowsocks.aidl.{Config, IShadowsocksService, IShadowsocksServiceCallback}
|
||||
import com.github.shadowsocks.utils.{Path, State}
|
||||
import java.io.{IOException, FileNotFoundException, FileReader, BufferedReader}
|
||||
import android.util.Log
|
||||
import android.app.Notification
|
||||
import android.content.Context
|
||||
import android.os.{Handler, RemoteCallbackList}
|
||||
import com.github.shadowsocks.aidl.{Config, IShadowsocksService, IShadowsocksServiceCallback}
|
||||
import com.github.shadowsocks.utils.State
|
||||
|
||||
trait BaseService {
|
||||
|
||||
@@ -100,10 +98,10 @@ trait BaseService {
|
||||
def getTag: String
|
||||
def getContext: Context
|
||||
|
||||
def getCallbackCount(): Int = {
|
||||
def getCallbackCount: Int = {
|
||||
callbackCount
|
||||
}
|
||||
def getState(): Int = {
|
||||
def getState: Int = {
|
||||
state
|
||||
}
|
||||
def changeState(s: Int) {
|
||||
|
||||
@@ -39,15 +39,15 @@
|
||||
|
||||
package com.github.shadowsocks
|
||||
|
||||
import android.os.{Message, Handler, Bundle}
|
||||
import android.app.{ProgressDialog, AlertDialog, Activity}
|
||||
import android.content.{Intent, DialogInterface}
|
||||
import com.github.shadowsocks.database.{ProfileManager, Profile}
|
||||
import com.github.shadowsocks.utils.{Parser, Action}
|
||||
import android.preference.PreferenceManager
|
||||
import android.view.WindowManager
|
||||
import android.app.{Activity, AlertDialog, ProgressDialog}
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.{Bundle, Handler, Message}
|
||||
import android.preference.PreferenceManager
|
||||
import android.view.WindowManager
|
||||
import com.github.shadowsocks.database.{Profile, ProfileManager}
|
||||
import com.github.shadowsocks.utils.Parser
|
||||
|
||||
class ParserActivity extends Activity {
|
||||
override def onCreate(savedInstanceState: Bundle) {
|
||||
|
||||
@@ -38,10 +38,9 @@
|
||||
*/
|
||||
package com.github.shadowsocks
|
||||
|
||||
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, FileOutputStream, IOException, InputStream, OutputStream}
|
||||
import java.util
|
||||
import java.io.{OutputStream, InputStream, ByteArrayInputStream, ByteArrayOutputStream, IOException, FileOutputStream}
|
||||
import java.util.Locale
|
||||
import java.lang.Math
|
||||
|
||||
import android.app.backup.BackupManager
|
||||
import android.app.{Activity, AlertDialog, ProgressDialog}
|
||||
@@ -52,6 +51,7 @@ import android.graphics.{Bitmap, Color, Typeface}
|
||||
import android.net.{Uri, VpnService}
|
||||
import android.os._
|
||||
import android.preference._
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.util.{DisplayMetrics, Log}
|
||||
import android.view.View.OnLongClickListener
|
||||
import android.view._
|
||||
@@ -65,15 +65,15 @@ import com.github.shadowsocks.utils._
|
||||
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 net.simonvt.menudrawer.MenuDrawer
|
||||
import com.joanzapata.android.iconify.Iconify
|
||||
import com.joanzapata.android.iconify.Iconify.IconValue
|
||||
import com.joanzapata.android.iconify.IconDrawable
|
||||
import com.joanzapata.android.iconify.Iconify.IconValue
|
||||
import com.nostra13.universalimageloader.core.download.BaseImageDownloader
|
||||
import net.glxn.qrgen.android.QRCode
|
||||
import net.simonvt.menudrawer.MenuDrawer
|
||||
|
||||
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
|
||||
import scala.concurrent.ops._
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
|
||||
class ProfileIconDownloader(context: Context, connectTimeout: Int, readTimeout: Int)
|
||||
extends BaseImageDownloader(context, connectTimeout, readTimeout) {
|
||||
@@ -224,7 +224,7 @@ class Shadowsocks
|
||||
|
||||
if (!status.getBoolean(getVersionName, false)) {
|
||||
status.edit.putBoolean(getVersionName, true).commit()
|
||||
recovery();
|
||||
recovery()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ class Shadowsocks
|
||||
changeSwitch(checked = false)
|
||||
}
|
||||
|
||||
def isReady(): Boolean = {
|
||||
def isReady: Boolean = {
|
||||
if (!checkText(Key.proxy)) return false
|
||||
if (!checkText(Key.sitekey)) return false
|
||||
if (!checkNumber(Key.localPort, low = false)) return false
|
||||
@@ -407,7 +407,7 @@ class Shadowsocks
|
||||
|
||||
def prepareStartService() {
|
||||
showProgress(R.string.connecting)
|
||||
spawn {
|
||||
Future {
|
||||
if (isVpnEnabled) {
|
||||
val intent = VpnService.prepare(this)
|
||||
if (intent != null) {
|
||||
@@ -522,8 +522,8 @@ class Shadowsocks
|
||||
getActionBar.setDisplayShowTitleEnabled(false)
|
||||
getActionBar.setDisplayShowCustomEnabled(true)
|
||||
if (Utils.isLollipopOrAbove) {
|
||||
getWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
getWindow.setStatusBarColor(getResources().getColor(R.color.grey3));
|
||||
getWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
||||
getWindow.setStatusBarColor(ContextCompat.getColor(this, R.color.grey3))
|
||||
getActionBar.setDisplayHomeAsUpEnabled(true)
|
||||
getActionBar.setHomeAsUpIndicator(R.drawable.ic_drawer)
|
||||
} else {
|
||||
@@ -551,7 +551,7 @@ class Shadowsocks
|
||||
registerReceiver(preferenceReceiver, new IntentFilter(Action.UPDATE_PREFS))
|
||||
|
||||
// Bind to the service
|
||||
spawn {
|
||||
Future {
|
||||
val isRoot = (!Utils.isLollipopOrAbove || status.getBoolean(Key.isNAT, false)) && Console.isRoot
|
||||
handler.post(new Runnable {
|
||||
override def run() {
|
||||
@@ -718,7 +718,7 @@ class Shadowsocks
|
||||
|
||||
val profile = profileManager.getProfile(id)
|
||||
|
||||
if (!profile.isDefined) return false
|
||||
if (profile.isEmpty) return false
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(String.format(Locale.ENGLISH, getString(R.string.remove_profile), profile.get.name))
|
||||
@@ -731,7 +731,7 @@ class Shadowsocks
|
||||
profileManager.delProfile(id)
|
||||
val profileId = {
|
||||
val profiles = profileManager.getAllProfiles.getOrElse(List[Profile]())
|
||||
if (profiles.isEmpty) -1 else profiles(0).id
|
||||
if (profiles.isEmpty) -1 else profiles.head.id
|
||||
}
|
||||
currentProfile = profileManager.load(profileId)
|
||||
menuAdapter.updateList(getMenuList, currentProfile.id)
|
||||
@@ -934,16 +934,14 @@ class Shadowsocks
|
||||
private def recovery() {
|
||||
serviceStop()
|
||||
val h = showProgress(R.string.recovering)
|
||||
spawn {
|
||||
Future {
|
||||
reset()
|
||||
h.sendEmptyMessage(0)
|
||||
}
|
||||
}
|
||||
|
||||
private def dp2px(dp: Int): Int = {
|
||||
val displayMetrics = getBaseContext.getResources.getDisplayMetrics()
|
||||
Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT))
|
||||
}
|
||||
private def dp2px(dp: Int): Int =
|
||||
Math.round(dp * (getBaseContext.getResources.getDisplayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT))
|
||||
|
||||
private def showQrCode() {
|
||||
val image = new ImageView(this)
|
||||
@@ -967,7 +965,7 @@ class Shadowsocks
|
||||
|
||||
private def flushDnsCache() {
|
||||
val h = showProgress(R.string.flushing)
|
||||
spawn {
|
||||
Future {
|
||||
Utils.toggleAirplaneMode(getBaseContext)
|
||||
h.sendEmptyMessage(0)
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ import com.google.android.gms.analytics.HitBuilders
|
||||
|
||||
import scala.collection._
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
import scala.concurrent.ops._
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
|
||||
class ShadowsocksNatService extends Service with BaseService {
|
||||
|
||||
@@ -556,7 +557,7 @@ class ShadowsocksNatService extends Service with BaseService {
|
||||
|
||||
changeState(State.CONNECTING)
|
||||
|
||||
spawn {
|
||||
Future {
|
||||
|
||||
if (config.proxy == "198.199.101.152") {
|
||||
val holder = application.containerHolder
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
package com.github.shadowsocks
|
||||
|
||||
import java.io.File
|
||||
import java.net.InetAddress
|
||||
import java.util.Locale
|
||||
|
||||
import android.app._
|
||||
@@ -57,7 +56,8 @@ import org.apache.commons.net.util.SubnetUtils
|
||||
|
||||
import scala.collection.mutable
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
import scala.concurrent.ops._
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
|
||||
class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
@@ -218,7 +218,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
changeState(State.CONNECTING)
|
||||
|
||||
spawn {
|
||||
Future {
|
||||
if (config.proxy == "198.199.101.152") {
|
||||
val holder = getApplication.asInstanceOf[ShadowsocksApplication].containerHolder
|
||||
try {
|
||||
@@ -453,7 +453,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
Console.runCommand(cmd)
|
||||
|
||||
return fd
|
||||
fd
|
||||
}
|
||||
|
||||
override def stopBackgroundService() {
|
||||
|
||||
@@ -103,7 +103,7 @@ class ShadowsocksVpnThread(vpnService: ShadowsocksVpnService) extends Thread {
|
||||
|
||||
val fds = socket.getAncillaryFileDescriptors
|
||||
|
||||
if (fds.length > 0) {
|
||||
if (fds.nonEmpty) {
|
||||
var ret = false
|
||||
|
||||
val getInt = classOf[FileDescriptor].getDeclaredMethod("getInt$")
|
||||
@@ -136,10 +136,9 @@ class ShadowsocksVpnThread(vpnService: ShadowsocksVpnService) extends Thread {
|
||||
|
||||
}})
|
||||
} catch {
|
||||
case e: IOException => {
|
||||
case e: IOException =>
|
||||
Log.e(TAG, "Error when accept socket", e)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ import android.view.ViewGroup
|
||||
import android.widget.BaseAdapter
|
||||
import android.widget.TextView
|
||||
import android.graphics.drawable.Drawable
|
||||
import com.github.shadowsocks.{R}
|
||||
import com.github.shadowsocks.R
|
||||
import android.view.View.{OnLongClickListener, OnClickListener}
|
||||
|
||||
abstract class Item {
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
|
||||
package com.github.shadowsocks.database
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.util.Log
|
||||
import com.github.shadowsocks._
|
||||
import android.content.{SharedPreferences, Context}
|
||||
import com.github.shadowsocks.utils.Key
|
||||
|
||||
class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
|
||||
|
||||
@@ -233,8 +233,8 @@ object ConfigUtils {
|
||||
.readTimeout(2000)
|
||||
.send("sig="+sig)
|
||||
.body
|
||||
val proxies = util.Random.shuffle(list.split('|').toSeq).toSeq
|
||||
val proxy = proxies(0).split(':')
|
||||
val proxies = util.Random.shuffle(list.split('|').toSeq)
|
||||
val proxy = proxies.head.split(':')
|
||||
|
||||
val host = proxy(0).trim
|
||||
val port = proxy(1).trim.toInt
|
||||
|
||||
@@ -47,11 +47,8 @@ import android.util.{Log, Base64}
|
||||
object Parser {
|
||||
val TAG = "ShadowParser"
|
||||
|
||||
def generate (profile: Profile): String = {
|
||||
val path = "%s:%s@%s:%d".formatLocal(Locale.ENGLISH,
|
||||
profile.method, profile.password, profile.host, profile.remotePort)
|
||||
return "ss://" + Base64.encodeToString(path.getBytes, Base64.NO_PADDING)
|
||||
}
|
||||
def generate (profile: Profile): String = "ss://" + Base64.encodeToString("%s:%s@%s:%d".formatLocal(Locale.ENGLISH,
|
||||
profile.method, profile.password, profile.host, profile.remotePort).getBytes, Base64.NO_PADDING)
|
||||
|
||||
def parse (data: String): Option[Profile] = {
|
||||
try {
|
||||
|
||||
@@ -38,21 +38,21 @@
|
||||
*/
|
||||
package com.github.shadowsocks.utils
|
||||
|
||||
import android.content.{Intent, Context}
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.drawable.{BitmapDrawable, Drawable}
|
||||
import android.util.{Base64, Log}
|
||||
import java.io._
|
||||
import java.net._
|
||||
import org.xbill.DNS._
|
||||
import android.graphics._
|
||||
import java.security.MessageDigest
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.content.pm.{ApplicationInfo, PackageManager}
|
||||
import android.content.{Context, Intent}
|
||||
import android.graphics._
|
||||
import android.graphics.drawable.{BitmapDrawable, Drawable}
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import scala.Some
|
||||
import java.security.MessageDigest
|
||||
import com.github.shadowsocks.{BuildConfig}
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.util.{Base64, Log}
|
||||
import com.github.shadowsocks.BuildConfig
|
||||
import org.xbill.DNS._
|
||||
|
||||
|
||||
object Utils {
|
||||
@@ -146,6 +146,7 @@ object Utils {
|
||||
// + "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false\n")
|
||||
}
|
||||
|
||||
//noinspection ScalaDeprecation
|
||||
private def toggleBelowApiLevel17(context: Context) {
|
||||
// Android 4.2 below
|
||||
Settings.System.putInt(context.getContentResolver, Settings.System.AIRPLANE_MODE_ON, 1)
|
||||
@@ -197,7 +198,7 @@ object Utils {
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
case e: Exception => None
|
||||
case e: Exception =>
|
||||
}
|
||||
None
|
||||
}
|
||||
@@ -232,7 +233,7 @@ object Utils {
|
||||
None
|
||||
}
|
||||
|
||||
lazy val isNumericMethod = classOf[InetAddress].getMethod("isNumeric", classOf[String])
|
||||
private lazy val isNumericMethod = classOf[InetAddress].getMethod("isNumeric", classOf[String])
|
||||
def isNumeric(address: String): Boolean = isNumericMethod.invoke(null, address).asInstanceOf[Boolean]
|
||||
|
||||
/**
|
||||
@@ -338,7 +339,7 @@ object Utils {
|
||||
|
||||
def getAppIcon(c: Context, packageName: String): Drawable = {
|
||||
val pm: PackageManager = c.getPackageManager
|
||||
val icon: Drawable = c.getResources.getDrawable(android.R.drawable.sym_def_app_icon)
|
||||
val icon: Drawable = ContextCompat.getDrawable(c, android.R.drawable.sym_def_app_icon)
|
||||
try {
|
||||
pm.getApplicationIcon(packageName)
|
||||
} catch {
|
||||
@@ -348,7 +349,7 @@ object Utils {
|
||||
|
||||
def getAppIcon(c: Context, uid: Int): Drawable = {
|
||||
val pm: PackageManager = c.getPackageManager
|
||||
val icon: Drawable = c.getResources.getDrawable(android.R.drawable.sym_def_app_icon)
|
||||
val icon: Drawable = ContextCompat.getDrawable(c, android.R.drawable.sym_def_app_icon)
|
||||
val packages: Array[String] = pm.getPackagesForUid(uid)
|
||||
if (packages != null) {
|
||||
if (packages.length >= 1) {
|
||||
|
||||
Reference in New Issue
Block a user