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
8e46be59
Commit
8e46be59
authored
Dec 29, 2016
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow user to use any QR code scanner
parent
2e737418
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
15 deletions
+11
-15
build.sbt
build.sbt
+0
-1
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
+11
-14
No files found.
build.sbt
View file @
8e46be59
...
...
@@ -52,7 +52,6 @@ libraryDependencies ++=
"com.twofortyfouram"
%
"android-plugin-api-for-locale"
%
"1.0.2"
::
"dnsjava"
%
"dnsjava"
%
"2.1.7"
::
"eu.chainfire"
%
"libsuperuser"
%
"1.0.0.201608240809"
::
"com.google.zxing"
%
"android-integration"
%
"3.2.1"
::
"net.glxn.qrgen"
%
"android"
%
"2.0"
::
Nil
...
...
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
8e46be59
...
...
@@ -37,13 +37,14 @@ import com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.utils._
import
com.github.shadowsocks.widget.UndoSnackbarManager
import
com.google.android.gms.ads.
{
AdRequest
,
AdSize
,
NativeExpressAdView
}
import
com.google.zxing.integration.android.IntentIntegrator
import
scala.collection.mutable.ArrayBuffer
import
scala.util.Random
object
ProfilesFragment
{
var
instance
:
ProfilesFragment
=
_
// used for callback from ProfileManager and stateChanged from MainActivity
private
final
val
REQUEST_SCAN_QR_CODE
=
0
}
final
class
ProfilesFragment
extends
ToolbarFragment
with
Toolbar
.
OnMenuItemClickListener
{
...
...
@@ -304,23 +305,19 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
super
.
onDestroy
()
}
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
super
.
onActivityResult
(
resultCode
,
resultCode
,
data
)
val
scanResult
=
IntentIntegrator
.
parseActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
scanResult
!=
null
)
{
val
contents
=
scanResult
.
getContents
if
(!
TextUtils
.
isEmpty
(
contents
))
Parser
.
findAll
(
contents
).
foreach
(
app
.
profileManager
.
createProfile
)
}
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
:
Unit
=
requestCode
match
{
case
REQUEST_SCAN_QR_CODE
=>
val
contents
=
data
.
getStringExtra
(
"SCAN_RESULT"
)
if
(!
TextUtils
.
isEmpty
(
contents
))
Parser
.
findAll
(
contents
).
foreach
(
app
.
profileManager
.
createProfile
)
case
_
=>
super
.
onActivityResult
(
resultCode
,
resultCode
,
data
)
}
def
onMenuItemClick
(
item
:
MenuItem
)
:
Boolean
=
item
.
getItemId
match
{
case
R
.
id
.
action_scan_qr_code
=>
val
integrator
=
new
IntentIntegrator
(
this
)
val
list
=
new
java
.
util
.
ArrayList
(
IntentIntegrator
.
TARGET_ALL_KNOWN
)
list
.
add
(
"tw.com.quickmark"
)
integrator
.
setTargetApplications
(
list
)
integrator
.
initiateScan
()
startActivityForResult
(
new
Intent
(
"com.google.zxing.client.android.SCAN"
)
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
)
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_NEW_DOCUMENT
),
REQUEST_SCAN_QR_CODE
)
true
case
R
.
id
.
action_import
=>
if
(
clipboard
.
hasPrimaryClip
)
{
...
...
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