Document Capture
This module provides a way to clip and upload the generic documents such as proof of adress, adhering to the desired document type, count, and screen configuration. Document type specifies the type of the document to be loaded and the document builder specifies the display configurations such as colors, text, and how many documents will be taken from camera.
Starting the capture
To capture a document from camera and let the user crop it use the start()
method of this module.
User Interface Settings
// Preparing DocumentBuilder for User Interface && Some Logic Operations
DocBuilder docBuilder = new DocBuilder("Tekrar Dene", // Text label
"Onayla", // Text label
R.color.color_blue, // Text color
R.color.color_blue, // Text color
R.color.white, // Button color
2); // Indicates the number of documents.
Getting the Fragment
//Calling Generic Document Fragment and Uploading Documents (due to lambda function result)
Fragment docFragment = Amani.sharedInstance().Document().start("DOC_TYPE",docBuilder, frameLayout,(docList,isSucess)->{
if (isSuccess) {
//Uploading Generic Documents that taken from camera
Amani.sharedInstance().Document().upload(this,"DOC_TYPE",(isSuccess, result, errors) -> {
if (isSuccess) Toast.makeText(this,"Generic Document Upload is Success", Toast.LENGTH_LONG).show();
else Toast.makeText(this,"Generic Document Upload is Not Success", Toast.LENGTH_SHORT).show();
});
}
});
yourFragmentMethod(docFragment);
Uploading Generic Documents
If you don't want to use the built in crop screen or upload supported file formats directly you can use the methods shown below.
Supported file types are:
- jpg
- png
- webp
- bmp
// Uploading Generic Documents that taken as ByteArray (Not from camera, will be provided from as static data as ArrayList of
//FileWithType data class that will be provided from AmaniSDK.)
FileWithType docData1 = new FileWithType(byteArrayOfPdf,"pdf"); // An object data class first param: byteArray, second param: type (file type: jpeg,pdf,png etc.)
FileWithType docData2 = new FileWithType(byteArrayOfJpeg, "jpeg");
ArrayList<FileWithType> docDataList = new ArrayList<>(); // List of files that will be given to upload.
docDataList.add(docData1); // Adding first document data
docDataList.add(docData2); // Second document data
... // Up to 10 document uploads have been tested without any problems.
Amani.sharedInstance().Document().upload(this,"TUR_ID_1",docDataList,(iSuccess)->{
if (isSuccess)//Upload is succeed
});
Deleting Document Cache Files (Optional usage, NOT Required!)
It provides a way to delete all file that are taken from camera. If you want to call this, you must call this after the upload process is done. Otherwise upload will fail.
Amani.sharedInstance().Document().deleteAllDocumentCaches();