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
33ed5c65
Commit
33ed5c65
authored
Apr 22, 2015
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #279
parent
1424e056
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
28 deletions
+38
-28
src/main/res/values-zh/strings.xml
src/main/res/values-zh/strings.xml
+1
-1
src/main/res/values/strings.xml
src/main/res/values/strings.xml
+1
-1
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+36
-26
No files found.
src/main/res/values-zh/strings.xml
View file @
33ed5c65
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
<string
name=
"stopping"
>
正在关闭...
</string>
<string
name=
"stopping"
>
正在关闭...
</string>
<string
name=
"vpn_error"
>
后台服务启动失败:%s
</string>
<string
name=
"vpn_error"
>
后台服务启动失败:%s
</string>
<string
name=
"ok_iknow"
>
确定
</string>
<string
name=
"ok_iknow"
>
确定
</string>
<string
name=
"port_alert"
>
端口号应大于1024
</string>
<string
name=
"port_alert"
>
本地
端口号应大于1024
</string>
<string
name=
"port_empty"
>
端口号不能为空
</string>
<string
name=
"port_empty"
>
端口号不能为空
</string>
<string
name=
"proxy_empty"
>
代理服务器地址不能为空
</string>
<string
name=
"proxy_empty"
>
代理服务器地址不能为空
</string>
<string
name=
"crash_alert"
>
检测到意外退出,状态已被重置。
</string>
<string
name=
"crash_alert"
>
检测到意外退出,状态已被重置。
</string>
...
...
src/main/res/values/strings.xml
View file @
33ed5c65
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
<!-- alert category -->
<!-- alert category -->
<string
name=
"ok_iknow"
>
OK
</string>
<string
name=
"ok_iknow"
>
OK
</string>
<string
name=
"port_alert"
>
The port number should be greater than 1024
</string>
<string
name=
"port_alert"
>
The
local
port number should be greater than 1024
</string>
<string
name=
"port_empty"
>
Port should not be empty
</string>
<string
name=
"port_empty"
>
Port should not be empty
</string>
<string
name=
"proxy_empty"
>
Proxy should not be empty
</string>
<string
name=
"proxy_empty"
>
Proxy should not be empty
</string>
<string
name=
"crash_alert"
>
An unexpected exit detected, the context has been reset.
<string
name=
"crash_alert"
>
An unexpected exit detected, the context has been reset.
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
33ed5c65
...
@@ -366,19 +366,29 @@ class Shadowsocks
...
@@ -366,19 +366,29 @@ class Shadowsocks
def
isTextEmpty
(
s
:
String
,
msg
:
String
)
:
Boolean
=
{
def
isTextEmpty
(
s
:
String
,
msg
:
String
)
:
Boolean
=
{
if
(
s
==
null
||
s
.
length
<=
0
)
{
if
(
s
==
null
||
s
.
length
<=
0
)
{
new
SnackBar
.
Builder
(
this
).
withMessage
(
msg
).
withStyle
(
SnackBar
.
Style
.
ALERT
).
show
()
new
SnackBar
.
Builder
(
this
)
.
withMessage
(
msg
)
.
withActionMessageId
(
R
.
string
.
error
)
.
withStyle
(
SnackBar
.
Style
.
ALERT
)
.
withDuration
(
SnackBar
.
LONG_SNACK
)
.
show
()
return
true
return
true
}
}
false
false
}
}
def
cancelStart
()
{
def
cancelStart
()
{
handler
.
postDelayed
(
new
Runnable
{
clearDialog
()
override
def
run
()
{
changeSwitch
(
checked
=
false
)
clearDialog
()
}
changeSwitch
(
checked
=
false
)
}
def
isReady
()
:
Boolean
=
{
},
1000
)
if
(!
checkText
(
Key
.
proxy
))
return
false
if
(!
checkText
(
Key
.
sitekey
))
return
false
if
(!
checkNumber
(
Key
.
localPort
,
low
=
false
))
return
false
if
(!
checkNumber
(
Key
.
remotePort
,
low
=
true
))
return
false
if
(
bgService
==
null
)
return
false
true
}
}
def
prepareStartService
()
{
def
prepareStartService
()
{
...
@@ -392,9 +402,7 @@ class Shadowsocks
...
@@ -392,9 +402,7 @@ class Shadowsocks
onActivityResult
(
Shadowsocks
.
REQUEST_CONNECT
,
Activity
.
RESULT_OK
,
null
)
onActivityResult
(
Shadowsocks
.
REQUEST_CONNECT
,
Activity
.
RESULT_OK
,
null
)
}
}
}
else
{
}
else
{
if
(!
serviceStart
)
{
serviceStart
()
cancelStart
()
}
}
}
}
}
}
}
...
@@ -403,7 +411,10 @@ class Shadowsocks
...
@@ -403,7 +411,10 @@ class Shadowsocks
if
(
compoundButton
eq
switchButton
)
{
if
(
compoundButton
eq
switchButton
)
{
checked
match
{
checked
match
{
case
true
=>
case
true
=>
prepareStartService
()
if
(
isReady
)
prepareStartService
()
else
changeSwitch
(
checked
=
false
)
case
false
=>
case
false
=>
serviceStop
()
serviceStop
()
}
}
...
@@ -889,9 +900,7 @@ class Shadowsocks
...
@@ -889,9 +900,7 @@ class Shadowsocks
resultCode
match
{
resultCode
match
{
case
Activity
.
RESULT_OK
=>
case
Activity
.
RESULT_OK
=>
prepared
=
true
prepared
=
true
if
(!
serviceStart
)
{
serviceStart
()
cancelStart
()
}
case
_
=>
case
_
=>
cancelStart
()
cancelStart
()
Log
.
e
(
Shadowsocks
.
TAG
,
"Failed to start VpnService"
)
Log
.
e
(
Shadowsocks
.
TAG
,
"Failed to start VpnService"
)
...
@@ -925,33 +934,34 @@ class Shadowsocks
...
@@ -925,33 +934,34 @@ class Shadowsocks
try
{
try
{
val
port
:
Int
=
Integer
.
valueOf
(
text
)
val
port
:
Int
=
Integer
.
valueOf
(
text
)
if
(!
low
&&
port
<=
1024
)
{
if
(!
low
&&
port
<=
1024
)
{
new
SnackBar
.
Builder
(
this
).
withMessageId
(
R
.
string
.
port_alert
).
withStyle
(
SnackBar
.
Style
.
ALERT
).
show
()
new
SnackBar
.
Builder
(
this
)
.
withMessageId
(
R
.
string
.
port_alert
)
.
withActionMessageId
(
R
.
string
.
error
)
.
withStyle
(
SnackBar
.
Style
.
ALERT
)
.
withDuration
(
SnackBar
.
LONG_SNACK
)
.
show
()
return
false
return
false
}
}
}
catch
{
}
catch
{
case
ex
:
Exception
=>
case
ex
:
Exception
=>
new
SnackBar
.
Builder
(
this
).
withMessageId
(
R
.
string
.
port_alert
).
withStyle
(
SnackBar
.
Style
.
ALERT
).
show
()
new
SnackBar
.
Builder
(
this
)
.
withMessageId
(
R
.
string
.
port_alert
)
.
withActionMessageId
(
R
.
string
.
error
)
.
withStyle
(
SnackBar
.
Style
.
ALERT
)
.
withDuration
(
SnackBar
.
LONG_SNACK
)
.
show
()
return
false
return
false
}
}
true
true
}
}
/** Called when connect button is clicked. */
/** Called when connect button is clicked. */
def
serviceStart
:
Boolean
=
{
def
serviceStart
()
{
if
(!
checkText
(
Key
.
proxy
))
return
false
if
(!
checkText
(
Key
.
sitekey
))
return
false
if
(!
checkNumber
(
Key
.
localPort
,
low
=
false
))
return
false
if
(!
checkNumber
(
Key
.
remotePort
,
low
=
true
))
return
false
if
(
bgService
==
null
)
return
false
bgService
.
start
(
ConfigUtils
.
load
(
settings
))
bgService
.
start
(
ConfigUtils
.
load
(
settings
))
if
(
isVpnEnabled
)
{
if
(
isVpnEnabled
)
{
changeSwitch
(
checked
=
false
)
changeSwitch
(
checked
=
false
)
}
}
true
}
}
private
def
showAbout
()
{
private
def
showAbout
()
{
...
...
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