File upload and QR management - Capture
Introduction
Document capture and QR reading and generation are performed with the CaptureComponent.
This component allows documents to be uploaded by taking a photo with the device camera or selecting one from the gallery.
Dependency
The component’s specific dependency is:
implementation "com.facephi.androidsdk:capture_component:$version"Available controllers
Controller
Description
FileUploaderController
Controller for document capture
QrReaderController
Controller for QR capture
QrGeneratorController
Controller for QR generation
Simplified Launch
Once the SDK has been initialized and a new operation has been created, the component can be launched. Any of its controllers can be used to execute its functionality.
Launching document capture:
Launching QR capture:
Launching QR generation:
Basic configuration
For the component capture and QR capture controllers, the configuration can be generated using the default parameters. For QR generation, the text to be used must be provided:
Receiving the result
Launching the component returns the information in SdkResult format. The result can be either a successful or an unsuccessful launch:
Receiving errors
Errors are returned as a 'CaptureError' object.
List of errors:
ACTIVITY_RESULT_MSG_ERROR(CAP_855): The result returned by the activity is incorrect or does not contain the information needed to continue.APPLICATION_CONTEXT_ERROR(CAP_856): The required application context is null or invalid, preventing the capture module from being initialized correctly.CAMERA_ERROR(CAP_853): An internal error related to the device camera has occurred (opening, initialization, or capture failure).CAMERA_PERMISSION_DENIED(CAP_852): The user denied the permissions required to access the camera.CANCEL_BY_USER(CAP_000): The user manually canceled the capture process.CANCEL_LAUNCH(CAP_007): The process was canceled generally by the SDK or by an external action.COMPONENT_LICENSE_ERROR(CAP_002): The component license is invalid, has expired, or does not match the required configuration.EMPTY_LICENSE(CAP_003): The license string is empty or was not provided.FETCH_DATA_ERROR(CAP_858): An error occurred while fetching or processing the data required to execute the flow. (Includes additional information in theerror.)FLOW_ERROR(CAP_863): An internal error occurred during the execution of the capture flow. (Includes additional information in theerror.)INITIALIZATION_ERROR(CAP_004): Error initializing the SDK components required. (Includes detailed information in theerror.)FILE_UPLOADER_CAPTURE_ERROR(CAP_850): Error during the upload of files generated during capture.INTERNAL_ERROR(CAP_861): Unexpected internal error during execution. (Includes additional information in theerror.)IMAGE_TOO_LARGE(CAP_862): The image selected from the gallery exceeds the maximum size configured inmaxGalleryImageSizeKb.MANAGER_NOT_INITIALIZED(CAP_857): The managers required to execute the process have not been initialized correctly.NO_DATA_ERROR(CAP_005): The required input data is null, missing, or insufficient to continue the process.OPERATION_NOT_CREATED(CAP_006): Could not create or retrieve an active operation required to continue. (Includes detailed information in theerror.)QR_CAPTURE_ERROR(CAP_851): Error during QR Code capture or scanning.QR_GENERATION_ERROR(CAP_854): Error generating the requested QR Code.TIMEOUT(CAP_001): The maximum allowed time was reached during one of the process stages.FLOW_VIDEO_RECORDING_ERROR(CAP_859): Error during Video Recording within the established flow.FLOW_TRACKING_ERROR(CAP_860): Error performing the tracking required to complete the capture flow.
Receiving the successful result - data
Receiving the document capture result
In the SdkResult.Success section - data, we will have the FileUploaderResult.
The fields returned in the result are as follows:
capturedDocumentList
List of captured files. These may be images or PDFs. The fields returned for each are:
mimeType:
StringtimestampMillis:
Longcontent:
FileContent. Document content. This differs depending on whether it is an image or a PDF document. To distinguish between them:
Fields for each content type:
FileContent.UploaderImage:image:SdkImage. Captured image.rotationDegrees:Int. Image rotation in degrees.source:FileUploaderSource. Image source. Possible values:CAMERA,GALLERY.
FileContent.UploaderDocument:frontPageImage:SdkImage?. Image of the first page of the PDF (may be null).bytes:ByteArray. PDF content.
Receiving the QR capture result
In the SdkResult.Success section - data, we will have the QrResult.
The fields returned in the result are as follows:
qrText
Text obtained from the QR code
Receiving the QR generation result
In the SdkResult.Success section - data, we will have an SdkImage with the generated QR code.
Advanced information
This section provides more information about the component.
Advanced component configuration
Document capture configuration
To launch this component, you must create a FileUploaderConfigurationData object, which will be the component controller's configuration.
All the fields that make up this class are detailed below.
vibrationEnabled:Boolean. Indicates whether vibration is enabled when the widget completes successfully. Defaults totrue.extractionTimeout:Long. Sets the maximum time allowed for capture, in milliseconds. Defaults to60000.showDiagnostic:Boolean. Show diagnostic screens at the end of the process. Defaults totrue.showPreviousTip:Boolean. Shows a screen before capture starts, with information about the process to be carried out and a button to start it. Defaults totrue.maxScannedDocs:Int. Maximum number of documents that can be captured. Defaults to2.allowGallery:Boolean. Enables access to the gallery to retrieve images or PDFs. Defaults totrue.onlyGalleryMode:Boolean. If enabled, the flow opens directly in gallery mode and does not show camera capture. Defaults totrue.maxGalleryImageSizeKb:Int. Maximum allowed size for images selected from the gallery, in KB. Defaults to2048; if this limit is exceeded,CAP_IMAGE_TOO_LARGE.
QR capture configuration
To launch this component, you must create a QrCaptureConfigurationData object, which will be the component controller's configuration.
All the fields that make up this class are detailed below.
vibrationEnabled:Boolean. Indicates whether vibration is enabled when the widget completes successfully. Defaults totrue.extractionTimeout:Long. Sets the maximum time allowed for capture, in milliseconds. Defaults to60000.showDiagnostic:Boolean. Show diagnostic screens at the end of the process. Defaults totrue.showPreviousTip:Boolean. Shows a screen before capture starts, with information about the process to be carried out and a button to start it. Defaults totrue.showTutorial:Boolean. Indicates whether the component displays the tutorial screen. This screen intuitively explains how to capture an image. By defaulttrue.cameraPreferred:Camera. Camera used for capture. Possible values:FRONT,BACK. By defaultBACK.cameraShape:CameraShape. Lets you choose the shape of the camera mask. Possible values:SQUARE,CIRCULAR,RECTANGLE_TALL. By defaultSQUARE.showStroke:Boolean. Displays the border of the camera mask. By defaultfalse.transparentBackground:Boolean. Indicates whether the background of the capture screen is transparent. By defaultfalse.
QR generation configuration
To launch the current component, you must create a QrGeneratorConfiguration object, which will serve as the component controller's configuration.
All the fields that make up this class are detailed below.
source:String. Text used to generate the QR Code. Required.width:Int. Width of the generated image in pixels. By default200.height:Int. Height of the generated image in pixels. By default200.
Component customization
In addition to the changes that can be made at the SDK level (explained in the document (SDK Customization), this specific component also allows its interface to be modified.
Text
To modify the SDK text, include the following XML file in the client application and change the value of each String to the desired text.
Animations
To modify the SDK animations (Lottie), include animations with the same names in the application's res/raw/ folder.
Last updated