I have had the need to make the iBarcode library function more like the Android ZXing barcode app, principally proper control of the torch, return of code type and cosmetics.
To that end I have created a class for my own use which may be of some interest to others.
The attached zip file has the class wrapped in a super simple B4I example which presents as follows:
The class header documentation pretty well explains the intent:
And the documentation of the Initialization method of the class describes the parameters that need to be passed:
This is my first major foray into B4I classes so I would be interested in any feedback about how to do things more elegantly.
The torch stuff relies on:
https://www.b4x.com/android/forum/threads/a-solution-for-getting-ambient-light-brightness.63106/
I am still interested in getting an Objective C expert look over this effort.
Hope this is of benefit to someone...
=================================================
UPDATE - see next post for better class.
To that end I have created a class for my own use which may be of some interest to others.
The attached zip file has the class wrapped in a super simple B4I example which presents as follows:
The class header documentation pretty well explains the intent:
B4X:
'************************************************************************************
'
'This class module wraps the iBarcode library
'
' Features:
'
' o Initial torch on/off state set by reading of ambient light brightness via:
'
' https://www.b4x.com/android/forum/threads/a-solution-for-getting-ambient-light-brightness.63106/
'
' o User can subsequently toggle torch on/off by tapping screen - there ia an
' accompanying prompt on the screen
'
' o A cosmetic overlay to resemble Android ZXing barcode scanner app (full screen
' mode, grayed boundaries and red "scan line")
'
' o Cosmetic overlay and torch prompt visually encourage user to use iPhone in
' landscape mode which experience to date suggests makes scanner read faster
' - works regardless of Main procedure #iPhoneOrientations/#iPadOrientations
' settings
'
' o An audio prompt to tutor user in how to use iPhone as a scanner
'
' o A successful scan triggers an event in parent module - which can then read scan
' code string, scan code type and ambient light brightness reading - scan code
' type extracted via:
'
' https://www.b4x.com/android/forum/threads/ibarcode-lib.49567/#post-317829
'
' Requirements:
'
' o B4I libraries:
'
' iBarcode (version 1.20 or later)
' iPhone (version 1.60 or later) - for TTS
'
' o To allow control of status bar, following must be added to host app:
'
' #Region Project Attributes
'
' 'Following attribute added to hide/show Status Bar, see:
' 'https://www.b4x.com/android/forum/threads/full-screen-apps.47866/#content
' #PlistExtra: <key>UIViewControllerBasedStatusBarAppearance</key><false/>
'
'************************************************************************************
And the documentation of the Initialization method of the class describes the parameters that need to be passed:
B4X:
'************************************************************************************
'
'This procedure gets control when Initialize method is called
'
'Input parameters are:
'
' ZXBC_Parent = pointer to module creating instance of this class
' ZXBC_Event_Name = event name stub
' ZXBC_App = pointer to Application
' ZXBC_NavControl = pointer to NavigationController
' ZXBC_Brightness_Min = brightness level below which torch is initially turned on
' ZXBC_Overlay_Border_Factor = grayed border width as fraction of screen width/height
' ZXBC_Overlay_Alpha = grayed border alpha (0 = transparent, 1 = solid)
' ZXBC_Types = string of acceptable barcode types (e.g. "type_128, type_qr" - not case sensitive, "" for all)
' ZXBC_User_Handedness = user handedness ("L" = left handed, "R" = right handed)
' ZXBC_Audio = text of audio prompt
'
'Returns:
'
' ZXBC_Parent can read .BC_Scan_String, .BC_Scan_Type and .BC_Brightness after
' it receives (ZXBC_Event_Name)_Scan event
'
'Notes on this procedure:
'
' o Initializes and launches barcode scanner
'
'************************************************************************************
This is my first major foray into B4I classes so I would be interested in any feedback about how to do things more elegantly.
The torch stuff relies on:
https://www.b4x.com/android/forum/threads/a-solution-for-getting-ambient-light-brightness.63106/
I am still interested in getting an Objective C expert look over this effort.
Hope this is of benefit to someone...
=================================================
UPDATE - see next post for better class.
Attachments
Last edited: