DOT Android Document 9.0.0

This guide describes how to migrate DOT Android Document version 8.x to version 9.0. Only the most important changes are highlighted in this guide. For more details, see the Android Samples.

Migration Steps

Compatibility with DIS

When utilizing DIS for server-side evaluation, ensure compatibility between your DIS version and the corresponding SDK version. Refer to the DIS vs SDKs compatibility table for detailed compatibility information.

SDK initialization

The way DOT SDK libraries are configured has changed.

  • Replace DotSdkConfiguration with DotSdk.Configuration class.
  • Update libraries property of DotSdk.Configuration class.

Before

Libraries were provided as a list of DotLibrary instances.

DotSdkConfiguration(
    //...
    libraries = listOf(
        DotDocumentLibrary(),
        //...
    )
)

After

Libraries are now configured via a single Libraries object, with explicit configuration for each DOT SDK library.

DotSdk.Configuration(
    //...
    libraries = Libraries(
        document = DotDocumentLibraryConfiguration,
        //...
    )
)

UI Document Auto Capture component

The DocumentAutoCaptureFragment class was moved to a new package, and both its API and configuration structure have changed. Existing configuration objects are not compatible with the new API and must be migrated to the new configuration model. Basic migration steps:

  • Replace import com.innovatrics.dot.document.autocapture.DocumentAutoCaptureFragment with import com.innovatrics.dot.document.autocapture.ui.DocumentAutoCaptureFragment.
  • Replace the method stopAsync(...) with the new method stop().
  • Remove the override of the onProcessed() method and override onUiStateUpdated(uiState: UiState) instead. UiState is a sealed interface, and its implementation UiState.Running replaces the data previously delivered via onProcessed() method.
  • Update configuration provided by provideConfiguration() method.

Before

//...
import com.innovatrics.dot.document.autocapture.DocumentAutoCaptureFragment
//...

class BasicDocumentAutoCaptureFragment: DocumentAutoCaptureFragment {

    override fun provideConfiguration(): Configuration {
        return Configuration(
            cameraFacing = CameraFacing.BACK,
            cameraPreviewScaleType = CameraPreviewScaleType.FILL,
            isTorchEnabled = false,
            isVideoCaptureEnabled = true,
            validationMode = ValidationMode.STANDARD,
            qualityAttributeThresholds = QualityAttributeThresholdPresets.standard,
            minValidFramesInRowToStartCandidateSelection = 2,
            candidateSelectionDurationMillis = 2000,
            isDetectionLayerVisible = false,
            mrzValidation = MrzValidation.VALIDATE_ALWAYS,
            sessionToken = "...",
            placeholderType = PlaceholderType.CORNERS_ONLY,
            isCameraPreviewVisible = true,
        )
    }

    override fun onProcessed(detection: DocumentAutoCaptureDetection) {
        //...
    }

    override fun onCaptured(result: DocumentAutoCaptureResult) {
        //...
    }
}

After

//...
import com.innovatrics.dot.document.autocapture.ui.DocumentAutoCaptureFragment
//...

class BasicDocumentAutoCaptureFragment: DocumentAutoCaptureFragment {
  
    override fun provideConfiguration(): Configuration {
        return Configuration(
            base = BaseDocumentAutoCaptureFragment.Configuration(
                common = CommonConfiguration(
                    sessionToken = "...",
                ),
                camera = CameraConfiguration(
                    facing = CameraFacing.BACK,
                    previewScaleType = CameraPreviewScaleType.FILL,
                    isTorchEnabled = false,
                    isVideoCaptureEnabled = true,
                    isPreviewVisible = true,
                ),
                autoCapture = AutoCaptureConfiguration(
                    minValidSamplesInRowToStartCandidateSelection = 2,
                    candidateSelectionDurationMillis = 2000,
                ),
                qualityAttributeThresholds = QualityAttributeThresholds.Presets.standard,
                validationMode = ValidationMode.STANDARD,
                mrzValidation = MrzValidation.REQUIRE_PRESENCE_AND_VALIDITY,
            ),
            placeholder = Placeholder.Visible(
                type = Placeholder.Visible.Type.CORNERS_ONLY,
            ),
            isDetectionLayerVisible = false,
        )
    }

    override fun onUiStateUpdated(uiState: UiState) {
        if (uiState is UiState.Running) {
            //...
        }
    }

    override fun onFinished(result: DocumentAutoCaptureResult) {
        //...
    }
}

Machine Readable Zone Reader

The configuration of the MrzReader has changed from a standalone class to an inner class.

  • Replace MrzReaderConfiguration with MrzReader.Configuration.

Image

Several changes were applied to image-related functionality.

  • BgraRawImage has been replaced by the generic Image class.
  • BgraRawImageFactory has been replaced by ImageFactory.

Before

val image: BgraRawImage = BgraRawImageFactory.create(imageProxy)

After

val image: Image = ImageFactory.createBgraRawImage(imageProxy)