Compare commits

..
34 Commits
Author SHA1 Message Date
Max Lv 80fdc07bdd Fix #968 2016-11-12 10:24:47 +08:00
Mygod 5ca3a8e9fd Suppress NewApi in lint.xml 2016-11-11 17:58:05 +08:00
Mygod f3a458161a Remove useless components in ads 2016-11-11 11:30:16 +08:00
Mygod e067c6fae2 Update dependency 2016-11-11 11:15:41 +08:00
Mygod f48ad61220 Refine #964 2016-11-04 14:02:44 +08:00
Max Lv 27f9992447 Fix #964 2016-11-04 13:59:06 +08:00
Mygod 546a5d010d Refine design for preference package 2016-11-03 21:20:04 +08:00
Mygod cbb839ec11 Fix up navigation 2016-11-03 20:50:53 +08:00
Mygod 179e5456f8 Refine shortcuts on Android 7.1 2016-11-03 19:18:25 +08:00
Mygod 30700facd3 Remove unused private_route 2016-11-01 13:10:35 +08:00
Max Lv 82103d286d Fix #961 2016-10-31 09:26:13 +08:00
Mygod a9ca3c049d Revert "Revert "Refine Travis rules""
This reverts commit d0b4819dc5.
2016-10-25 20:16:23 +08:00
Mygod 0433704d87 Revert "Force to update Android SDK"
This reverts commit c1dd21e0c3.
2016-10-25 20:16:12 +08:00
Max Lv 2f23462c84 Fix the build 2016-10-25 13:11:38 +08:00
Max Lv c1dd21e0c3 Force to update Android SDK 2016-10-25 12:50:42 +08:00
Max Lv d0b4819dc5 Revert "Refine Travis rules"
This reverts commit 0fdbd19bff.
2016-10-25 12:19:00 +08:00
Mygod d99757f1a3 Fix a deprecation in build.sbt 2016-10-24 16:44:26 +08:00
Mygod 8ed71d1707 Add quick switch to shortcuts 2016-10-24 16:04:34 +08:00
Mygod ffdb6f84e3 Refine shortcuts.xml 2016-10-24 15:49:27 +08:00
Mygod 094b307254 Add taskAffinity to invisible activities 2016-10-24 15:40:57 +08:00
Mygod bd5fff100d Update proguard 2016-10-24 15:27:04 +08:00
Mygod 479e697e6d Experimental support for demo users
TODO: Untested code. Need to find out how to activate demo users.

Fix #950 nevertheless.
2016-10-23 15:39:06 +08:00
Mygod e98dadf0a2 Fix a minor UI issue 2016-10-23 14:35:33 +08:00
Mygod 4cfab40ec2 Fix wrong activity launched when long pressing QS tile 2016-10-23 14:32:57 +08:00
Mygod 0fdbd19bff Refine Travis rules 2016-10-23 14:30:16 +08:00
Mygod 913ec3c06b Fix #949 2016-10-23 14:29:26 +08:00
Mygod 617c6dac1b Fix crashing on Android 6.0+ 2016-10-23 14:22:02 +08:00
Mygod 244c2ecdfd Add quick toggle shortcut (#950)
Mainly for Android 7.1, also backward compatible.
2016-10-23 14:16:56 +08:00
Mygod 54c696d00a Merge branch 'master' of github.com:shadowsocks/shadowsocks-android 2016-10-23 13:13:44 +08:00
Mygod c4d9edc224 Recreate round launcher icon with Android Studio (#950)
The icon was created using shadow.png.
2016-10-23 13:12:32 +08:00
Max Lv 7a7cbf5803 Update travis-ci 2016-10-23 12:07:04 +08:00
Max Lv f53936421d Fix #951 2016-10-23 11:54:39 +08:00
Mygod 5ef2849c4a Update build target to Android 7.1 Developer Preview 2016-10-23 00:30:20 +08:00
Mygod e1f58bfd0c Update dependencies
Disabling `android:extractNativeLib` will reduce apk install size and reduce install time.
2016-10-23 00:24:59 +08:00
52 changed files with 252 additions and 207 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ cache:
android:
components:
- tools
- build-tools-24.0.3
- build-tools-25.0.0
- extra-android-m2repository
- extra-google-m2repository
+1 -2
View File
@@ -14,7 +14,7 @@ A [shadowsocks](http://shadowsocks.org) client for Android, written in Scala.
* SBT 0.13.0+
* Go 1.4+
* Android SDK
- Build Tools 24+ (as required by [`sbt-android`](https://github.com/scala-android/sbt-android))
- Build Tools 25+
- Android Support Repository and Google Repository (see `build.sbt` for version)
* Android NDK r12b+
@@ -24,7 +24,6 @@ A [shadowsocks](http://shadowsocks.org) client for Android, written in Scala.
* Set environment variable `ANDROID_NDK_HOME` to `/path/to/android-ndk`
* Set environment variable `GOROOT_BOOTSTRAP` to `/path/to/go`
* Create your key following the instructions at https://developer.android.com/studio/publish/app-signing.html
* Put your key in ~/.keystore
* Create `local.properties` from `local.properties.example` with your own key information
* Invoke the building like this
+14 -14
View File
@@ -2,13 +2,13 @@ scalaVersion := "2.11.8"
dexMaxHeap := "4g"
enablePlugins(AndroidApp)
useSupportVectors
android.useSupportVectors
name := "shadowsocks"
version := "3.2.7"
versionCode := Some(167)
platformTarget := "android-24"
platformTarget := "android-25"
compileOrder := CompileOrder.JavaThenScala
javacOptions ++= "-source" :: "1.7" :: "-target" :: "1.7" :: Nil
@@ -16,14 +16,14 @@ scalacOptions ++= "-target:jvm-1.7" :: "-Xexperimental" :: Nil
ndkJavah := Seq()
ndkBuild := Seq()
proguardVersion := "5.3"
proguardVersion := "5.3.1"
proguardCache := Seq()
proguardOptions ++=
"-keep class com.github.shadowsocks.System { *; }" ::
"-dontwarn com.google.android.gms.internal.**" ::
"-dontwarn com.j256.ormlite.**" ::
"-dontwarn org.xbill.**" ::
Nil
"-dontwarn com.google.android.gms.internal.**" ::
"-dontwarn com.j256.ormlite.**" ::
"-dontwarn org.xbill.**" ::
Nil
shrinkResources := true
typedResources := false
@@ -31,16 +31,16 @@ resConfigs := Seq("ru", "zh-rCN", "zh-rTW")
resolvers += Resolver.jcenterRepo
libraryDependencies ++=
"com.android.support" % "design" % "24.2.1" ::
"com.android.support" % "gridlayout-v7" % "24.2.1" ::
"com.android.support" % "preference-v14" % "24.2.1" ::
"com.evernote" % "android-job" % "1.1.0" ::
"com.android.support" % "design" % "25.0.0" ::
"com.android.support" % "gridlayout-v7" % "25.0.0" ::
"com.android.support" % "preference-v14" % "25.0.0" ::
"com.evernote" % "android-job" % "1.1.3" ::
"com.github.clans" % "fab" % "1.6.4" ::
"com.github.jorgecastilloprz" % "fabprogresscircle" % "1.01" ::
"com.github.kevinsawicki" % "http-request" % "6.0" ::
"com.google.android.gms" % "play-services-ads" % "9.6.1" ::
"com.google.android.gms" % "play-services-analytics" % "9.6.1" ::
"com.google.android.gms" % "play-services-gcm" % "9.6.1" ::
"com.google.android.gms" % "play-services-ads" % "9.8.0" ::
"com.google.android.gms" % "play-services-analytics" % "9.8.0" ::
"com.google.android.gms" % "play-services-gcm" % "9.8.0" ::
"com.j256.ormlite" % "ormlite-android" % "5.0" ::
"com.twofortyfouram" % "android-plugin-api-for-locale" % "1.0.2" ::
"dnsjava" % "dnsjava" % "2.1.7" ::
+3
View File
@@ -0,0 +1,3 @@
<issue id="NewApi">
<ignore path="src/main/res/drawable"/>
</issue>
+1 -1
View File
@@ -1,4 +1,4 @@
addSbtPlugin("org.scala-android" % "sbt-android" % "1.7.0")
addSbtPlugin("org.scala-android" % "sbt-android" % "1.7.1")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10")
+26 -9
View File
@@ -18,13 +18,15 @@
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="24"/>
android:targetSdkVersion="25"/>
<application
android:allowBackup="true"
android:extractNativeLibs="false"
android:name=".ShadowsocksApplication"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:backupAgent=".ShadowsocksBackupAgent"
android:label="@string/app_name"
android:theme="@style/Theme.Material"
@@ -35,10 +37,6 @@
<meta-data android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAI_zVxZthz2HDuz9toTvkYvL0L5GA-OjeUIfBeXg"/>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<activity
android:name=".Shadowsocks"
android:label="@string/app_name"
@@ -49,14 +47,17 @@
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts"/>
</activity>
<activity
android:name=".ShadowsocksRunnerActivity"
android:theme="@android:style/Theme.NoDisplay"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:excludeFromRecents="true"
android:taskAffinity=""
android:launchMode="singleTask">
</activity>
@@ -97,13 +98,14 @@
android:launchMode="singleTask"/>
<activity android:name=".TaskerActivity"
android:icon="@drawable/ic_launcher">
android:icon="@mipmap/ic_launcher">
<intent-filter>
<action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING" />
</intent-filter>
</activity>
<activity android:name=".ShadowsocksQuickSwitchActivity"
android:label="@string/quick_switch"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
android:taskAffinity=""
@@ -114,6 +116,18 @@
</intent-filter>
</activity>
<activity
android:name=".QuickToggleShortcut"
android:label="@string/quick_toggle"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:excludeFromRecents="true"
android:taskAffinity=""
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
</intent-filter>
</activity>
<service
android:name=".ShadowsocksRunnerService"
android:exported="false">
@@ -168,6 +182,9 @@
android:process=":bg"/>
<receiver android:name="com.evernote.android.job.JobBootReceiver"
android:process=":bg"/>
<!-- Strip useless components -->
<activity android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity" tools:node="remove"/>
</application>
</manifest>
+1 -20
View File
@@ -4756,26 +4756,7 @@
(.*\.)?gmail\.com
(.*\.)?gmodules\.com
(.*\.)?goo\.gl
(.*\.)?google\.ae
(.*\.)?google\.am
(.*\.)?google\.cat
(.*\.)?google\.cd
(.*\.)?google\.ci
(.*\.)?google\.co\.kr
(.*\.)?google\.co\.ma
(.*\.)?google\.com
(.*\.)?google\.dk
(.*\.)?google\.es
(.*\.)?google\.fi
(.*\.)?google\.gg
(.*\.)?google\.ie
(.*\.)?google\.is
(.*\.)?google\.it
(.*\.)?google\.nl
(.*\.)?google\.no
(.*\.)?google\.sk
(.*\.)?google\.sm
(.*\.)?google\.tk
(.*\.)?google(\..*)?
(.*\.)?googleapis\.com
(.*\.)?googleapps\.com
(.*\.)?googleartproject\.com
+1 -20
View File
@@ -4770,26 +4770,7 @@
(.*\.)?gmail\.com
(.*\.)?gmodules\.com
(.*\.)?goo\.gl
(.*\.)?google\.ae
(.*\.)?google\.am
(.*\.)?google\.cat
(.*\.)?google\.cd
(.*\.)?google\.ci
(.*\.)?google\.co\.kr
(.*\.)?google\.co\.ma
(.*\.)?google\.com
(.*\.)?google\.dk
(.*\.)?google\.es
(.*\.)?google\.fi
(.*\.)?google\.gg
(.*\.)?google\.ie
(.*\.)?google\.is
(.*\.)?google\.it
(.*\.)?google\.nl
(.*\.)?google\.no
(.*\.)?google\.sk
(.*\.)?google\.sm
(.*\.)?google\.tk
(.*\.)?google(\..*)?
(.*\.)?googleapis\.com
(.*\.)?googleapps\.com
(.*\.)?googleartproject\.com
+1 -20
View File
@@ -338,26 +338,7 @@
(.*\.)?gmail\.com
(.*\.)?gmodules\.com
(.*\.)?goo\.gl
(.*\.)?google\.ae
(.*\.)?google\.am
(.*\.)?google\.cat
(.*\.)?google\.cd
(.*\.)?google\.ci
(.*\.)?google\.co\.kr
(.*\.)?google\.co\.ma
(.*\.)?google\.com
(.*\.)?google\.dk
(.*\.)?google\.es
(.*\.)?google\.fi
(.*\.)?google\.gg
(.*\.)?google\.ie
(.*\.)?google\.is
(.*\.)?google\.it
(.*\.)?google\.nl
(.*\.)?google\.no
(.*\.)?google\.sk
(.*\.)?google\.sm
(.*\.)?google\.tk
(.*\.)?google(\..*)?
(.*\.)?googleapis\.com
(.*\.)?googleapps\.com
(.*\.)?googleartproject\.com
Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#f5f5f5"
android:pathData="M24,24m-22,0a22,22 0,1 1,44 0a22,22 0,1 1,-44 0Z" />
<path
android:fillColor="#546e7a"
android:pathData="M24,21.8 C25.7673,21.8,27.2,23.2327,27.2,25 C27.2,26.7673,25.7673,28.2,24,28.2
C22.2327,28.2,20.8,26.7673,20.8,25 C20.8,23.2327,22.2327,21.8,24,21.8 Z" />
<path
android:fillColor="#546e7a"
android:pathData="M21,15 L19.17,17 L16,17 A2,2,0,0,0,14,19 L14,31 A2,2,0,0,0,16,33 L32,33
A2,2,0,0,0,34,31 L34,19 A2,2,0,0,0,32,17 L28.83,17 L27,15 Z M24,30
A5,5,0,1,1,29,25 A5,5,0,0,1,24,30 Z" />
</vector>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#f5f5f5"
android:pathData="M24,24m-22,0a22,22 0,1 1,44 0a22,22 0,1 1,-44 0Z" />
<path
android:fillColor="#546e7a"
android:pathData="M34,14.72 L30.52,30.04 L22.72,27.53 L29.61,19.31 L20.43,27.04 L14,24.62
L34,14.72 Z" />
<path
android:fillColor="#546e7a"
android:pathData="M22.89,29.1 L25.38,29.9 L22.9,33.28 L22.89,29.1 Z" />
</vector>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@@ -1,4 +1,3 @@
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
-1
View File
@@ -1,4 +1,3 @@
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
@@ -1,4 +1,3 @@
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
@@ -1,4 +1,3 @@
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
@@ -1,4 +1,3 @@
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
-1
View File
@@ -1,4 +1,3 @@
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
-10
View File
@@ -1,10 +0,0 @@
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M18,7l-1.41,-1.41 -6.34,6.34 1.41,1.41L18,7zM22.24,5.59L11.66,16.17 7.48,12l-1.41,1.41L11.66,19l12,-12 -1.42,-1.41zM0.41,13.41L6,19l1.41,-1.41L1.83,12 0.41,13.41z"/>
</vector>
@@ -1,4 +1,3 @@
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
@@ -1,4 +1,3 @@
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
-2
View File
@@ -1,5 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
@@ -1,5 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
-2
View File
@@ -1,5 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!--suppress NewApi -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
+8 -11
View File
@@ -1,15 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar_light_dark" />
</FrameLayout>
<me.dm7.barcodescanner.zxing.ZXingScannerView android:id="@+id/scanner"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
+1 -2
View File
@@ -2,10 +2,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_apply_all"
android:title="@string/action_apply_all"
android:icon="@drawable/ic_done_all"
android:alphabeticShortcut="a"
android:numericShortcut="1"
app:showAsAction="always"/>
app:showAsAction="never"/>
<item android:id="@+id/action_export"
android:title="@string/action_export"
android:icon="@drawable/ic_content_copy"
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

-17
View File
@@ -47,23 +47,6 @@
<item>china-list</item>
</string-array>
<string-array name="private_route">
<item>0.0.0.0/8</item>
<item>10.0.0.0/8</item>
<item>100.64.0.0/10</item>
<item>127.0.0.0/8</item>
<item>169.254.0.0/16</item>
<item>172.16.0.0/12</item>
<item>192.0.0.0/29</item>
<item>192.0.2.0/24</item>
<item>192.88.99.0/24</item>
<item>192.168.0.0/16</item>
<item>198.18.0.0/15</item>
<item>198.51.100.0/24</item>
<item>203.0.113.0/24</item>
<item>224.0.0.0/3</item>
</string-array>
<string-array name="bypass_private_route">
<item>1.0.0.0/8</item>
<item>2.0.0.0/7</item>
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="black_list" translatable="false">".appspot.com",".blogspot.com",".blogspot.kr",".blogspot.sg",".cdninstagram.com",".connect.facebook.net",".facebook.br",".facebook.com",".facebook.hu",".facebook.nl",".facebook.se",".fbcdn.net",".google.co.kr",".google.com",".google.com",".google.com.hk",".google.com.sg",".google.com.tw",".googleapis.com",".googleapps.com",".googleartproject.com",".googleblog.com",".googlecode.com",".googlecommerce.com",".googledomains.com",".googledrive.com",".googleearth.com",".googlegroups.com",".googlehosted.com",".googleideas.com",".googlelabs.com",".googlemail.com",".googleplay.com",".googleplus.com",".googlesile.com",".googlesource.com",".googleusercontent.com",".googlevideo.com",".googlezip.net",".gstatic.com",".yahoo.com",".igoogle.com",".instagram.com",".institut-tibetain.org",".nic.google",".registry.google",".thinkwithgoogle.com",".withgoogle.com",".youtube-nocookie.com",".youtube.com",".gvt1.com",".gvt2.com",".gvt3.com",".1e100.net"</string>
<string name="black_list" translatable="false">".appspot.com",".blogspot.com",".blogspot.kr",".blogspot.sg",".cdninstagram.com",".connect.facebook.net",".facebook.br",".facebook.com",".facebook.hu",".facebook.nl",".facebook.se",".fbcdn.net",".google.co.jp",".google.co.kr",".google.com",".google.com",".google.com.hk",".google.com.sg",".google.com.tw",".googleapis.com",".googleapps.com",".googleartproject.com",".googleblog.com",".googlecode.com",".googlecommerce.com",".googledomains.com",".googledrive.com",".googleearth.com",".googlegroups.com",".googlehosted.com",".googleideas.com",".googlelabs.com",".googlemail.com",".googleplay.com",".googleplus.com",".googlesile.com",".googlesource.com",".googleusercontent.com",".googlevideo.com",".googlezip.net",".gstatic.com",".yahoo.com",".igoogle.com",".instagram.com",".institut-tibetain.org",".nic.google",".registry.google",".thinkwithgoogle.com",".withgoogle.com",".youtube-nocookie.com",".youtube.com",".gvt1.com",".gvt2.com",".gvt3.com",".1e100.net"</string>
</resources>
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut android:shortcutId="toggle"
android:icon="@drawable/ic_qu_shadowsocks_launcher"
android:shortcutShortLabel="@string/quick_toggle"
android:shortcutLongLabel="@string/quick_toggle">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.github.shadowsocks"
android:targetClass="com.github.shadowsocks.QuickToggleShortcut" />
</shortcut>
<shortcut android:shortcutId="switch"
android:icon="@drawable/ic_qu_shadowsocks_launcher"
android:shortcutShortLabel="@string/quick_switch"
android:shortcutLongLabel="@string/quick_switch">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.github.shadowsocks"
android:targetClass="com.github.shadowsocks.ShadowsocksQuickSwitchActivity" />
</shortcut>
<shortcut android:shortcutId="scan"
android:icon="@drawable/ic_qu_camera_launcher"
android:shortcutShortLabel="@string/add_profile_methods_scan_qr_code"
android:shortcutLongLabel="@string/add_profile_methods_scan_qr_code">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.github.shadowsocks"
android:targetClass="com.github.shadowsocks.ScannerActivity" />
</shortcut>
</shortcuts>
@@ -0,0 +1,8 @@
package be.mygod.preference
import android.app.DialogFragment
import android.support.v7.preference.DialogPreference
trait DialogPreferencePlus extends DialogPreference {
def createDialog(): DialogFragment
}
@@ -11,10 +11,12 @@ import android.util.AttributeSet
* Based on: https://github.com/Gericop/Android-Support-Preference-V7-Fix/tree/master/app/src/main/java/android/support/v7/preference
*/
class EditTextPreference(context: Context, attrs: AttributeSet = null) extends Parent(context, attrs)
with SummaryPreference {
with DialogPreferencePlus with SummaryPreference {
val editText = new AppCompatEditText(context, attrs)
editText.setId(android.R.id.edit)
override def createDialog() = new EditTextPreferenceDialogFragment()
override protected def getSummaryValue = {
var text = getText
if (text == null) text = ""
@@ -9,7 +9,7 @@ import android.widget.NumberPicker
import com.github.shadowsocks.R
class NumberPickerPreference(private val context: Context, attrs: AttributeSet = null)
extends DialogPreference(context, attrs) with SummaryPreference {
extends DialogPreference(context, attrs) with DialogPreferencePlus with SummaryPreference {
private[preference] val picker = new NumberPicker(new ContextThemeWrapper(context, R.style.NumberPickerStyle))
private var value: Int = _
@@ -20,6 +20,8 @@ class NumberPickerPreference(private val context: Context, attrs: AttributeSet =
a.recycle
}
override def createDialog() = new NumberPickerPreferenceDialogFragment()
def getValue = value
def getMin = if (picker == null) 0 else picker.getMinValue
def getMax = picker.getMaxValue
@@ -3,7 +3,7 @@ package be.mygod.preference
import android.app.DialogFragment
import android.os.Bundle
import android.support.v14.preference.{PreferenceFragment => Base}
import android.support.v7.preference.PreferenceScreen
import android.support.v7.preference.{Preference, PreferenceScreen}
import android.view.{LayoutInflater, ViewGroup}
abstract class PreferenceFragment extends Base {
@@ -20,6 +20,11 @@ abstract class PreferenceFragment extends Base {
.commitAllowingStateLoss()
}
override def onDisplayPreferenceDialog(preference: Preference) = preference match {
case dpp: DialogPreferencePlus => displayPreferenceDialog(preference.getKey, dpp.createDialog())
case _ => super.onDisplayPreferenceDialog(preference)
}
override protected def onCreateAdapter(screen: PreferenceScreen) = new PreferenceGroupAdapter(screen)
override def onResume {
@@ -42,6 +42,7 @@ package com.github.shadowsocks
import java.util.concurrent.atomic.AtomicBoolean
import android.Manifest.permission
import android.app.TaskStackBuilder
import android.content._
import android.content.pm.PackageManager
import android.graphics.drawable.Drawable
@@ -220,9 +221,11 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
toolbar = findViewById(R.id.toolbar).asInstanceOf[Toolbar]
toolbar.setTitle(R.string.proxied_apps)
toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material)
toolbar.setNavigationOnClickListener((v: View) => {
toolbar.setNavigationOnClickListener(_ => {
val intent = getParentActivityIntent
if (intent == null) finish else navigateUpTo(intent)
if (shouldUpRecreateTask(intent) || isTaskRoot)
TaskStackBuilder.create(this).addNextIntentWithParentStack(intent).startActivities()
else finish()
})
toolbar.inflateMenu(R.menu.app_manager_menu)
toolbar.setOnMenuItemClickListener(this)
@@ -2,12 +2,12 @@ package com.github.shadowsocks
import java.nio.charset.Charset
import android.app.Activity
import android.app.{Activity, TaskStackBuilder}
import android.content._
import android.content.pm.PackageManager
import android.nfc.NfcAdapter.CreateNdefMessageCallback
import android.nfc.{NdefMessage, NdefRecord, NfcAdapter, NfcEvent}
import android.os.{Bundle, Handler}
import android.os.{Build, Bundle, Handler, UserManager}
import android.provider.Settings
import android.support.v7.app.{AlertDialog, AppCompatActivity}
import android.support.v7.widget.RecyclerView.ViewHolder
@@ -86,7 +86,7 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
val builder = new SpannableStringBuilder
val tx = item.tx + txTotal
val rx = item.rx + rxTotal
builder.append(item.name)
builder.append(if (isDemoMode) "Profile #" + item.id else item.name)
if (tx != 0 || rx != 0) {
val start = builder.length
builder.append(getString(R.string.stat_profiles,
@@ -186,6 +186,7 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
private var undoManager: UndoSnackbarManager[Profile] = _
private lazy val clipboard = getSystemService(Context.CLIPBOARD_SERVICE).asInstanceOf[ClipboardManager]
private lazy val isDemoMode = Build.VERSION.SDK_INT >= 25 && getSystemService(classOf[UserManager]).isDemoUser
private var nfcAdapter : NfcAdapter = _
private var nfcShareItem: Array[Byte] = _
@@ -202,9 +203,11 @@ final class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClic
val toolbar = findViewById(R.id.toolbar).asInstanceOf[Toolbar]
toolbar.setTitle(R.string.profiles)
toolbar.setNavigationIcon(R.drawable.ic_navigation_close)
toolbar.setNavigationOnClickListener((v: View) => {
toolbar.setNavigationOnClickListener(_ => {
val intent = getParentActivityIntent
if (intent == null) finish else navigateUpTo(intent)
if (shouldUpRecreateTask(intent) || isTaskRoot)
TaskStackBuilder.create(this).addNextIntentWithParentStack(intent).startActivities()
else finish()
})
toolbar.inflateMenu(R.menu.profile_manager_menu)
toolbar.setOnMenuItemClickListener(this)
@@ -0,0 +1,42 @@
package com.github.shadowsocks
import android.app.Activity
import android.content.Intent
import android.content.pm.ShortcutManager
import android.os.{Build, Bundle}
import com.github.shadowsocks.utils.{State, Utils}
/**
* @author Mygod
*/
class QuickToggleShortcut extends Activity with ServiceBoundContext {
override def onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
getIntent.getAction match {
case Intent.ACTION_CREATE_SHORTCUT =>
setResult(Activity.RESULT_OK, new Intent()
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this, classOf[QuickToggleShortcut]))
.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.quick_toggle))
.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher)))
finish()
case _ =>
attachService()
if (Build.VERSION.SDK_INT >= 25) getSystemService(classOf[ShortcutManager]).reportShortcutUsed("toggle")
}
}
override def onDestroy() {
detachService()
super.onDestroy()
}
override def onServiceConnected() {
bgService.getState match {
case State.STOPPED => Utils.startSsService(this)
case State.CONNECTED => Utils.stopSsService(this)
case _ => // ignore
}
finish()
}
}
@@ -1,23 +1,25 @@
package com.github.shadowsocks
import android.app.Activity
import android.app.{Activity, TaskStackBuilder}
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.content.pm.{PackageManager, ShortcutManager}
import android.os.{Build, Bundle}
import android.support.v4.app.ActivityCompat
import android.support.v4.content.ContextCompat
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
import android.view.{MenuItem, ViewGroup}
import android.widget.Toast
import com.google.zxing.Result
import me.dm7.barcodescanner.zxing.ZXingScannerView
object ScannerActivity {
private final val MY_PERMISSIONS_REQUEST_CAMERA = 1
}
class ScannerActivity extends AppCompatActivity with ZXingScannerView.ResultHandler {
import ScannerActivity._
val MY_PERMISSIONS_REQUEST_CAMERA = 1
var scannerView: ZXingScannerView = _
private var scannerView: ZXingScannerView = _
override def onRequestPermissionsResult(requestCode: Int, permissions: Array[String],
grantResults: Array[Int]) {
@@ -34,14 +36,22 @@ class ScannerActivity extends AppCompatActivity with ZXingScannerView.ResultHand
}
}
def navigateUp() {
val intent = getParentActivityIntent
if (shouldUpRecreateTask(intent) || isTaskRoot)
TaskStackBuilder.create(this).addNextIntentWithParentStack(intent).startActivities()
else finish()
}
override def onCreate(state: Bundle) {
super.onCreate(state)
setContentView(R.layout.layout_scanner)
setupToolbar()
scannerView = new ZXingScannerView(this)
val contentFrame = findViewById(R.id.content_frame).asInstanceOf[ViewGroup]
contentFrame.addView(scannerView)
val toolbar = findViewById(R.id.toolbar).asInstanceOf[Toolbar]
toolbar.setTitle(getTitle)
toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material)
toolbar.setNavigationOnClickListener(_ => navigateUp())
scannerView = findViewById(R.id.scanner).asInstanceOf[ZXingScannerView]
if (Build.VERSION.SDK_INT >= 25) getSystemService(classOf[ShortcutManager]).reportShortcutUsed("scan")
}
override def onResume() {
@@ -66,29 +76,7 @@ class ScannerActivity extends AppCompatActivity with ZXingScannerView.ResultHand
val intent = new Intent()
intent.putExtra("uri", rawResult.getText)
setResult(Activity.RESULT_OK, intent)
finish()
navigateUp()
}
def setupToolbar() {
val toolbar = findViewById(R.id.toolbar).asInstanceOf[Toolbar]
setSupportActionBar(toolbar)
val ab = getSupportActionBar()
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true)
}
}
override def onOptionsItemSelected(item: MenuItem): Boolean = {
item.getItemId() match {
// Respond to the action bar's Up/Home button
case android.R.id.home =>
setResult(Activity.RESULT_CANCELED, new Intent())
finish()
return true
case _ => // Do nothing
}
return super.onOptionsItemSelected(item)
}
}
@@ -352,10 +352,11 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
preferences.setEnabled(false)
fabProgressCircle.postDelayed(hideCircle, 100)
stat.setVisibility(View.VISIBLE)
if (resetConnectionTest) if (app.isNatEnabled) connectionTestText.setVisibility(View.GONE) else {
connectionTestText.setVisibility(View.VISIBLE)
connectionTestText.setText(getString(R.string.connection_test_pending))
}
if (resetConnectionTest || state != State.CONNECTED)
if (app.isNatEnabled) connectionTestText.setVisibility(View.GONE) else {
connectionTestText.setVisibility(View.VISIBLE)
connectionTestText.setText(getString(R.string.connection_test_pending))
}
case State.STOPPING =>
fab.setBackgroundTintList(greyTint)
serviceStarted = false
@@ -332,7 +332,8 @@ class ShadowsocksNatService extends BaseService {
handleConnection()
AclSyncJob.schedule(profile.route)
if (profile.route != Route.ALL)
AclSyncJob.schedule(profile.route)
changeState(State.CONNECTED)
notification = new ShadowsocksNotification(this, profile.name, true)
@@ -1,5 +1,6 @@
package com.github.shadowsocks
import android.content.pm.ShortcutManager
import android.content.res.Resources
import android.os.{Build, Bundle}
import android.support.v7.app.AppCompatActivity
@@ -70,5 +71,6 @@ class ShadowsocksQuickSwitchActivity extends AppCompatActivity {
if (app.profileId >= 0) lm.scrollToPosition(profilesAdapter.profiles.zipWithIndex.collectFirst {
case (profile, i) if profile.id == app.profileId => i
}.getOrElse(0))
if (Build.VERSION.SDK_INT >= 25) getSystemService(classOf[ShortcutManager]).reportShortcutUsed("switch")
}
}
@@ -5,7 +5,7 @@ import java.util.Locale
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.content.{Intent, SharedPreferences}
import android.net.Uri
import android.os.Bundle
import android.os.{Build, Bundle, UserManager}
import android.support.design.widget.Snackbar
import android.support.v14.preference.SwitchPreference
import android.support.v7.app.AlertDialog
@@ -41,13 +41,21 @@ object ShadowsocksSettings {
pref.asInstanceOf[SwitchPreference].setChecked(value)
}
def updatePreference(pref: Preference, name: String, profile: Profile) {
def updatePreference(pref: Preference, name: String, profile: Profile, demo: Boolean = false) {
name match {
case Key.name => updateEditTextPreference(pref, profile.name)
case Key.host => updateEditTextPreference(pref, profile.host)
case Key.remotePort => updateNumberPickerPreference(pref, profile.remotePort)
case Key.name =>
updateEditTextPreference(pref, profile.name)
pref.setSummary(if (demo) "Profile #" + profile.id else "%s")
case Key.host =>
updateEditTextPreference(pref, profile.host)
pref.setSummary(if (demo) "shadowsocks.example.org" else "%s")
case Key.remotePort =>
updateNumberPickerPreference(pref, profile.remotePort)
pref.setSummary(if (demo) "1337" else "%d")
case Key.localPort => updateNumberPickerPreference(pref, profile.localPort)
case Key.password => updateEditTextPreference(pref, profile.password)
case Key.password =>
updateEditTextPreference(pref, profile.password)
pref.setSummary(if (demo) "\u2022" * 32 else "%s")
case Key.method => updateDropDownPreference(pref, profile.method)
case Key.route => updateDropDownPreference(pref, profile.route)
case Key.proxyApps => updateSwitchPreference(pref, profile.proxyApps)
@@ -195,12 +203,8 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
})
}
override def onDisplayPreferenceDialog(preference: Preference) = preference match {
case _: EditTextPreference => displayPreferenceDialog(preference.getKey,
if (preference.getKey == Key.kcpcli) new KcpCliPreferenceDialogFragment()
else new EditTextPreferenceDialogFragment())
case _: NumberPickerPreference =>
displayPreferenceDialog(preference.getKey, new NumberPickerPreferenceDialogFragment())
override def onDisplayPreferenceDialog(preference: Preference) = preference.getKey match {
case Key.kcpcli => displayPreferenceDialog(Key.kcpcli, new KcpCliPreferenceDialogFragment())
case _ => super.onDisplayPreferenceDialog(preference)
}
@@ -248,6 +252,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
var profile: Profile = _
def setProfile(profile: Profile) {
this.profile = profile
for (name <- Array(PROXY_PREFS, FEATURE_PREFS).flatten) updatePreference(findPreference(name), name, profile)
val demo = Build.VERSION.SDK_INT >= 25 && activity.getSystemService(classOf[UserManager]).isDemoUser
for (name <- Array(PROXY_PREFS, FEATURE_PREFS).flatten) updatePreference(findPreference(name), name, profile, demo)
}
}
@@ -164,7 +164,8 @@ class ShadowsocksVpnService extends VpnService with BaseService {
handleConnection()
changeState(State.CONNECTED)
AclSyncJob.schedule(profile.route)
if (profile.route != Route.ALL)
AclSyncJob.schedule(profile.route)
notification = new ShadowsocksNotification(this, profile.name)
}