Skip to content

Flow Configuration

Besides the extension points where client code can plug in customized logic into the flow process, client code can also change the flow process using different settings, such as choosing the preferred activation method, or choosing how to display warning or information messages, either with a dialog or a toast message, etc.

Mobile Service Static Initialization

FlowContext provides the enabledServices parameter that lets client code specify which features to use for mobile applications, for example, UsageService, LogService, etc. The flow component will call the static initializer, which is a foundation module, to initialize these services at the right time.

Sample client code:

val flowContext =
    FlowContextBuilder()
        .setApplication(prepareAppConfig())
        .setMobileServices(getServices())
        .setFlowStateListener(WizardFlowStateListener(application as SAPWizardApplication))
        .build()
Flow.start(this, flowContext = flowContext)

private fun getServices(): List<KClass<out MobileService>> {
    val services = arrayListOf<KClass<out MobileService>>()
    services.add(UsageService::class)
    services.add(PushService::class)
    return services
}
FlowContext flowContext = new FlowContextBuilder()
        .setApplication(prepareAppConfig())
        .setMobileServices(getServices())
        .setFlowStateListener(new WizardFlowStateListener(
                (SAPWizardApplication) getApplication()))
        .build();
Flow.start(this, flowContext);

private List getServices() {
    List services = new ArrayList<>();
    services.add(JvmClassMappingKt.getKotlinClass(UsageService.class));
    services.add(JvmClassMappingKt.getKotlinClass(PushService.class));
    return services;
}

Configuration Options

The client code can set one of two options to determine which activation method to use to show information messages: either with a dialog or a toast message.

To configure these options, use a child class of FlowOptions.

/**
 * Shows the [Info] message either with a dialog or a [Toast]
 */
open fun infoMessageOption(): InfoMessageOption = InfoMessageOption.DIALOG

/**
 * Chooses the activation method: [ActivationOption.CHOOSE_BETWEEN_DS_QR],
 * [ActivationOption.DS_ONLY], or [ActivationOption.QR_ONLY]
 */
open fun activationOption(): ActivationOption = ActivationOption.CHOOSE_BETWEEN_DS_QR

By default, the flow framework uses a dialog to display information messages, and lets the user choose the activation method, either Discovery Service or QR code.

To use this feature, define a child class of FlowOptions and override the two functions, then save an instance of the child class into FlowContext and start a flow.

val flowContext = FlowContext(flowOptions = MyFlowOptions())
Flow.start(activity, flowContext)
FlowContext flowContext = new FlowContextBuilder()
    .setFlowOptions(new MyFlowOptions())
    .build();
Flow.start(activity, flowContext);

Last update: August 12, 2020