#Region Project Attributes
#ApplicationLabel: ZXingStandAlone
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\ZXingRes
#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.
Private Button1 As Button
Dim zxalone As ZXingStandAlone
Private ImageView1 As ImageView
Private Label1 As Label
Private Label2 As Label
Private Spinner1 As Spinner
Private ImageView2 As ImageView
Private ImageView3 As ImageView
Private ImageView4 As ImageView
Private ImageView5 As ImageView
Dim cntr As Int
Private cb1 As CheckBox
Private cb2 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")
Spinner1.DropdownBackgroundColor = Colors.Blue
Spinner1.DropdownTextColor = Colors.red
Spinner1.AddAll(Array As String("BACK", "FRONT"))
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
Dim laserAlpha() As Int = Array As Int (0, 64, 128, 192, 255, 192, 128, 64)
zxalone.laserAlpha = laserAlpha
zxalone.laserColor = Colors.Magenta
zxalone.maskColor = Colors.ARGB(100,0,0,200)
zxalone.resultColor = Colors.ARGB(100,100,0,100)
zxalone.resultPointColor = Colors.Green
zxalone.CustomPromptMessage = "Posizionare il codice a barre all'interno della vista dello scanner"
zxalone.CustomPromptMessageTextColor = Colors.Yellow
zxalone.CustomPromptMessageTextSize = 20
cntr = 1 'cntr is used to decide what imagview should display the consecutive barcode scans
zxalone.NumberOfScans = 3 'set the number of barcodes to scan before returning to B4A
ImageView1.Bitmap = Null
ImageView2.Bitmap = Null
ImageView3.Bitmap = Null
ImageView4.Bitmap = Null
ImageView5.Bitmap = Null
zxalone.BeginScan("zxalone")
End Sub
Sub Spinner1_ItemClick (Position As Int, Value As Object)
If Spinner1.SelectedIndex = 0 Then zxalone.CameraToUse = zxalone.BACK_CAMERA
If Spinner1.SelectedIndex = 1 Then zxalone.CameraToUse = zxalone.FRONT_CAMERA
End Sub
Sub zxalone_scan_result(barcodetype As String, barcodetext As String, image As Object)
Log("barcode type = " & barcodetype)
Log("barcodetext = " & barcodetext)
Log("cntr = " & cntr)
ImageView1.Gravity = Gravity.FILL
ImageView2.Gravity = Gravity.FILL
ImageView3.Gravity = Gravity.FILL
ImageView4.Gravity = Gravity.FILL
ImageView5.Gravity = Gravity.FILL
ImageView1.Visible = True
ImageView2.Visible = True
ImageView3.Visible = True
ImageView4.Visible = True
ImageView5.Visible = True
ImageView1.BringToFront
ImageView2.BringToFront
ImageView3.BringToFront
ImageView4.BringToFront
ImageView5.BringToFront
Label1.Text = "Last Type Scanned: " & barcodetype
Label2.Text = "Context of last scan: " & barcodetext
If cntr = 1 Then
ImageView1.Bitmap = image
cntr = cntr + 1
else if cntr = 2 Then
ImageView2.Bitmap = image
cntr = cntr + 1
else if cntr = 3 Then
ImageView3.Bitmap = image
cntr = cntr + 1
else if cntr = 4 Then
ImageView4.Bitmap = image
cntr = cntr + 1
else if cntr = 5 Then
ImageView5.Bitmap = image
cntr = cntr + 1
End If
If cntr = 6 Then cntr = 1
End Sub
Sub cb1_CheckedChange(Checked As Boolean)
If Checked = True Then
zxalone.MoveLaserUpDown = True
Else
zxalone.MoveLaserUpDown = False
End If
End Sub
Sub cb2_CheckedChange(Checked As Boolean)
If Checked = True Then
zxalone.ResultPointShape = zxalone.resultpointshape_circle 'can also be zxalone.resultpointshape_circle
Else
zxalone.ResultPointShape = zxalone.resultpointshape_square 'can also be zxalone.resultpointshape_square
End If
End Sub