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 ++=
...
@@ -52,7 +52,6 @@ libraryDependencies ++=
"com.twofortyfouram"
%
"android-plugin-api-for-locale"
%
"1.0.2"
::
"com.twofortyfouram"
%
"android-plugin-api-for-locale"
%
"1.0.2"
::
"dnsjava"
%
"dnsjava"
%
"2.1.7"
::
"dnsjava"
%
"dnsjava"
%
"2.1.7"
::
"eu.chainfire"
%
"libsuperuser"
%
"1.0.0.201608240809"
::
"eu.chainfire"
%
"libsuperuser"
%
"1.0.0.201608240809"
::
"com.google.zxing"
%
"android-integration"
%
"3.2.1"
::
"net.glxn.qrgen"
%
"android"
%
"2.0"
::
"net.glxn.qrgen"
%
"android"
%
"2.0"
::
Nil
Nil
...
...
src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
View file @
8e46be59
...
@@ -37,13 +37,14 @@ import com.github.shadowsocks.database.Profile
...
@@ -37,13 +37,14 @@ import com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.utils._
import
com.github.shadowsocks.utils._
import
com.github.shadowsocks.widget.UndoSnackbarManager
import
com.github.shadowsocks.widget.UndoSnackbarManager
import
com.google.android.gms.ads.
{
AdRequest
,
AdSize
,
NativeExpressAdView
}
import
com.google.android.gms.ads.
{
AdRequest
,
AdSize
,
NativeExpressAdView
}
import
com.google.zxing.integration.android.IntentIntegrator
import
scala.collection.mutable.ArrayBuffer
import
scala.collection.mutable.ArrayBuffer
import
scala.util.Random
import
scala.util.Random
object
ProfilesFragment
{
object
ProfilesFragment
{
var
instance
:
ProfilesFragment
=
_
// used for callback from ProfileManager and stateChanged from MainActivity
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
{
final
class
ProfilesFragment
extends
ToolbarFragment
with
Toolbar
.
OnMenuItemClickListener
{
...
@@ -304,23 +305,19 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
...
@@ -304,23 +305,19 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
super
.
onDestroy
()
super
.
onDestroy
()
}
}
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
:
Unit
=
requestCode
match
{
super
.
onActivityResult
(
resultCode
,
resultCode
,
data
)
case
REQUEST_SCAN_QR_CODE
=>
val
scanResult
=
IntentIntegrator
.
parseActivityResult
(
requestCode
,
resultCode
,
data
)
val
contents
=
data
.
getStringExtra
(
"SCAN_RESULT"
)
if
(
scanResult
!=
null
)
{
if
(!
TextUtils
.
isEmpty
(
contents
))
Parser
.
findAll
(
contents
).
foreach
(
app
.
profileManager
.
createProfile
)
val
contents
=
scanResult
.
getContents
case
_
=>
super
.
onActivityResult
(
resultCode
,
resultCode
,
data
)
if
(!
TextUtils
.
isEmpty
(
contents
))
Parser
.
findAll
(
contents
).
foreach
(
app
.
profileManager
.
createProfile
)
}
}
}
def
onMenuItemClick
(
item
:
MenuItem
)
:
Boolean
=
item
.
getItemId
match
{
def
onMenuItemClick
(
item
:
MenuItem
)
:
Boolean
=
item
.
getItemId
match
{
case
R
.
id
.
action_scan_qr_code
=>
case
R
.
id
.
action_scan_qr_code
=>
val
integrator
=
new
IntentIntegrator
(
this
)
startActivityForResult
(
new
Intent
(
"com.google.zxing.client.android.SCAN"
)
val
list
=
new
java
.
util
.
ArrayList
(
IntentIntegrator
.
TARGET_ALL_KNOWN
)
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
)
list
.
add
(
"tw.com.quickmark"
)
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
|
Intent
.
FLAG_ACTIVITY_NEW_DOCUMENT
),
integrator
.
setTargetApplications
(
list
)
REQUEST_SCAN_QR_CODE
)
integrator
.
initiateScan
()
true
true
case
R
.
id
.
action_import
=>
case
R
.
id
.
action_import
=>
if
(
clipboard
.
hasPrimaryClip
)
{
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