buildWorkflowSettings
fun buildWorkflowSettings(@DrawableRes scanInstructionsSearchingDrawableId: Int? = null, @DrawableRes scanInstructionsReadingDrawableId: Int? = null, @DrawableRes scanInstructionsSuccessDrawableId: Int? = null, @DrawableRes scanInstructionsFailureDrawableId: Int? = null, @StringRes scanInstructionsTextId: Int? = null, shouldShowFailoverPopup: Boolean? = null, skipVisibilityTimeout: Int? = null, handleOrientation: Boolean? = null): String
Formats an encoded workflow settings JSON string for this fragment to use with MiSnapSettings.Workflow.add.
Return
String with the relevant settings, pass it into MiSnapSettings.Workflow.add along with the Fragment's label to apply the settings.
Parameters
scanInstructionsSearchingDrawableId
Formats the SCAN_INSTRUCTIONS_SEARCHING_DRAWABLE_ID.
scanInstructionsReadingDrawableId
Formats the SCAN_INSTRUCTIONS_READING_DRAWABLE_ID.
scanInstructionsSuccessDrawableId
Formats the SCAN_INSTRUCTIONS_SUCCESS_DRAWABLE_ID.
scanInstructionsFailureDrawableId
Formats the SCAN_INSTRUCTIONS_FAILURE_DRAWABLE_ID.
scanInstructionsTextId
Formats the SCAN_INSTRUCTIONS_TEXT_ID.
shouldShowFailoverPopup
Formats the SHOULD_SHOW_FAILOVER_POPUP.
skipVisibilityTimeout
Formats the SKIP_VISIBILITY_TIMEOUT.
handleOrientation
Formats the HANDLE_ORIENTATION.
Samples
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.miteksystems.misnap.apputil.LicenseFetcher
import com.miteksystems.misnap.R
import com.miteksystems.misnap.core.MiSnapSettings
import com.miteksystems.misnap.workflow.fragment.DocumentAnalysisFragment
import com.miteksystems.misnap.workflow.fragment.DocumentAnalysisFragment.ReviewCondition
import com.miteksystems.misnap.workflow.fragment.HelpFragment
fun main() {
//sampleStart
/**
* This example demonstrates the customization of the MiSnap SDK UI and behavior through the use
* of a [MiSnapSettings] object. This is the most straight-forward way of customizing the workflow
* as it uses the main configuration object.
*
* Please refer to the "buildWorkflowSettings" method of the fragment you want to customize for the
* full list of customization options.
*
* NOTE: Ensure that the provided license has all the necessary features enabled for the target
* MiSnap session.
*
* @see com.miteksystems.misnap.examples.settings.FragmentArguments for an example on how to customize
* the UI and behavior using [Bundle]s instead.
*/
class WorkflowSettings : AppCompatActivity() {
/**
* Fetch the Misnap SDK license.
* Good practice: Handle the license in a way that it is remotely updatable.
*/
private val license by lazy {
LicenseFetcher.fetch()
}
override fun onStart() {
super.onStart()
/**
* Use the method "buildWorkflowSettings" from the workflow fragment you want to customize to
* create a JSON string that can be added to [MiSnapSettings.workflow] to apply your customizations.
*/
val helpFragmentWorkflowSettings =
HelpFragment.buildWorkflowSettings(showSkipCheckBox = false)
val documentAnalysisFragmentWorkflowSettings =
DocumentAnalysisFragment.buildWorkflowSettings(
timeoutDuration = 15_000,
manualButtonDrawableId = android.R.drawable.ic_menu_camera,
guideViewShowVignette = true,
hintViewShouldShowBackground = true,
successViewShouldVibrate = true,
reviewCondition = ReviewCondition.ALWAYS,
shouldShowCancelButton = true,
cancelButtonDrawableId = android.R.drawable.ic_menu_close_clear_cancel,
)
/**
* Identify the label of the fragment you want to customize from the strings, then use it along the
* JSON formatted workflow settings from the "buildWorkflowSettings" method to add them to the
* [MiSnapSettings.workflow] map.
* The label corresponds to the one used in the fragment element of the navigation graph in
* which is included.
* Use the built settings with your preferred integration type.
*
* NOTE: See the different navgraphs included in the Workflow module for the full list of fragment
* labels used.
*/
val settings = MiSnapSettings(MiSnapSettings.UseCase.ID_FRONT, license).apply {
workflow.add(
getString(R.string.misnapWorkflowDocumentAnalysisFlowHelpFragmentLabel),
helpFragmentWorkflowSettings
)
workflow.add(
getString(R.string.misnapWorkflowDocumentAnalysisFlowDocumentAnalysisFragmentLabel),
documentAnalysisFragmentWorkflowSettings
)
}
}
}
//sampleEnd
}