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
c1c15f53
Commit
c1c15f53
authored
Dec 28, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine connection test feature
parent
e33adc4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
11 deletions
+9
-11
src/main/scala/com/github/shadowsocks/MainActivity.scala
src/main/scala/com/github/shadowsocks/MainActivity.scala
+9
-11
No files found.
src/main/scala/com/github/shadowsocks/MainActivity.scala
View file @
c1c15f53
...
...
@@ -127,6 +127,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
if
(
state
==
State
.
CONNECTED
)
fab
.
setBackgroundTintList
(
greenTint
)
else
{
fab
.
setBackgroundTintList
(
greyTint
)
updateTraffic
(
0
,
0
,
0
,
0
)
testCount
+=
1
// suppress previous test messages
}
fab
.
setEnabled
(
false
)
if
(
state
==
State
.
CONNECTED
||
state
==
State
.
STOPPED
)
...
...
@@ -211,12 +212,10 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
txRateText
=
findViewById
(
R
.
id
.
txRate
).
asInstanceOf
[
TextView
]
rxText
=
findViewById
(
R
.
id
.
rx
).
asInstanceOf
[
TextView
]
rxRateText
=
findViewById
(
R
.
id
.
rxRate
).
asInstanceOf
[
TextView
]
findViewById
(
R
.
id
.
stat
).
setOnClickListener
(
_
=>
{
val
id
=
synchronized
{
testCount
+=
1
handler
.
post
(()
=>
statusText
.
setText
(
R
.
string
.
connection_test_testing
))
testCount
}
findViewById
(
R
.
id
.
stat
).
setOnClickListener
(
_
=>
if
(
state
==
State
.
CONNECTED
&&
app
.
isVpnEnabled
)
{
testCount
+=
1
statusText
.
setText
(
R
.
string
.
connection_test_testing
)
val
id
=
testCount
// it would change by other code
Utils
.
ThrowableFuture
{
// Based on: https://android.googlesource.com/platform/frameworks/base/+/master/services/core/java/com/android/server/connectivity/NetworkMonitor.java#640
autoDisconnect
(
new
URL
(
"https"
,
"www.google.com"
,
"/generate_204"
).
openConnection
()
...
...
@@ -241,11 +240,10 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
success
=
false
result
=
getString
(
R
.
string
.
connection_test_error
,
e
.
getMessage
)
}
synchronized
(
if
(
state
==
State
.
CONNECTED
&&
testCount
==
id
&&
app
.
isVpnEnabled
)
handler
.
post
(()
=>
if
(
success
)
statusText
.
setText
(
result
)
else
{
statusText
.
setText
(
R
.
string
.
connection_test_fail
)
Snackbar
.
make
(
findViewById
(
R
.
id
.
snackbar
),
result
,
Snackbar
.
LENGTH_LONG
).
show
()
}))
if
(
testCount
==
id
)
handler
.
post
(()
=>
if
(
success
)
statusText
.
setText
(
result
)
else
{
statusText
.
setText
(
R
.
string
.
connection_test_fail
)
Snackbar
.
make
(
findViewById
(
R
.
id
.
snackbar
),
result
,
Snackbar
.
LENGTH_LONG
).
show
()
})
}
}
}
...
...
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