It is a wrap for this Github project. It is 100% embedded in B4A. I have wrapped and posted this project before somewhere else in this forum (here) but this is the latest update of this project that seems to have some major changes. Please note the checkbox setting - it controls a Boolean variable that will determine if the scanned result will be returned to the B4A project or not.
The new Github project has two views - the one is supposed to overlay the other in order to display/highlight the result points. As I was not sure how to wrap the two views so that the one could overlay the other, I have changed the code in the original Github project in order to incorporate the one view within the other view.
It only shows the 3 or 4 most outlaying result points (based on the version of the QR code)
Posting the following:
1. B4A library files
2. B4A sample project
Note that it only scans QR Codes.
Sample code:
Library:
NewQRCodeReaderView
Author: Github: David Lazaro, Wrapped by: Johan Schoeman
Version: 1.01
The new Github project has two views - the one is supposed to overlay the other in order to display/highlight the result points. As I was not sure how to wrap the two views so that the one could overlay the other, I have changed the code in the original Github project in order to incorporate the one view within the other view.
It only shows the 3 or 4 most outlaying result points (based on the version of the QR code)
Posting the following:
1. B4A library files
2. B4A sample project
Note that it only scans QR Codes.
Sample code:
B4X:
#Region Project Attributes
#ApplicationLabel: b4NewQRCodeReaderView
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#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
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 nqrcrv As NewQRCodeReaderView
Private Button1 As Button
Private torchOn As Boolean = False
Private Button2 As Button
Private Button3 As Button
Private prevscan As String = ""
Private Label1 As Label
Private CheckBox1 As CheckBox
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")
nativeMe.InitializeContext
nqrcrv.QRDecodingEnabled = True
nqrcrv.AutofocusInterval = 500
nqrcrv.ScanNow = False
nqrcrv.Visible = False
nqrcrv.ResultPointColor = Colors.Red
CheckBox1.Checked = False
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
torchOn = False
CheckBox1.Checked = False
nqrcrv.stopCamera
prevscan = ""
End Sub
Sub nqrcrv_result_found(retval As String)
If prevscan = retval Then
'Log("same scan")
prevscan = retval
Else
Log("b4aResult = " & retval)
prevscan = retval
nativeMe.RunMethod("playTone", Null)
End If
End Sub
Sub Button1_Click
If nqrcrv.Visible = True Then
If torchOn = False Then
nqrcrv.TorchEnabled = True
torchOn = True
Else
nqrcrv.TorchEnabled = False
torchOn = False
End If
End If
End Sub
Sub Button2_Click
nqrcrv.Visible = True
nqrcrv.setBackCamera
nqrcrv.startCamera
End Sub
Sub Button3_Click
nqrcrv.Visible = False
CheckBox1.Checked = False
nqrcrv.stopCamera
prevscan = ""
End Sub
Sub CheckBox1_CheckedChange(Checked As Boolean)
If Checked = True Then
nqrcrv.ScanNow = True
Else
nqrcrv.ScanNow = False
End If
End Sub
#if Java
import android.media.ToneGenerator;
import android.media.AudioManager;
public void playTone() {
final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
tg.startTone(ToneGenerator.TONE_PROP_BEEP);
}
#End If
Library:
NewQRCodeReaderView
Author: Github: David Lazaro, Wrapped by: Johan Schoeman
Version: 1.01
- NewQRCodeReaderView
Events:- result_found (retval As String)
- ba As BA
- BringToFront
- DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
- Initialize (EventName As String)
- Invalidate
- Invalidate2 (arg0 As Rect)
- Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- IsInitialized As Boolean
- RemoveView
- RequestFocus As Boolean
- SendToBack
- SetBackgroundImage (arg0 As Bitmap)
- SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
- SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
- SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
- forceAutoFocus
Trigger an auto focus - setBackCamera
Camera preview from device back camera - setFrontCamera
Camera preview from device front camera - startCamera
Starts camera preview and decoding - stopCamera
Stop camera preview and decoding
- android.hardware.camera
- android.hardware.camera.autofocus
- android.permission.CAMERA
- AutofocusInterval As Long [write only]
Set Camera autofocus interval value
default value is 5000 ms. - Background As Drawable
- Color As Int [write only]
- Enabled As Boolean
- Height As Int
- Left As Int
- Padding()() As Int
- Parent As Object [read only]
- PreviewCameraId As Int [write only]
Allows user to specify the camera ID, rather than determine
it automatically based on available cameras and their orientation. - QRDecodingEnabled As Boolean [write only]
- ResultPointColor As Int [write only]
- ScanNow As Boolean [write only]
- Tag As Object
- Top As Int
- TorchEnabled As Boolean [write only]
Set Torch enabled/disabled.
default value is false - Visible As Boolean
- Width As Int
Attachments
Last edited: