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
1ffd1326
Commit
1ffd1326
authored
Dec 29, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use internal scanner as fallback
parent
4ddebb7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
8 deletions
+33
-8
build.sbt
build.sbt
+1
-0
src/main/scala/com/github/shadowsocks/ScannerActivity.scala
src/main/scala/com/github/shadowsocks/ScannerActivity.scala
+32
-8
No files found.
build.sbt
View file @
1ffd1326
...
...
@@ -51,6 +51,7 @@ 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"
::
"me.dm7.barcodescanner"
%
"zxing"
%
"1.9"
::
"net.glxn.qrgen"
%
"android"
%
"2.0"
::
Nil
...
...
src/main/scala/com/github/shadowsocks/ScannerActivity.scala
View file @
1ffd1326
...
...
@@ -21,6 +21,7 @@
package
com.github.shadowsocks
import
android.app.TaskStackBuilder
import
android.content.Intent
import
android.content.pm.
{
PackageManager
,
ShortcutManager
}
import
android.os.
{
Build
,
Bundle
}
import
android.support.v4.app.ActivityCompat
...
...
@@ -32,6 +33,7 @@ import android.widget.Toast
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.utils.Parser
import
com.google.zxing.Result
import
com.google.zxing.integration.android.IntentIntegrator
import
me.dm7.barcodescanner.zxing.ZXingScannerView
object
ScannerActivity
{
...
...
@@ -71,14 +73,21 @@ class ScannerActivity extends AppCompatActivity with ZXingScannerView.ResultHand
override
def
onResume
()
{
super
.
onResume
()
val
permissionCheck
=
ContextCompat
.
checkSelfPermission
(
this
,
android
.
Manifest
.
permission
.
CAMERA
)
if
(
permissionCheck
==
PackageManager
.
PERMISSION_GRANTED
)
{
scannerView
.
setResultHandler
(
this
)
// Register ourselves as a handler for scan results.
scannerView
.
startCamera
()
// Start camera on resume
}
else
{
ActivityCompat
.
requestPermissions
(
this
,
Array
(
android
.
Manifest
.
permission
.
CAMERA
),
MY_PERMISSIONS_REQUEST_CAMERA
)
val
integrator
=
new
IntentIntegrator
(
ScannerActivity
.
this
)
val
list
=
new
java
.
util
.
ArrayList
(
IntentIntegrator
.
TARGET_ALL_KNOWN
)
list
.
add
(
"tw.com.quickmark"
)
integrator
.
setTargetApplications
(
list
)
val
dialog
=
integrator
.
initiateScan
()
if
(
dialog
!=
null
)
{
val
permissionCheck
=
ContextCompat
.
checkSelfPermission
(
this
,
android
.
Manifest
.
permission
.
CAMERA
)
if
(
permissionCheck
==
PackageManager
.
PERMISSION_GRANTED
)
{
scannerView
.
setResultHandler
(
this
)
// Register ourselves as a handler for scan results.
scannerView
.
startCamera
()
// Start camera on resume
}
else
{
ActivityCompat
.
requestPermissions
(
this
,
Array
(
android
.
Manifest
.
permission
.
CAMERA
),
MY_PERMISSIONS_REQUEST_CAMERA
)
}
}
}
...
...
@@ -87,6 +96,21 @@ class ScannerActivity extends AppCompatActivity with ZXingScannerView.ResultHand
scannerView
.
stopCamera
()
// Stop camera on pause
}
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
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
)
val
intent
=
getParentActivityIntent
if
(
shouldUpRecreateTask
(
intent
)
||
isTaskRoot
)
TaskStackBuilder
.
create
(
this
).
addNextIntentWithParentStack
(
intent
).
startActivities
()
else
finish
()
}
else
{
super
.
onActivityResult
(
resultCode
,
resultCode
,
data
)
}
}
override
def
handleResult
(
rawResult
:
Result
)
{
val
uri
=
rawResult
.
getText
if
(!
TextUtils
.
isEmpty
(
uri
))
...
...
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