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
244c2ecd
Commit
244c2ecd
authored
Oct 23, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add quick toggle shortcut (#950)
Mainly for Android 7.1, also backward compatible.
parent
54c696d0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
0 deletions
+65
-0
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+13
-0
src/main/res/xml/shortcuts.xml
src/main/res/xml/shortcuts.xml
+13
-0
src/main/scala/com/github/shadowsocks/QuickToggleShortcut.scala
...in/scala/com/github/shadowsocks/QuickToggleShortcut.scala
+39
-0
No files found.
src/main/AndroidManifest.xml
View file @
244c2ecd
...
@@ -53,6 +53,8 @@
...
@@ -53,6 +53,8 @@
<intent-filter>
<intent-filter>
<action
android:name=
"android.service.quicksettings.action.QS_TILE"
/>
<action
android:name=
"android.service.quicksettings.action.QS_TILE"
/>
</intent-filter>
</intent-filter>
<meta-data
android:name=
"android.app.shortcuts"
android:resource=
"@xml/shortcuts"
/>
</activity>
</activity>
<activity
<activity
...
@@ -116,6 +118,17 @@
...
@@ -116,6 +118,17 @@
</intent-filter>
</intent-filter>
</activity>
</activity>
<activity
android:name=
".QuickToggleShortcut"
android:label=
"@string/quick_toggle"
android:theme=
"@android:style/Theme.NoDisplay"
android:excludeFromRecents=
"true"
android:launchMode=
"singleTask"
>
<intent-filter>
<action
android:name=
"android.intent.action.CREATE_SHORTCUT"
/>
</intent-filter>
</activity>
<service
<service
android:name=
".ShadowsocksRunnerService"
android:name=
".ShadowsocksRunnerService"
android:exported=
"false"
>
android:exported=
"false"
>
...
...
src/main/res/xml/shortcuts.xml
0 → 100644
View file @
244c2ecd
<?xml version="1.0" encoding="utf-8"?>
<shortcuts
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<shortcut
android:shortcutId=
"toggle"
android:enabled=
"true"
android:icon=
"@mipmap/ic_launcher"
android:shortcutShortLabel=
"@string/quick_toggle"
android:shortcutLongLabel=
"@string/quick_toggle"
android:shortcutDisabledMessage=
"@string/quick_toggle"
>
<intent
android:action=
"android.intent.action.VIEW"
android:targetPackage=
"com.github.shadowsocks"
android:targetClass=
"com.github.shadowsocks.QuickToggleShortcut"
/>
</shortcut>
</shortcuts>
src/main/scala/com/github/shadowsocks/QuickToggleShortcut.scala
0 → 100644
View file @
244c2ecd
package
com.github.shadowsocks
import
android.app.Activity
import
android.content.Intent
import
android.os.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
()
}
}
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
()
}
}
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