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
07eb4d2a
Commit
07eb4d2a
authored
Jul 05, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine utils.Key for readability
parent
c480137d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
39 deletions
+39
-39
src/main/scala/com/github/shadowsocks/AppManager.scala
src/main/scala/com/github/shadowsocks/AppManager.scala
+5
-5
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+1
-1
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
...scala/com/github/shadowsocks/ShadowsocksApplication.scala
+2
-2
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
...in/scala/com/github/shadowsocks/ShadowsocksSettings.scala
+20
-20
src/main/scala/com/github/shadowsocks/utils/Constants.scala
src/main/scala/com/github/shadowsocks/utils/Constants.scala
+11
-11
No files found.
src/main/scala/com/github/shadowsocks/AppManager.scala
View file @
07eb4d2a
...
...
@@ -163,7 +163,7 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
case
R
.
id
.
action_apply_all
=>
app
.
profileManager
.
getAllProfiles
match
{
case
Some
(
profiles
)
=>
val
proxiedAppString
=
prefs
.
getString
(
Key
.
proxied
,
""
)
val
proxiedAppString
=
prefs
.
getString
(
Key
.
individual
,
""
)
profiles
.
foreach
(
profile
=>
{
profile
.
individual
=
proxiedAppString
app
.
profileManager
.
updateProfile
(
profile
)
...
...
@@ -173,9 +173,9 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
}
return
true
case
R
.
id
.
action_export
=>
val
bypass
=
prefs
.
getBoolean
(
Key
.
isBypassApp
s
,
false
)
val
proxiedAppString
=
prefs
.
getString
(
Key
.
proxied
,
""
)
val
clip
=
ClipData
.
newPlainText
(
Key
.
proxied
,
bypass
+
"\n"
+
proxiedAppString
)
val
bypass
=
prefs
.
getBoolean
(
Key
.
bypas
s
,
false
)
val
proxiedAppString
=
prefs
.
getString
(
Key
.
individual
,
""
)
val
clip
=
ClipData
.
newPlainText
(
Key
.
individual
,
bypass
+
"\n"
+
proxiedAppString
)
clipboard
.
setPrimaryClip
(
clip
)
Toast
.
makeText
(
this
,
R
.
string
.
action_export_msg
,
Toast
.
LENGTH_SHORT
).
show
()
return
true
...
...
@@ -191,7 +191,7 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
val
(
enabled
,
apps
)
=
if
(
i
<
0
)
(
proxiedAppString
,
""
)
else
(
proxiedAppString
.
substring
(
0
,
i
),
proxiedAppString
.
substring
(
i
+
1
))
bypassSwitch
.
setChecked
(
enabled
.
toBoolean
)
editor
.
putString
(
Key
.
proxied
,
apps
).
apply
()
editor
.
putString
(
Key
.
individual
,
apps
).
apply
()
Toast
.
makeText
(
this
,
R
.
string
.
action_import_msg
,
Toast
.
LENGTH_SHORT
).
show
()
appListView
.
setVisibility
(
View
.
GONE
)
loadingView
.
setVisibility
(
View
.
VISIBLE
)
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
07eb4d2a
...
...
@@ -405,7 +405,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
fab
=
findViewById
(
R
.
id
.
fab
).
asInstanceOf
[
FloatingActionButton
]
fabProgressCircle
=
findViewById
(
R
.
id
.
fabProgressCircle
).
asInstanceOf
[
FABProgressCircle
]
fab
.
setOnClickListener
(
_
=>
if
(
serviceStarted
)
serviceStop
()
else
if
(
checkText
(
Key
.
proxy
)
&&
checkText
(
Key
.
sitekey
)
&&
bgService
!=
null
)
prepareStartService
()
else
if
(
checkText
(
Key
.
host
)
&&
checkText
(
Key
.
password
)
&&
bgService
!=
null
)
prepareStartService
()
else
changeSwitch
(
checked
=
false
))
fab
.
setOnLongClickListener
((
v
:
View
)
=>
{
Utils
.
positionToast
(
Toast
.
makeText
(
this
,
if
(
serviceStarted
)
R
.
string
.
stop
else
R
.
string
.
connect
,
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
View file @
07eb4d2a
...
...
@@ -83,8 +83,8 @@ class ShadowsocksApplication extends Application {
.
setLabel
(
getVersionName
)
.
build
())
def
profileId
=
settings
.
getInt
(
Key
.
profileI
d
,
-
1
)
def
profileId
(
i
:
Int
)
=
editor
.
putInt
(
Key
.
profileI
d
,
i
).
apply
def
profileId
=
settings
.
getInt
(
Key
.
i
d
,
-
1
)
def
profileId
(
i
:
Int
)
=
editor
.
putInt
(
Key
.
i
d
,
i
).
apply
def
currentProfile
=
profileManager
.
getProfile
(
profileId
)
def
switchProfile
(
id
:
Int
)
=
{
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
View file @
07eb4d2a
...
...
@@ -17,9 +17,9 @@ import com.github.shadowsocks.utils.{Key, Utils}
object
ShadowsocksSettings
{
// Constants
private
final
val
TAG
=
"ShadowsocksSettings"
private
val
PROXY_PREFS
=
Array
(
Key
.
profileName
,
Key
.
proxy
,
Key
.
remotePort
,
Key
.
localPort
,
Key
.
sitekey
,
Key
.
encM
ethod
,
Key
.
isA
uth
)
private
val
FEATURE_PREFS
=
Array
(
Key
.
route
,
Key
.
isProxyApps
,
Key
.
isUdpDns
,
Key
.
isI
pv6
)
private
val
PROXY_PREFS
=
Array
(
Key
.
name
,
Key
.
host
,
Key
.
remotePort
,
Key
.
localPort
,
Key
.
password
,
Key
.
m
ethod
,
Key
.
a
uth
)
private
val
FEATURE_PREFS
=
Array
(
Key
.
route
,
Key
.
proxyApps
,
Key
.
udpdns
,
Key
.
i
pv6
)
// Helper functions
def
updateDropDownPreference
(
pref
:
Preference
,
value
:
String
)
{
...
...
@@ -46,17 +46,17 @@ object ShadowsocksSettings {
def
updatePreference
(
pref
:
Preference
,
name
:
String
,
profile
:
Profile
)
{
name
match
{
case
Key
.
profileN
ame
=>
updateSummaryEditTextPreference
(
pref
,
profile
.
name
)
case
Key
.
proxy
=>
updateSummaryEditTextPreference
(
pref
,
profile
.
host
)
case
Key
.
n
ame
=>
updateSummaryEditTextPreference
(
pref
,
profile
.
name
)
case
Key
.
host
=>
updateSummaryEditTextPreference
(
pref
,
profile
.
host
)
case
Key
.
remotePort
=>
updateNumberPickerPreference
(
pref
,
profile
.
remotePort
)
case
Key
.
localPort
=>
updateNumberPickerPreference
(
pref
,
profile
.
localPort
)
case
Key
.
sitekey
=>
updatePasswordEditTextPreference
(
pref
,
profile
.
password
)
case
Key
.
encM
ethod
=>
updateDropDownPreference
(
pref
,
profile
.
method
)
case
Key
.
password
=>
updatePasswordEditTextPreference
(
pref
,
profile
.
password
)
case
Key
.
m
ethod
=>
updateDropDownPreference
(
pref
,
profile
.
method
)
case
Key
.
route
=>
updateDropDownPreference
(
pref
,
profile
.
route
)
case
Key
.
isP
roxyApps
=>
updateSwitchPreference
(
pref
,
profile
.
proxyApps
)
case
Key
.
isUdpD
ns
=>
updateSwitchPreference
(
pref
,
profile
.
udpdns
)
case
Key
.
isA
uth
=>
updateSwitchPreference
(
pref
,
profile
.
auth
)
case
Key
.
i
sI
pv6
=>
updateSwitchPreference
(
pref
,
profile
.
ipv6
)
case
Key
.
p
roxyApps
=>
updateSwitchPreference
(
pref
,
profile
.
proxyApps
)
case
Key
.
udpd
ns
=>
updateSwitchPreference
(
pref
,
profile
.
udpdns
)
case
Key
.
a
uth
=>
updateSwitchPreference
(
pref
,
profile
.
auth
)
case
Key
.
ipv6
=>
updateSwitchPreference
(
pref
,
profile
.
ipv6
)
}
}
}
...
...
@@ -74,11 +74,11 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
addPreferencesFromResource
(
R
.
xml
.
pref_all
)
getPreferenceManager
.
getSharedPreferences
.
registerOnSharedPreferenceChangeListener
(
this
)
findPreference
(
Key
.
profileN
ame
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
findPreference
(
Key
.
n
ame
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
profile
.
name
=
value
.
asInstanceOf
[
String
]
app
.
profileManager
.
updateProfile
(
profile
)
})
findPreference
(
Key
.
proxy
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
findPreference
(
Key
.
host
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
profile
.
host
=
value
.
asInstanceOf
[
String
]
app
.
profileManager
.
updateProfile
(
profile
)
})
...
...
@@ -90,11 +90,11 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
profile
.
localPort
=
value
.
asInstanceOf
[
Int
]
app
.
profileManager
.
updateProfile
(
profile
)
})
findPreference
(
Key
.
sitekey
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
findPreference
(
Key
.
password
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
profile
.
password
=
value
.
asInstanceOf
[
String
]
app
.
profileManager
.
updateProfile
(
profile
)
})
findPreference
(
Key
.
encM
ethod
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
findPreference
(
Key
.
m
ethod
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
profile
.
method
=
value
.
asInstanceOf
[
String
]
app
.
profileManager
.
updateProfile
(
profile
)
})
...
...
@@ -103,7 +103,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
app
.
profileManager
.
updateProfile
(
profile
)
})
isProxyApps
=
findPreference
(
Key
.
isP
roxyApps
).
asInstanceOf
[
SwitchPreference
]
isProxyApps
=
findPreference
(
Key
.
p
roxyApps
).
asInstanceOf
[
SwitchPreference
]
isProxyApps
.
setOnPreferenceClickListener
(
_
=>
{
startActivity
(
new
Intent
(
activity
,
classOf
[
AppManager
]))
isProxyApps
.
setChecked
(
true
)
...
...
@@ -114,15 +114,15 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
app
.
profileManager
.
updateProfile
(
profile
)
})
findPreference
(
Key
.
isUdpD
ns
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
findPreference
(
Key
.
udpd
ns
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
profile
.
udpdns
=
value
.
asInstanceOf
[
Boolean
]
app
.
profileManager
.
updateProfile
(
profile
)
})
findPreference
(
Key
.
isA
uth
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
findPreference
(
Key
.
a
uth
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
profile
.
auth
=
value
.
asInstanceOf
[
Boolean
]
app
.
profileManager
.
updateProfile
(
profile
)
})
findPreference
(
Key
.
i
sI
pv6
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
findPreference
(
Key
.
ipv6
).
setOnPreferenceChangeListener
((
_
,
value
)
=>
{
profile
.
ipv6
=
value
.
asInstanceOf
[
Boolean
]
app
.
profileManager
.
updateProfile
(
profile
)
})
...
...
@@ -202,7 +202,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
for
(
name
<-
Key
.
isNAT
#::
PROXY_PREFS
.
toStream
#:::
FEATURE_PREFS
.
toStream
)
{
val
pref
=
findPreference
(
name
)
if
(
pref
!=
null
)
pref
.
setEnabled
(
enabled
&&
(
name
!=
Key
.
isP
roxyApps
||
Utils
.
isLollipopOrAbove
||
app
.
isNatEnabled
))
(
name
!=
Key
.
p
roxyApps
||
Utils
.
isLollipopOrAbove
||
app
.
isNatEnabled
))
}
}
...
...
src/main/scala/com/github/shadowsocks/utils/Constants.scala
View file @
07eb4d2a
...
...
@@ -143,25 +143,25 @@ object ConfigUtils {
}
object
Key
{
val
profileI
d
=
"profileId"
val
profileN
ame
=
"profileName"
val
i
d
=
"profileId"
val
n
ame
=
"profileName"
val
proxied
=
"Proxyed"
val
individual
=
"Proxyed"
val
isNAT
=
"isNAT"
val
route
=
"route"
val
isAutoConnect
=
"isAutoConnect"
val
isP
roxyApps
=
"isProxyApps"
val
isBypassApp
s
=
"isBypassApps"
val
isUdpD
ns
=
"isUdpDns"
val
isA
uth
=
"isAuth"
val
i
sI
pv6
=
"isIpv6"
val
p
roxyApps
=
"isProxyApps"
val
bypas
s
=
"isBypassApps"
val
udpd
ns
=
"isUdpDns"
val
a
uth
=
"isAuth"
val
ipv6
=
"isIpv6"
val
proxy
=
"proxy"
val
sitekey
=
"sitekey"
val
encM
ethod
=
"encMethod"
val
host
=
"proxy"
val
password
=
"sitekey"
val
m
ethod
=
"encMethod"
val
remotePort
=
"remotePortNum"
val
localPort
=
"localPortNum"
...
...
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