diff --git a/project/Build.scala b/project/Build.scala
index 7672c5a5..a51ece76 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -5,8 +5,8 @@ import sbtandroid._
import sbtandroid.AndroidKeys._
object App {
- val version = "1.7.7"
- val versionCode = 44
+ val version = "1.8.0"
+ val versionCode = 45
}
object General {
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 608efc4b..cf7d4d06 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -6,6 +6,7 @@
+
Shadowsocks %s
Donate
http://buildbot.sinaapp.com/donate.html
-
+ Flush DNS Cache
+ Flushing
diff --git a/src/main/scala/com/github/shadowsocks/AppManager.scala b/src/main/scala/com/github/shadowsocks/AppManager.scala
index dcc829fb..8222e4cc 100644
--- a/src/main/scala/com/github/shadowsocks/AppManager.scala
+++ b/src/main/scala/com/github/shadowsocks/AppManager.scala
@@ -1,5 +1,6 @@
-/* Shadowsocks - A shadowsocks client for Android
- * Copyright (C) 2012
+/*
+ * Shadowsocks - A shadowsocks client for Android
+ * Copyright (C) 2013
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -277,7 +278,7 @@ class AppManager extends SherlockActivity with OnCheckedChangeListener with OnCl
appListView.setAdapter(adapter)
appListView.setOnScrollListener(new AbsListView.OnScrollListener {
def onScroll(view: AbsListView, firstVisibleItem: Int, visibleItemCount: Int,
- totalItemCount: Int) {
+ totalItemCount: Int) {
if (visible) {
val name: String = apps(firstVisibleItem).name
if (name != null && name.length > 1) {
@@ -325,4 +326,4 @@ class AppManager extends SherlockActivity with OnCheckedChangeListener with OnCl
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/scala/com/github/shadowsocks/ShadowVpnActivity.scala b/src/main/scala/com/github/shadowsocks/ShadowVpnActivity.scala
index 22ca8714..e2a8022b 100644
--- a/src/main/scala/com/github/shadowsocks/ShadowVpnActivity.scala
+++ b/src/main/scala/com/github/shadowsocks/ShadowVpnActivity.scala
@@ -1,3 +1,42 @@
+/*
+ * Shadowsocks - A shadowsocks client for Android
+ * Copyright (C) 2013
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ *
+ * ___====-_ _-====___
+ * _--^^^#####// \\#####^^^--_
+ * _-^##########// ( ) \\##########^-_
+ * -############// |\^^/| \\############-
+ * _/############// (@::@) \\############\_
+ * /#############(( \\// ))#############\
+ * -###############\\ (oo) //###############-
+ * -#################\\ / VV \ //#################-
+ * -###################\\/ \//###################-
+ * _#/|##########/\######( /\ )######/\##########|\#_
+ * |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
+ * ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
+ * ` ` ` ` / | | | | \ ' ' ' '
+ * ( | | | | )
+ * __\ | | | | /__
+ * (vvv(VVV)(VVV)vvv)
+ *
+ * HERE BE DRAGONS
+ *
+ */
+
package com.github.shadowsocks
import android.app.Activity
diff --git a/src/main/scala/com/github/shadowsocks/ShadowVpnService.scala b/src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
index 182aee4d..786493b6 100644
--- a/src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
+++ b/src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
@@ -1,5 +1,6 @@
-/* Shadowsocks - A shadowsocks client for Android
- * Copyright (C) 2012
+/*
+ * Shadowsocks - A shadowsocks client for Android
+ * Copyright (C) 2013
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,6 +36,7 @@
* HERE BE DRAGONS
*
*/
+
package com.github.shadowsocks
import android.app._
diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
index f98936c4..98e59b22 100644
--- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala
@@ -1,4 +1,5 @@
-/* Shadowsocks - A shadowsocks client for Android
+/*
+ * Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2012
*
* This program is free software: you can redistribute it and/or modify
@@ -124,7 +125,7 @@ object Shadowsocks {
}
}
- class FeatureFragment extends UnifiedPreferenceFragment with OnSharedPreferenceChangeListener{
+ class FeatureFragment extends UnifiedPreferenceFragment with OnSharedPreferenceChangeListener {
var receiver: BroadcastReceiver = null
@@ -269,7 +270,7 @@ class Shadowsocks
private def copyFile(in: InputStream, out: OutputStream) {
val buffer: Array[Byte] = new Array[Byte](1024)
var read: Int = 0
- while ({
+ while ( {
read = in.read(buffer)
read
} != -1) {
@@ -363,8 +364,6 @@ class Shadowsocks
setHeaderRes(R.xml.shadowsocks_headers)
super.onCreate(savedInstanceState)
-
-
val switchLayout = getLayoutInflater
.inflate(R.layout.layout_switch, null)
.asInstanceOf[RelativeLayout]
@@ -427,6 +426,10 @@ class Shadowsocks
.add(0, 1, 1, R.string.about)
.setIcon(android.R.drawable.ic_menu_info_details)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT)
+ menu
+ .add(0, 2, 2, R.string.flush_dnscache)
+ .setIcon(android.R.drawable.ic_menu_revert)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT)
true
}
@@ -453,6 +456,10 @@ class Shadowsocks
EasyTracker.getTracker.sendEvent(Shadowsocks.TAG, "about", getVersionName, 0L)
showAbout()
}
+ case 2 => {
+ EasyTracker.getTracker.sendEvent(Shadowsocks.TAG, "flush_dnscache", getVersionName, 0L)
+ flushDnsCache()
+ }
}
super.onOptionsItemSelected(item)
}
@@ -559,6 +566,20 @@ class Shadowsocks
}
}
+ private def flushDnsCache() {
+ clearDialog()
+ progressDialog = ProgressDialog.show(this, "", getString(R.string.flushing), true, true)
+ val h: Handler = new Handler {
+ override def handleMessage(msg: Message) {
+ clearDialog()
+ }
+ }
+ spawn {
+ Utils.toggleAirplaneMode(getBaseContext)
+ h.sendEmptyMessage(0)
+ }
+ }
+
override def onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
resultCode match {
case Activity.RESULT_OK => {
diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
index 562b24ff..f704c868 100644
--- a/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
+++ b/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
@@ -1,5 +1,6 @@
-/* Shadowsocks - A shadowsocks client for Android
- * Copyright (C) 2012
+/*
+ * Shadowsocks - A shadowsocks client for Android
+ * Copyright (C) 2013
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -44,4 +45,4 @@ class ShadowsocksApplication extends Application {
override def onCreate() {
EasyTracker.getInstance.setContext(this)
}
-}
\ No newline at end of file
+}
diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksBackupAgent.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksBackupAgent.scala
index 19e9791f..b63940a0 100644
--- a/src/main/scala/com/github/shadowsocks/ShadowsocksBackupAgent.scala
+++ b/src/main/scala/com/github/shadowsocks/ShadowsocksBackupAgent.scala
@@ -1,3 +1,42 @@
+/*
+ * Shadowsocks - A shadowsocks client for Android
+ * Copyright (C) 2013
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ *
+ * ___====-_ _-====___
+ * _--^^^#####// \\#####^^^--_
+ * _-^##########// ( ) \\##########^-_
+ * -############// |\^^/| \\############-
+ * _/############// (@::@) \\############\_
+ * /#############(( \\// ))#############\
+ * -###############\\ (oo) //###############-
+ * -#################\\ / VV \ //#################-
+ * -###################\\/ \//###################-
+ * _#/|##########/\######( /\ )######/\##########|\#_
+ * |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
+ * ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
+ * ` ` ` ` / | | | | \ ' ' ' '
+ * ( | | | | )
+ * __\ | | | | /__
+ * (vvv(VVV)(VVV)vvv)
+ *
+ * HERE BE DRAGONS
+ *
+ */
+
package com.github.shadowsocks
import android.app.backup.{SharedPreferencesBackupHelper, BackupAgentHelper}
diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksReceiver.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
index 80004ac1..d9cdb026 100644
--- a/src/main/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
+++ b/src/main/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
@@ -1,5 +1,6 @@
-/* Shadowsocks - A shadowsocks client for Android
- * Copyright (C) 2012
+/*
+ * Shadowsocks - A shadowsocks client for Android
+ * Copyright (C) 2013
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -82,4 +83,4 @@ class ShadowsocksReceiver extends BroadcastReceiver {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
index 655748ea..d0d3912a 100644
--- a/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
+++ b/src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
@@ -1,5 +1,6 @@
-/* Shadowsocks - A shadowsocks client for Android
- * Copyright (C) 2012
+/*
+ * Shadowsocks - A shadowsocks client for Android
+ * Copyright (C) 2013
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,6 +36,7 @@
* HERE BE DRAGONS
*
*/
+
package com.github.shadowsocks
import android.app.Notification
diff --git a/src/main/scala/com/github/shadowsocks/Utils.scala b/src/main/scala/com/github/shadowsocks/Utils.scala
index 4cbefa0d..041e2c9e 100644
--- a/src/main/scala/com/github/shadowsocks/Utils.scala
+++ b/src/main/scala/com/github/shadowsocks/Utils.scala
@@ -1,4 +1,5 @@
-/* Shadowsocks - A shadowsocks client for Android
+/*
+ * Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2012
*
* This program is free software: you can redistribute it and/or modify
@@ -50,6 +51,8 @@ import org.xbill.DNS._
import scala.Some
import android.graphics.{Canvas, Bitmap}
import android.app.ActivityManager
+import android.os.Build
+import android.provider.Settings
object Config {
val SHADOWSOCKS = "{\"server\": [%s], \"server_port\": %d, \"local_port\": %d, \"password\": %s, \"timeout\": %d}"
@@ -100,7 +103,11 @@ object Config {
def printToFile(f: java.io.File)(op: java.io.PrintWriter => Unit) {
val p = new java.io.PrintWriter(f)
- try { op(p) } finally { p.close() }
+ try {
+ op(p)
+ } finally {
+ p.close()
+ }
}
}
@@ -252,6 +259,38 @@ object Utils {
var data_path: String = null
var rootTries = 0
+ // Blocked > 3 seconds
+ def toggleAirplaneMode(context: Context) {
+ if (Build.VERSION.SDK_INT >= 17) {
+ toggleAboveApiLevel17()
+ } else {
+ toggleBelowApiLevel17(context)
+ }
+ }
+
+ private def toggleAboveApiLevel17() {
+ // Android 4.2 and above
+ Utils.runRootCommand("settings put global airplane_mode_on 1\n"
+ + "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true\n"
+ + "settings put global airplane_mode_on 0\n"
+ + "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false\n"
+ )
+ }
+
+ private def toggleBelowApiLevel17(context: Context) {
+ // Android 4.2 below
+ Settings.System.putInt(context.getContentResolver, Settings.System.AIRPLANE_MODE_ON, 1)
+ val enableIntent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED)
+ enableIntent.putExtra("state", true)
+ context.sendBroadcast(enableIntent)
+ Thread.sleep(3000)
+
+ Settings.System.putInt(context.getContentResolver, Settings.System.AIRPLANE_MODE_ON, 0)
+ val disableIntent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED)
+ disableIntent.putExtra("state", false)
+ context.sendBroadcast(disableIntent)
+ }
+
def isServiceStarted(name: String, context: Context): Boolean = {
import scala.collection.JavaConversions._
diff --git a/src/main/scala/com/github/shadowsocks/preferences/PasswordEditTextPreference.scala b/src/main/scala/com/github/shadowsocks/preferences/PasswordEditTextPreference.scala
index 177b818e..4a8cd7da 100644
--- a/src/main/scala/com/github/shadowsocks/preferences/PasswordEditTextPreference.scala
+++ b/src/main/scala/com/github/shadowsocks/preferences/PasswordEditTextPreference.scala
@@ -1,3 +1,42 @@
+/*
+ * Shadowsocks - A shadowsocks client for Android
+ * Copyright (C) 2013
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ *
+ * ___====-_ _-====___
+ * _--^^^#####// \\#####^^^--_
+ * _-^##########// ( ) \\##########^-_
+ * -############// |\^^/| \\############-
+ * _/############// (@::@) \\############\_
+ * /#############(( \\// ))#############\
+ * -###############\\ (oo) //###############-
+ * -#################\\ / VV \ //#################-
+ * -###################\\/ \//###################-
+ * _#/|##########/\######( /\ )######/\##########|\#_
+ * |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
+ * ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
+ * ` ` ` ` / | | | | \ ' ' ' '
+ * ( | | | | )
+ * __\ | | | | /__
+ * (vvv(VVV)(VVV)vvv)
+ *
+ * HERE BE DRAGONS
+ *
+ */
+
package com.github.shadowsocks.preferences
import android.content.Context
@@ -21,4 +60,4 @@ class PasswordEditTextPreference(context: Context, attrs: AttributeSet, defStyle
}
private var mDefaultSummary: CharSequence = getSummary
-}
\ No newline at end of file
+}
diff --git a/src/main/scala/com/github/shadowsocks/preferences/SummaryEditTextPreference.scala b/src/main/scala/com/github/shadowsocks/preferences/SummaryEditTextPreference.scala
index e89b5795..d6531714 100644
--- a/src/main/scala/com/github/shadowsocks/preferences/SummaryEditTextPreference.scala
+++ b/src/main/scala/com/github/shadowsocks/preferences/SummaryEditTextPreference.scala
@@ -1,3 +1,42 @@
+/*
+ * Shadowsocks - A shadowsocks client for Android
+ * Copyright (C) 2013
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ *
+ * ___====-_ _-====___
+ * _--^^^#####// \\#####^^^--_
+ * _-^##########// ( ) \\##########^-_
+ * -############// |\^^/| \\############-
+ * _/############// (@::@) \\############\_
+ * /#############(( \\// ))#############\
+ * -###############\\ (oo) //###############-
+ * -#################\\ / VV \ //#################-
+ * -###################\\/ \//###################-
+ * _#/|##########/\######( /\ )######/\##########|\#_
+ * |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
+ * ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
+ * ` ` ` ` / | | | | \ ' ' ' '
+ * ( | | | | )
+ * __\ | | | | /__
+ * (vvv(VVV)(VVV)vvv)
+ *
+ * HERE BE DRAGONS
+ *
+ */
+
package com.github.shadowsocks.preferences
import android.content.Context
@@ -21,4 +60,4 @@ class SummaryEditTextPreference(context: Context, attrs: AttributeSet, defStyle:
}
private var mDefaultSummary: CharSequence = getSummary
-}
\ No newline at end of file
+}