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
b0bc0c74
Commit
b0bc0c74
authored
Dec 29, 2018
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more shortcuts for keyboard devices
parent
5c3bdb32
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
20 deletions
+36
-20
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
+25
-17
mobile/src/main/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
...in/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
+1
-0
mobile/src/main/res/menu/app_manager_menu.xml
mobile/src/main/res/menu/app_manager_menu.xml
+1
-0
mobile/src/main/res/menu/custom_rules_menu.xml
mobile/src/main/res/menu/custom_rules_menu.xml
+3
-1
mobile/src/main/res/menu/profile_manager_menu.xml
mobile/src/main/res/menu/profile_manager_menu.xml
+6
-2
No files found.
mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
View file @
b0bc0c74
...
...
@@ -117,6 +117,16 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, OnPre
stateListener
?.
invoke
(
state
)
}
private
fun
toggle
()
=
when
{
state
==
BaseService
.
CONNECTED
->
Core
.
stopService
()
BaseService
.
usingVpnMode
->
{
val
intent
=
VpnService
.
prepare
(
this
)
if
(
intent
!=
null
)
startActivityForResult
(
intent
,
REQUEST_CONNECT
)
else
onActivityResult
(
REQUEST_CONNECT
,
Activity
.
RESULT_OK
,
null
)
}
else
->
Core
.
startService
()
}
override
val
listenForDeath
:
Boolean
get
()
=
true
override
fun
onServiceConnected
(
service
:
IShadowsocksService
)
=
changeState
(
try
{
service
.
state
...
...
@@ -158,17 +168,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, OnPre
}
fab
=
findViewById
(
R
.
id
.
fab
)
fab
.
setOnClickListener
{
when
{
state
==
BaseService
.
CONNECTED
->
Core
.
stopService
()
BaseService
.
usingVpnMode
->
{
val
intent
=
VpnService
.
prepare
(
this
)
if
(
intent
!=
null
)
startActivityForResult
(
intent
,
REQUEST_CONNECT
)
else
onActivityResult
(
REQUEST_CONNECT
,
Activity
.
RESULT_OK
,
null
)
}
else
->
Core
.
startService
()
}
}
fab
.
setOnClickListener
{
toggle
()
}
changeState
(
BaseService
.
IDLE
)
// reset everything to init state
Core
.
handler
.
post
{
connection
.
connect
()
}
...
...
@@ -264,12 +264,20 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Interface, OnPre
}
}
override
fun
onKeyShortcut
(
keyCode
:
Int
,
event
:
KeyEvent
?)
=
(
supportFragmentManager
.
findFragmentById
(
R
.
id
.
fragment_holder
)
as
ToolbarFragment
).
toolbar
.
menu
.
let
{
it
.
setQwertyMode
(
KeyCharacterMap
.
load
(
event
?.
deviceId
?:
KeyCharacterMap
.
VIRTUAL_KEYBOARD
).
keyboardType
!=
KeyCharacterMap
.
NUMERIC
)
it
.
performShortcut
(
keyCode
,
event
,
0
)
}
override
fun
onKeyShortcut
(
keyCode
:
Int
,
event
:
KeyEvent
)
=
when
{
keyCode
==
KeyEvent
.
KEYCODE_G
&&
event
.
hasModifiers
(
KeyEvent
.
META_CTRL_ON
)
->
{
toggle
()
true
}
keyCode
==
KeyEvent
.
KEYCODE_T
&&
event
.
hasModifiers
(
KeyEvent
.
META_CTRL_ON
)
->
{
stats
.
testConnection
()
true
}
else
->
(
supportFragmentManager
.
findFragmentById
(
R
.
id
.
fragment_holder
)
as
ToolbarFragment
).
toolbar
.
menu
.
let
{
it
.
setQwertyMode
(
KeyCharacterMap
.
load
(
event
.
deviceId
).
keyboardType
!=
KeyCharacterMap
.
NUMERIC
)
it
.
performShortcut
(
keyCode
,
event
,
0
)
}
}
override
fun
onStop
()
{
connection
.
listeningForBandwidth
=
false
...
...
mobile/src/main/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
View file @
b0bc0c74
...
...
@@ -166,6 +166,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
private
val
text
=
view
.
findViewById
<
TextView
>(
android
.
R
.
id
.
text1
)
init
{
view
.
isFocusable
=
true
view
.
setOnClickListener
(
this
)
view
.
setOnLongClickListener
(
this
)
view
.
setBackgroundResource
(
R
.
drawable
.
background_selectable
)
...
...
mobile/src/main/res/menu/app_manager_menu.xml
View file @
b0bc0c74
...
...
@@ -4,6 +4,7 @@
<item
android:id=
"@+id/action_apply_all"
android:title=
"@string/action_apply_all"
android:alphabeticShortcut=
"a"
app:alphabeticModifiers=
"CTRL|SHIFT"
app:showAsAction=
"never"
/>
<item
android:id=
"@+id/action_export_clipboard"
...
...
mobile/src/main/res/menu/custom_rules_menu.xml
View file @
b0bc0c74
...
...
@@ -7,7 +7,9 @@
app:showAsAction=
"always"
>
<menu>
<item
android:id=
"@+id/action_manual_settings"
android:title=
"@string/add_profile_methods_manual_settings"
/>
android:title=
"@string/add_profile_methods_manual_settings"
android:alphabeticShortcut=
"n"
app:alphabeticModifiers=
"CTRL|SHIFT"
/>
<item
android:id=
"@+id/action_import_clipboard"
android:title=
"@string/action_import"
android:alphabeticShortcut=
"v"
/>
...
...
mobile/src/main/res/menu/profile_manager_menu.xml
View file @
b0bc0c74
...
...
@@ -20,7 +20,9 @@
android:title=
"@string/action_import_file"
/>
<item
android:id=
"@+id/action_manual_settings"
android:title=
"@string/add_profile_methods_manual_settings"
/>
android:title=
"@string/add_profile_methods_manual_settings"
android:alphabeticShortcut=
"n"
app:alphabeticModifiers=
"CTRL|SHIFT"
/>
</menu>
</item>
<item
...
...
@@ -35,7 +37,9 @@
android:title=
"@string/action_export"
/>
<item
android:id=
"@+id/action_export_file"
android:title=
"@string/action_export_file"
/>
android:title=
"@string/action_export_file"
android:alphabeticShortcut=
"s"
app:alphabeticModifiers=
"CTRL|SHIFT"
/>
</menu>
</item>
</menu>
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