Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Page Properties
hiddentrue

Status

Status
titletodo
/
Status
Status
colourPurple
titlestarted
/
colourYellow
titlefor review
/
Status
colourGreen
titleapproved

Approver

Alpar Szotyori (Unlicensed)

On this page:

Table of Contents

Overview

Filter by label (Content by label)showLabelsfalsemax5spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@145a5showSpacefalsesortmodifiedtypepagereversetruelabelskb-how-to-articlecqllabel = "kb-how-to-article" and type = "page" and space = "TSD"To handle imported files using Gini Bank SDK, register an activity result handler with the CaptureFlowImportContract() and pass the incoming intent to GiniBank.startCaptureFlowForIntent():

Code Block
languagekotlin
// Use the androidx's Activity Result API to register a handler for the capture result.
val captureImportLauncher = registerForActivityResult(CaptureFlowImportContract()) { result: CaptureResult ->
    when (result) {
        is CaptureResult.Success -> {
            handleExtractions(result.specificExtractions)
        }
        is CaptureResult.Error -> {
            when (result.value) {
                is ResultError.Capture -> {
                    val captureError: GiniCaptureError = (result.value as ResultError.Capture).giniCaptureError
                    handleCaptureError(captureError)
                }
                is ResultError.FileImport -> {
                    val fileImportError = result.value as ResultError.FileImport
                    handleFileImportError(fileImportError)
                }
            }
        }
        CaptureResult.Empty -> {
            handleNoExtractions()
        }
        CaptureResult.Cancel -> {
            handleCancellation()
        }
    }
}

fun handleFileImportError(exception: ImportedFileValidationException) {
    var message = ...
    exception.validationError?.let { validationError ->
        // Get the default message
        message = getString(validationError.textResource)
        // Or use custom messages
        message = when (validationError) {
            FileImportValidator.Error.TYPE_NOT_SUPPORTED -> ...
            FileImportValidator.Error.SIZE_TOO_LARGE -> ...
            FileImportValidator.Error.TOO_MANY_PDF_PAGES -> ...
            FileImportValidator.Error.PASSWORD_PROTECTED_PDF -> ...
            FileImportValidator.Error.TOO_MANY_DOCUMENT_PAGES -> ...
        }
    }
    AlertDialog.Builder(this)
        .setMessage(message)
        .setPositiveButton("OK") { _, _ -> finish() }
        .show()
}

fun startGiniBankSDKForImportedFile(importedFileIntent: Intent) {
    // Configure capture first
    configureCapture();

    fileImportCancellationToken =
        GiniBank.startCaptureFlowForIntent(captureImportLauncher, this, importedFileIntent)
}