Skip to content

EULA Screen

This screen is used to display end user license agreements (EULA).

EULA Screen

Definition

@Composable
fun EulaScreen(
    eulaContentLocale: Locale = LocalConfiguration.current.locales.get(0),
    webViewClient: WebViewClient = WebViewClient(),
    eulaScreenSettings: EulaScreenSettings? = null,
    agreeViewClickListener: ViewClickListener? = null,
    disagreeViewClickListener: ViewClickListener? = null
) { ... }

data class EulaScreenSettings(
    val eulaUrl: String = "file:///android_res/raw/eula.html",
    @StringRes val agreeButtonCaption: Int = R.string.eula_agree_button_caption,
    @StringRes val disagreeButtonCaption: Int = R.string.eula_disagree_button_caption,
) : BaseScreenSettings

From the definition of EulaScreenSettings you can see in the source of the EULA content, the two button captions can be customized. When your EULA HTML file is saved in the 'res/raw' folder, you can provide the EULA content in different languages and the SDK can switch to the right version automatically.

The eulaContentLocale argument of the EulaScreen function is used to set the locale of the EULA content. Setting it to a fixed locale will prevent the EULA content switching when the system language changes. If you need the EULA content to reflect the current system language settings, your code needs to make sure that your EULA screen is able to redraw when the configuration changes. Refer to State and Jetpack Compose for information on how to manage the UI states.

Example

val step1 = SingleStep(context, "step_1") {
    EulaScreen(
        eulaContentLocale = localeState.value,
        eulaScreenSettings = EulaScreenSettings(
            eulaUrl = "file:///android_res/raw/custom_eula.html",
            agreeButtonCaption = android.R.string.ok,
            disagreeButtonCaption = android.R.string.cancel
        ),
        agreeViewClickListener = {
            flowDone("step_1")
        },
        disagreeViewClickListener = {
            terminateFlowWithMessage("Custom flow cancelled.")
        },
        webViewClient = object : WebViewClient() {
            override fun shouldOverrideUrlLoading(
                view: WebView?,
                request: WebResourceRequest?
            ): Boolean =
                request?.url?.let { url ->
                    SDKCustomTabsLauncher.launchCustomTabs(context, url.toString())
                    true
                } ?: false
        }
    )
}

addSingleStep(step1)

Last update: February 20, 2023