Posting an update - have added some code to the wrapper and the original project:
1. Set the laser color
2. Set the mask color
3. set the status text, text size, and text color
4. set the "possible result points" color and size
5. set the view finder frame color
6. choose between front and back camera (note that I have not added code to test for front and back cameras - you can for eg use
THIS to test for front and back camera being available on a device)
It will return the bitmap of the scanned barcode, the barcode type (eg QR_CODE), and the barcode content/data to the B4A project.
It should scan the following 1D & 2D codes:
UPC_A
UPC_E
EAN_13
EAN_8
RSS_14
CODE_39
CODE_93
CODE_128
ITF
CODABAR
QR_CODE
DATA_MATRIX
PDF_417
AZTEC
MAXICODE
RSS_EXPANDED
UPC_EAN_EXTENSION
Main Activity:
#Region Project Attributes
#ApplicationLabel: AndroidQuickResponseCode
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
'Dim nativeMe As JavaObject
Dim HasAnyActivityPaused As Boolean = False
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Button1 As Button
Dim settings(3) As Boolean
Private ImageView1 As ImageView
Private Label1 As Label
Private Label2 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
ImageView1.Visible = False
Label1.Visible = False
Label2.Visible = False
End Sub
Sub Activity_Resume
HasAnyActivityPaused = False
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
CallSubDelayed2(Main_Scanner, "StartScan", settings)
End Sub
Sub GetResult(retval As List) 'This is called by activity Main_Scanner (with the result of the scan)
HasAnyActivityPaused = False
ImageView1.Bitmap = retval.Get(0) 'the bitmap of the scanned barcode
Log("back in main " & retval.Get(1)) 'the TYPE of barcode that was scanned
Log("back in main " & retval.Get(2)) 'the data that is contained in the barcode
ImageView1.Visible = True
Label1.Text = "Type : " & retval.Get(1)
Label1.Visible = True
Label2.text = "Data : " & retval.Get(2)
Label2.Visible = True
End Sub
Main_Scanner activity:
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim myscan As AndroidQuickResponseCode
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
If Main.HasAnyActivityPaused = False Then
Activity.LoadLayout("main2")
myscan.Initialize("myscan")
Else
Activity.Finish
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Main.HasAnyActivityPaused = True
End Sub
Sub StartScan(settings() As Boolean)
'All of the below are passed to aQrcWrapper.java (setters) and then to various other classes - see comments below
myscan.StatusViewText = "Wrapped by Johan Schoeman" 'it is used in CaptureActivity.java
myscan.StatusViewTextSize = 20 'it is used in CaptureActivity.java
myscan.StatusViewTextColor = Colors.Magenta 'it is used in CaptureActivity.java
myscan.LaserColor = Colors.Yellow 'it is used in ViewfinderView.java
myscan.PossibleResultPointColor = Colors.Red 'it is used in ViewfinderView.java
myscan.PossibleResultPointSize = 8 'it is used in ViewfinderView.java
myscan.ViewfinderFrameColor = Colors.White 'it is used in ViewfinderView.java
myscan.MaskColor = 0x88000088 'it is used in ViewfinderView.java
myscan.CameraToUse = myscan.CAMERA_BACK 'it is used in CameraManager.java
myscan.beginScan
End Sub
Sub myscan_scan_result(image As Object, btype As String, bcontent As String) 'this event is raised by the library when a scan occured
Dim retval As List 'use a list to pass the info back to activity Main
retval.Initialize 'initialize the list
retval.Add(image) 'add the bitmap image to the list
retval.Add(btype) 'add the barcode type to the list
retval.Add(bcontent) 'add the barcode data to the list
CallSubDelayed2(Main, "GetResult", retval) 'pass the scanned result back to the Main activity.
Activity.Finish 'kill this activity so that the Main activity is displayed
End Sub
Library:
AndroidQuickResponseCode
Author: Github: Justin Wetherell, Wrapped by: Johan Schoeman
Version: 1
- AndroidQuickResponseCode
Events:
- scan_result (image As Object, barcodetype As String, barcodecontent As String)
Fields:
- CAMERA_BACK As Int
- CAMERA_FRONT As Int
Methods:
- BeginScan
Called when a view has been clicked.
v: The view that was clicked.
- Initialize (paramString As String)
- IsInitialized As Boolean
Permissions:
- android.hardware.camera
- android.hardware.camera.autofocus
- android.permission.CAMERA
- android.permission.FLASHLIGHT
- android.permission.VIBRATE
- android.permission.WRITE_EXTERNAL_STORAGE
Properties:
- CameraToUse As Int [write only]
- LaserColor As Int [write only]
- MaskColor As Int [write only]
- PossibleResultPointColor As Int [write only]
- PossibleResultPointSize As Int [write only]
- StatusViewText As String [write only]
- StatusViewTextColor As Int [write only]
- StatusViewTextSize As Int [write only]
- ViewfinderFrameColor As Int [write only]
Posting:
1. Updated B4A project
2. The Java Code (only the src folder - see post #1 for the
libs folder)
3. Updated B4A library files (see post #1 for
core-3.2.2-20150819.125554-1.jar)
Take note of the B4A project's manifest file....