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
1907ac2f
Commit
1907ac2f
authored
Dec 01, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support scaning QR code
parent
aae95df4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
11 deletions
+112
-11
build.sbt
build.sbt
+2
-1
src/main/res/values-zh/strings.xml
src/main/res/values-zh/strings.xml
+7
-0
src/main/res/values/strings.xml
src/main/res/values/strings.xml
+6
-0
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+63
-10
src/main/scala/com/github/shadowsocks/utils/ShadowParser.scala
...ain/scala/com/github/shadowsocks/utils/ShadowParser.scala
+34
-0
No files found.
build.sbt
View file @
1907ac2f
...
...
@@ -4,7 +4,8 @@ libraryDependencies ++= Seq(
"com.google.android"
%
"admob"
%
"6.4.1"
,
"dnsjava"
%
"dnsjava"
%
"2.1.5"
,
"org.scalaj"
%%
"scalaj-http"
%
"0.3.10"
,
"commons-net"
%
"commons-net"
%
"3.3"
"commons-net"
%
"commons-net"
%
"3.3"
,
"com.google.zxing"
%
"android-integration"
%
"2.2"
)
libraryDependencies
++=
Seq
(
...
...
src/main/res/values-zh/strings.xml
View file @
1907ac2f
...
...
@@ -66,4 +66,11 @@
<string
name=
"flush_dnscache"
>
刷新 DNS 缓存
</string>
<string
name=
"flushing"
>
刷新中...
</string>
<string
name=
"add_profile"
>
添加配置文件
</string>
<!-- profile -->
<string-array
name=
"add_profile_methods"
>
<item>
扫描二维码
</item>
<item>
手动设置
</item>
</string-array>
</resources>
src/main/res/values/strings.xml
View file @
1907ac2f
...
...
@@ -83,4 +83,10 @@
<string
name=
"flushing"
>
Flushing
</string>
<string
name=
"add_profile"
>
Add Profile
</string>
<!-- profile -->
<string-array
name=
"add_profile_methods"
>
<item>
Scan QR code
</item>
<item>
Manually Setting
</item>
</string-array>
</resources>
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
1907ac2f
...
...
@@ -72,6 +72,7 @@ import com.github.shadowsocks.database.Category
import
com.github.shadowsocks.utils._
import
com.github.shadowsocks.database.Item
import
com.github.shadowsocks.database.Category
import
com.google.zxing.integration.android.IntentIntegrator
class
ProfileIconDownloader
(
context
:
Context
,
connectTimeout
:
Int
,
readTimeout
:
Int
)
extends
BaseImageDownloader
(
context
,
connectTimeout
,
readTimeout
)
{
...
...
@@ -569,6 +570,50 @@ class Shadowsocks
drawer
.
setActiveView
(
v
,
pos
)
}
def
newProfile
(
id
:
Int
)
{
val
builder
=
new
AlertDialog
.
Builder
(
this
)
builder
.
setTitle
(
R
.
string
.
add_profile
)
.
setItems
(
R
.
array
.
add_profile_methods
,
new
DialogInterface
.
OnClickListener
()
{
def
onClick
(
dialog
:
DialogInterface
,
which
:
Int
)
{
which
match
{
case
0
=>
{
val
integrator
=
new
IntentIntegrator
(
Shadowsocks
.
this
)
integrator
.
initiateScan
()
}
case
1
=>
addProfile
(
id
)
case
_
=>
}
}
})
builder
.
create
().
show
()
}
def
addProfile
(
profile
:
Profile
)
{
drawer
.
closeMenu
(
true
)
val
h
=
showProgress
(
getString
(
R
.
string
.
loading
))
handler
.
postDelayed
(
new
Runnable
{
def
run
()
{
currentProfile
=
profile
profileManager
.
createOrUpdateProfile
(
currentProfile
)
profileManager
.
reload
(
currentProfile
.
id
)
menuAdapter
.
updateList
(
getMenuList
,
currentProfile
.
id
)
if
(!
isSinglePane
)
{
sendBroadcast
(
new
Intent
(
Action
.
UPDATE_FRAGMENT
))
}
else
{
updatePreferenceScreen
()
}
h
.
sendEmptyMessage
(
0
)
}
},
600
)
}
def
addProfile
(
id
:
Int
)
{
drawer
.
closeMenu
(
true
)
...
...
@@ -665,7 +710,7 @@ class Shadowsocks
buf
++=
getProfileList
buf
+=
new
Item
(-
400
,
getString
(
R
.
string
.
add_profile
),
android
.
R
.
drawable
.
ic_menu_add
,
add
Profile
)
new
Item
(-
400
,
getString
(
R
.
string
.
add_profile
),
android
.
R
.
drawable
.
ic_menu_add
,
new
Profile
)
buf
+=
new
Category
(
getString
(
R
.
string
.
settings
))
...
...
@@ -827,6 +872,13 @@ class Shadowsocks
}
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
val
scanResult
=
IntentIntegrator
.
parseActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
scanResult
!=
null
)
{
ShadowParser
.
parse
(
scanResult
.
getContents
)
match
{
case
Some
(
profile
)
=>
addProfile
(
profile
)
case
_
=>
// ignore
}
}
else
{
resultCode
match
{
case
Activity
.
RESULT_OK
=>
{
prepared
=
true
...
...
@@ -840,6 +892,7 @@ class Shadowsocks
}
}
}
}
def
isVpnEnabled
:
Boolean
=
{
if
(
Shadowsocks
.
vpnEnabled
<
0
)
{
...
...
src/main/scala/com/github/shadowsocks/utils/ShadowParser.scala
0 → 100644
View file @
1907ac2f
package
com.github.shadowsocks.utils
import
com.github.shadowsocks.database.Profile
import
android.net.Uri
import
android.util.
{
Log
,
Base64
}
object
ShadowParser
{
val
TAG
=
"ShadowParser"
def
parse
(
data
:
String
)
:
Option
[
Profile
]
=
{
try
{
Log
.
d
(
TAG
,
data
)
val
uri
=
Uri
.
parse
(
data
.
trim
)
if
(
uri
.
isOpaque
&&
uri
.
getScheme
==
"shadow"
)
{
val
encoded
=
data
.
replace
(
"shadow:"
,
""
)
val
content
=
new
String
(
Base64
.
decode
(
encoded
,
Base64
.
NO_PADDING
),
"UTF-8"
)
val
info
=
content
.
split
(
'@'
)
val
encinfo
=
info
(
0
).
split
(
':'
)
val
serverinfo
=
info
(
1
).
split
(
':'
)
val
profile
=
new
Profile
profile
.
name
=
serverinfo
(
0
)
profile
.
host
=
serverinfo
(
0
)
profile
.
remotePort
=
serverinfo
(
1
).
toInt
profile
.
localPort
=
1080
profile
.
method
=
encinfo
(
0
)
profile
.
password
=
encinfo
(
1
)
return
Some
(
profile
)
}
}
catch
{
case
ex
:
Exception
=>
Log
.
e
(
TAG
,
"parser error"
,
ex
)
// Ignore
}
None
}
}
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