add flush dns cache
This commit is contained in:
+2
-2
@@ -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 {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
<string name="about_title">Shadowsocks %s</string>
|
||||
<string name="donate">Donate</string>
|
||||
<string name="donate_address">http://buildbot.sinaapp.com/donate.html</string>
|
||||
|
||||
<string name="flush_dnscache">Flush DNS Cache</string>
|
||||
<string name="flushing">Flushing</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2012 <max.c.lv@gmail.com>
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2013 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,42 @@
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2013 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* ___====-_ _-====___
|
||||
* _--^^^#####// \\#####^^^--_
|
||||
* _-^##########// ( ) \\##########^-_
|
||||
* -############// |\^^/| \\############-
|
||||
* _/############// (@::@) \\############\_
|
||||
* /#############(( \\// ))#############\
|
||||
* -###############\\ (oo) //###############-
|
||||
* -#################\\ / VV \ //#################-
|
||||
* -###################\\/ \//###################-
|
||||
* _#/|##########/\######( /\ )######/\##########|\#_
|
||||
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
|
||||
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
|
||||
* ` ` ` ` / | | | | \ ' ' ' '
|
||||
* ( | | | | )
|
||||
* __\ | | | | /__
|
||||
* (vvv(VVV)(VVV)vvv)
|
||||
*
|
||||
* HERE BE DRAGONS
|
||||
*
|
||||
*/
|
||||
|
||||
package com.github.shadowsocks
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2012 <max.c.lv@gmail.com>
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2013 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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._
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Shadowsocks - A shadowsocks client for Android
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2012 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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 => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2012 <max.c.lv@gmail.com>
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2013 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,42 @@
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2013 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* ___====-_ _-====___
|
||||
* _--^^^#####// \\#####^^^--_
|
||||
* _-^##########// ( ) \\##########^-_
|
||||
* -############// |\^^/| \\############-
|
||||
* _/############// (@::@) \\############\_
|
||||
* /#############(( \\// ))#############\
|
||||
* -###############\\ (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}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2012 <max.c.lv@gmail.com>
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2013 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2012 <max.c.lv@gmail.com>
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2013 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Shadowsocks - A shadowsocks client for Android
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2012 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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._
|
||||
|
||||
|
||||
@@ -1,3 +1,42 @@
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2013 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* ___====-_ _-====___
|
||||
* _--^^^#####// \\#####^^^--_
|
||||
* _-^##########// ( ) \\##########^-_
|
||||
* -############// |\^^/| \\############-
|
||||
* _/############// (@::@) \\############\_
|
||||
* /#############(( \\// ))#############\
|
||||
* -###############\\ (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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,42 @@
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2013 <max.c.lv@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* ___====-_ _-====___
|
||||
* _--^^^#####// \\#####^^^--_
|
||||
* _-^##########// ( ) \\##########^-_
|
||||
* -############// |\^^/| \\############-
|
||||
* _/############// (@::@) \\############\_
|
||||
* /#############(( \\// ))#############\
|
||||
* -###############\\ (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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user