buildWorkflowSettings
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
Formats the GUIDE_VIEW_DRAWABLE_ID
Formats the GUIDE_VIEW_ALIGNED_SCALE_PERCENTAGE
Formats the GUIDE_VIEW_UNALIGNED_SCALE_PERCENTAGE
Formats the GUIDE_VIEW_SHOW_VIGNETTE
Formats the MANUAL_BUTTON_DRAWABLE_ID
Formats the TORCH_VIEW_ON_DRAWABLE_ID
Formats the TORCH_VIEW_OFF_DRAWABLE_ID
Formats the RECORDING_ICON_DRAWABLE_ID
Formats the RECORDING_ICON_ANIMATION_ID
Formats the HELP_BUTTON_DRAWABLE_ID
Formats the SUCCESS_VIEW_MESSAGE_DRAWABLE_ID
Formats the SUCCESS_VIEW_MESSAGE_ANIMATION_ID
Formats the SUCCESS_VIEW_BACKGROUND_DRAWABLE_ID
Formats the SUCCESS_VIEW_SHOULD_VIBRATE
Formats the SUCCESS_VIEW_SOUND_URI
Formats the REVIEW_CONDITION
Formats the HANDLE_ORIENTATION
Formats the SHOW_CANCEL_BUTTON
Formats the CANCEL_BUTTON_DRAWABLE_ID
Formats the SHOW_BARCODE_LABEL
Formats the BARCODE_LABEL_STRING_ID
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
}