Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
3d998a32
Commit
3d998a32
authored
Nov 30, 2015
by
CzBiX
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automation app integration
parent
1de3a449
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
307 additions
and
14 deletions
+307
-14
build.sbt
build.sbt
+2
-1
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+13
-0
src/main/res/layout/layout_tasker.xml
src/main/res/layout/layout_tasker.xml
+30
-0
src/main/res/values-zh/strings.xml
src/main/res/values-zh/strings.xml
+2
-0
src/main/res/values/strings.xml
src/main/res/values/strings.xml
+6
-0
src/main/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
...in/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
+2
-12
src/main/scala/com/github/shadowsocks/TaskerActivity.scala
src/main/scala/com/github/shadowsocks/TaskerActivity.scala
+97
-0
src/main/scala/com/github/shadowsocks/TaskerReceiver.scala
src/main/scala/com/github/shadowsocks/TaskerReceiver.scala
+58
-0
src/main/scala/com/github/shadowsocks/helper/TaskerSettings.scala
.../scala/com/github/shadowsocks/helper/TaskerSettings.scala
+77
-0
src/main/scala/com/github/shadowsocks/utils/Utils.scala
src/main/scala/com/github/shadowsocks/utils/Utils.scala
+20
-1
No files found.
build.sbt
View file @
3d998a32
...
...
@@ -39,7 +39,8 @@ libraryDependencies ++= Seq(
"com.android.support"
%
"design"
%
"23.1.1"
,
"com.github.jorgecastilloprz"
%
"fabprogresscircle"
%
"1.01"
,
"com.j256.ormlite"
%
"ormlite-core"
%
"4.48"
,
"com.j256.ormlite"
%
"ormlite-android"
%
"4.48"
"com.j256.ormlite"
%
"ormlite-android"
%
"4.48"
,
"com.twofortyfouram"
%
"android-plugin-api-for-locale"
%
"1.0.2"
)
proguardOptions
in
Android
++=
Seq
(
"-keep class com.github.shadowsocks.** { <init>(...); }"
,
...
...
src/main/AndroidManifest.xml
View file @
3d998a32
...
...
@@ -80,6 +80,14 @@
android:parentActivityName=
".Shadowsocks"
android:launchMode=
"singleTask"
/>
<activity
android:name=
".TaskerActivity"
android:icon=
"@drawable/ic_launcher"
android:launchMode=
"singleTask"
>
<intent-filter>
<action
android:name=
"com.twofortyfouram.locale.intent.action.EDIT_SETTING"
/>
</intent-filter>
</activity>
<service
android:name=
".ShadowsocksRunnerService"
android:exported=
"false"
>
...
...
@@ -109,6 +117,11 @@
</intent-filter>
</receiver>
<receiver
android:name=
".TaskerReceiver"
>
<intent-filter>
<action
android:name=
"com.twofortyfouram.locale.intent.action.FIRE_SETTING"
/>
</intent-filter>
</receiver>
</application>
</manifest>
src/main/res/layout/layout_tasker.xml
0 → 100644
View file @
3d998a32
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<include
layout=
"@layout/toolbar_light_dark"
/>
<RelativeLayout
android:padding=
"16dp"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<Switch
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/toggle_service_state"
android:id=
"@+id/service_switch"
android:layout_centerHorizontal=
"true"
/>
<Button
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/save"
android:textColor=
"@android:color/white"
android:id=
"@+id/btn_save"
android:layout_alignParentBottom=
"true"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
android:layout_alignParentRight=
"true"
android:layout_alignParentEnd=
"true"
/>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
src/main/res/values-zh/strings.xml
View file @
3d998a32
...
...
@@ -97,5 +97,7 @@
<string
name=
"removed"
>
已删除
</string>
<string
name=
"undo"
>
撤销
</string>
<string
name=
"toggle_service_state"
>
切换服务状态
</string>
<string
name=
"save"
>
保存
</string>
</resources>
src/main/res/values/strings.xml
View file @
3d998a32
...
...
@@ -102,4 +102,10 @@
<string
name=
"removed"
>
Removed
</string>
<string
name=
"undo"
>
Undo
</string>
<!-- tasker -->
<string
name=
"toggle_service_state"
>
Toggle service state
</string>
<string
name=
"save"
>
Save
</string>
<string
name=
"turn_service_state"
>
Turn service %s
</string>
<string
name=
"state_on"
>
On
</string>
<string
name=
"state_off"
>
Off
</string>
</resources>
src/main/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
View file @
3d998a32
...
...
@@ -47,18 +47,8 @@ class ShadowsocksReceiver extends BroadcastReceiver {
val
TAG
=
"Shadowsocks"
def
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
val
isAutoConnect
:
Boolean
=
ShadowsocksApplication
.
settings
.
getBoolean
(
Key
.
isAutoConnect
,
false
)
val
isInstalled
:
Boolean
=
ShadowsocksApplication
.
settings
.
getBoolean
(
ShadowsocksApplication
.
getVersionName
,
false
)
if
(
isAutoConnect
&&
isInstalled
)
{
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
)
}
if
(
ShadowsocksApplication
.
settings
.
getBoolean
(
Key
.
isAutoConnect
,
false
))
{
Utils
.
startSsService
(
context
)
}
}
}
src/main/scala/com/github/shadowsocks/TaskerActivity.scala
0 → 100644
View file @
3d998a32
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2014 <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
import
android.content.Intent
import
android.os.Bundle
import
android.support.v7.app.AppCompatActivity
import
android.support.v7.widget.Toolbar
import
android.util.Log
import
android.view.View
import
android.widget.
{
Button
,
Switch
}
import
com.github.shadowsocks.helper.TaskerSettings
import
com.twofortyfouram.locale.api.
{
Intent
=>
ApiIntent
}
/**
* @author CzBiX
*/
class
TaskerActivity
extends
AppCompatActivity
{
var
taskerOption
:
TaskerSettings
=
_
var
switch
:
Switch
=
_
var
btnSave
:
Button
=
_
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
layout_tasker
)
switch
=
findViewById
(
R
.
id
.
service_switch
).
asInstanceOf
[
Switch
]
btnSave
=
findViewById
(
R
.
id
.
btn_save
).
asInstanceOf
[
Button
]
val
toolbar
=
findViewById
(
R
.
id
.
toolbar
).
asInstanceOf
[
Toolbar
]
toolbar
.
setTitle
(
R
.
string
.
screen_name
)
toolbar
.
setNavigationIcon
(
R
.
drawable
.
abc_ic_ab_back_mtrl_am_alpha
)
toolbar
.
setNavigationOnClickListener
(
_
=>
finish
())
switch
.
setOnCheckedChangeListener
((
_
,
isChecked
)
=>
taskerOption
.
is_start
=
isChecked
)
btnSave
.
setOnClickListener
(
_
=>
saveResult
())
loadSettings
()
}
private
def
loadSettings
()
:
Unit
=
{
val
intent
:
Intent
=
getIntent
if
(
intent
.
getAction
!=
ApiIntent
.
ACTION_EDIT_SETTING
)
{
Log
.
w
(
Shadowsocks
.
TAG
,
"unknown tasker action"
)
finish
()
return
}
taskerOption
=
TaskerSettings
.
fromIntent
(
intent
)
switch
.
setChecked
(
taskerOption
.
is_start
)
}
private
def
saveResult
()
:
Unit
=
{
setResult
(
Activity
.
RESULT_OK
,
taskerOption
.
toIntent
(
this
))
finish
()
}
}
src/main/scala/com/github/shadowsocks/TaskerReceiver.scala
0 → 100644
View file @
3d998a32
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2014 <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.content.
{
BroadcastReceiver
,
Context
,
Intent
}
import
com.github.shadowsocks.helper.TaskerSettings
import
com.github.shadowsocks.utils.Utils
/**
* @author CzBiX
*/
class
TaskerReceiver
extends
BroadcastReceiver
{
override
def
onReceive
(
context
:
Context
,
intent
:
Intent
)
:
Unit
=
{
val
settings
:
TaskerSettings
=
TaskerSettings
.
fromIntent
(
intent
)
if
(
settings
.
is_start
)
{
Utils
.
startSsService
(
context
)
}
else
{
Utils
.
stopSsService
(
context
)
}
}
}
src/main/scala/com/github/shadowsocks/helper/TaskerSettings.scala
0 → 100644
View file @
3d998a32
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2014 <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.helper
import
android.content.
{
Intent
,
Context
}
import
android.os.Bundle
import
com.github.shadowsocks.R
import
com.twofortyfouram.locale.api.
{
Intent
=>
ApiIntent
}
object
TaskerSettings
{
def
fromIntent
(
intent
:
Intent
)
:
TaskerSettings
=
{
val
bundle
:
Bundle
=
if
(
intent
.
hasExtra
(
ApiIntent
.
EXTRA_BUNDLE
))
intent
.
getBundleExtra
(
ApiIntent
.
EXTRA_BUNDLE
)
else
Bundle
.
EMPTY
new
TaskerSettings
(
bundle
)
}
def
fromBundle
(
bundle
:
Bundle
)
:
TaskerSettings
=
{
new
TaskerSettings
(
bundle
)
}
}
class
TaskerSettings
(
bundle
:
Bundle
)
{
val
KEY_IS_START
=
"is_start"
var
is_start
:
Boolean
=
bundle
.
getBoolean
(
KEY_IS_START
)
def
toIntent
(
context
:
Context
)
:
Intent
=
{
val
bundle
=
new
Bundle
()
bundle
.
putBoolean
(
KEY_IS_START
,
is_start
)
val
desc
=
context
.
getString
(
R
.
string
.
turn_service_state
,
context
.
getString
(
if
(
is_start
)
R
.
string
.
state_on
else
R
.
string
.
state_off
))
val
intent
:
Intent
=
new
Intent
()
intent
.
putExtra
(
ApiIntent
.
EXTRA_STRING_BLURB
,
desc
)
.
putExtra
(
ApiIntent
.
EXTRA_BUNDLE
,
bundle
)
}
}
src/main/scala/com/github/shadowsocks/utils/Utils.scala
View file @
3d998a32
...
...
@@ -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.
{
ShadowsocksApplication
,
BuildConfig
}
import
com.github.shadowsocks.
{
Shadowsocks
RunnerActivity
,
ShadowsocksRunnerService
,
Shadowsocks
Application
,
BuildConfig
}
import
org.xbill.DNS._
...
...
@@ -416,6 +416,25 @@ object Utils {
false
}
}
def
startSsService
(
context
:
Context
)
:
Unit
=
{
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
)
}
}
def
stopSsService
(
context
:
Context
)
:
Unit
=
{
context
.
sendBroadcast
(
new
Intent
(
Action
.
CLOSE
))
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment