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
ac98caa4
Commit
ac98caa4
authored
Dec 06, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move code
parent
8c2690c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
50 deletions
+45
-50
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+45
-50
No files found.
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
ac98caa4
...
...
@@ -158,9 +158,50 @@ class Shadowsocks
// Services
var
currentServiceName
=
classOf
[
ShadowsocksNatService
].
getName
private
val
callback
=
new
IShadowsocksServiceCallback
.
Stub
{
def
stateChanged
(
state
:
Int
,
msg
:
String
)
=
onStateChanged
(
state
,
msg
)
def
trafficUpdated
(
txRate
:
String
,
rxRate
:
String
,
txTotal
:
String
,
rxTotal
:
String
)
=
Shadowsocks
.
this
.
trafficUpdated
(
txRate
,
rxRate
,
txTotal
,
rxTotal
)
def
stateChanged
(
s
:
Int
,
m
:
String
)
{
handler
.
post
(()
=>
if
(
state
!=
s
)
{
s
match
{
case
State
.
CONNECTING
=>
fab
.
setBackgroundTintList
(
greyTint
)
fab
.
setImageResource
(
R
.
drawable
.
ic_cloud_queue
)
fab
.
setEnabled
(
false
)
fabProgressCircle
.
show
()
setPreferenceEnabled
(
enabled
=
false
)
case
State
.
CONNECTED
=>
fab
.
setBackgroundTintList
(
greenTint
)
if
(
state
==
State
.
CONNECTING
)
{
fabProgressCircle
.
beginFinalAnimation
()
}
else
{
handler
.
postDelayed
(()
=>
fabProgressCircle
.
hide
(),
1000
)
}
fab
.
setEnabled
(
true
)
changeSwitch
(
checked
=
true
)
setPreferenceEnabled
(
enabled
=
false
)
case
State
.
STOPPED
=>
fab
.
setBackgroundTintList
(
greyTint
)
handler
.
postDelayed
(()
=>
fabProgressCircle
.
hide
(),
1000
)
fab
.
setEnabled
(
true
)
changeSwitch
(
checked
=
false
)
if
(
m
!=
null
)
Snackbar
.
make
(
findViewById
(
android
.
R
.
id
.
content
),
getString
(
R
.
string
.
vpn_error
).
formatLocal
(
Locale
.
ENGLISH
,
m
),
Snackbar
.
LENGTH_LONG
).
show
setPreferenceEnabled
(
enabled
=
true
)
case
State
.
STOPPING
=>
fab
.
setBackgroundTintList
(
greyTint
)
fab
.
setImageResource
(
R
.
drawable
.
ic_cloud_queue
)
fab
.
setEnabled
(
false
)
if
(
state
==
State
.
CONNECTED
)
fabProgressCircle
.
show
()
// ignore for stopped
setPreferenceEnabled
(
enabled
=
false
)
}
state
=
s
})
}
def
trafficUpdated
(
txRate
:
String
,
rxRate
:
String
,
txTotal
:
String
,
rxTotal
:
String
)
{
val
trafficStat
=
getString
(
R
.
string
.
stat_summary
)
.
formatLocal
(
Locale
.
ENGLISH
,
txRate
,
rxRate
,
txTotal
,
rxTotal
)
handler
.
post
(()
=>
{
preferences
.
findPreference
(
Key
.
stat
).
setSummary
(
trafficStat
)
})
}
}
def
attachService
:
Unit
=
attachService
(
callback
)
...
...
@@ -195,14 +236,6 @@ class Shadowsocks
if
(
fab
!=
null
)
fab
.
setEnabled
(
false
)
}
def
trafficUpdated
(
txRate
:
String
,
rxRate
:
String
,
txTotal
:
String
,
rxTotal
:
String
)
{
val
trafficStat
=
getString
(
R
.
string
.
stat_summary
)
.
formatLocal
(
Locale
.
ENGLISH
,
txRate
,
rxRate
,
txTotal
,
rxTotal
)
handler
.
post
(()
=>
{
preferences
.
findPreference
(
Key
.
stat
).
setSummary
(
trafficStat
)
})
}
private
lazy
val
preferences
=
getFragmentManager
.
findFragmentById
(
android
.
R
.
id
.
content
).
asInstanceOf
[
ShadowsocksSettings
]
private
var
adView
:
AdView
=
_
...
...
@@ -445,7 +478,7 @@ class Shadowsocks
// Check if current profile changed
if
(
ShadowsocksApplication
.
profileId
!=
currentProfile
.
id
)
reloadProfile
()
trafficUpdated
(
TrafficMonitor
.
getTxRate
,
TrafficMonitor
.
getRxRate
,
callback
.
trafficUpdated
(
TrafficMonitor
.
getTxRate
,
TrafficMonitor
.
getRxRate
,
TrafficMonitor
.
getTxTotal
,
TrafficMonitor
.
getRxTotal
)
}
...
...
@@ -582,42 +615,4 @@ class Shadowsocks
progressTag
=
-
1
}
}
def
onStateChanged
(
s
:
Int
,
m
:
String
)
{
handler
.
post
(()
=>
if
(
state
!=
s
)
{
s
match
{
case
State
.
CONNECTING
=>
fab
.
setBackgroundTintList
(
greyTint
)
fab
.
setImageResource
(
R
.
drawable
.
ic_cloud_queue
)
fab
.
setEnabled
(
false
)
fabProgressCircle
.
show
()
setPreferenceEnabled
(
enabled
=
false
)
case
State
.
CONNECTED
=>
fab
.
setBackgroundTintList
(
greenTint
)
if
(
state
==
State
.
CONNECTING
)
{
fabProgressCircle
.
beginFinalAnimation
()
}
else
{
handler
.
postDelayed
(()
=>
fabProgressCircle
.
hide
(),
1000
)
}
fab
.
setEnabled
(
true
)
changeSwitch
(
checked
=
true
)
setPreferenceEnabled
(
enabled
=
false
)
case
State
.
STOPPED
=>
fab
.
setBackgroundTintList
(
greyTint
)
handler
.
postDelayed
(()
=>
fabProgressCircle
.
hide
(),
1000
)
fab
.
setEnabled
(
true
)
changeSwitch
(
checked
=
false
)
if
(
m
!=
null
)
Snackbar
.
make
(
findViewById
(
android
.
R
.
id
.
content
),
getString
(
R
.
string
.
vpn_error
).
formatLocal
(
Locale
.
ENGLISH
,
m
),
Snackbar
.
LENGTH_LONG
).
show
setPreferenceEnabled
(
enabled
=
true
)
case
State
.
STOPPING
=>
fab
.
setBackgroundTintList
(
greyTint
)
fab
.
setImageResource
(
R
.
drawable
.
ic_cloud_queue
)
fab
.
setEnabled
(
false
)
if
(
state
==
State
.
CONNECTED
)
fabProgressCircle
.
show
()
// ignore for stopped
setPreferenceEnabled
(
enabled
=
false
)
}
state
=
s
})
}
}
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