EULA Screen¶
Introduction¶
This screen is used to display end user license agreements (EULA). The following animation shows this screen as part of the onboarding process, where the user must agree to the terms to complete the onboarding process. The agreement terms can come from either the local file system or the network.
Examples¶
val screen = EulaScreen(getTargetContext())
screen.initialize(
EulaScreenSettings.Builder()
.setAgreeButtonText("Agree")
.setRejectButtonText("Reject")
.setTitle("EULA")
.setEulaUrl("http://www.sap.com") //default to a local HTML file.
.build()
)
screen.setAgreeClickListener {
//agreed, good to go.
}
screen.setRejectClickListener {
//rejected, terminate.
}
screen.setWebViewClientAndLoad(webViewClient)
EulaScreen screen = new EulaScreen(getTargetContext());
EulaScreenSettings ess = new EulaScreenSettings.Builder()
.setAgreeButtonText("Agree")
.setRejectButtonText("Reject")
.setTitle("EULA")
.setEulaUrl("http://www.sap.com")
.build();
screen.initialize(ess);
screen.setAgreeClickListener( v -> {
//agreed, good to go.
});
screen.setRejectClickListener( v -> {
//rejected, terminate.
});
screen.setWebViewClientAndLoad(webViewClient);
Internationalization Support¶
EULA files in different languages can be stored online or locally.
Load EULA Content From Online¶
For the online scenario, there are two options:
- Provide a web URL (
setEulaUrl()
) that links to a EULA stored within a web page where the web page is capable of switching the language based on the device's language setting. - Check the device's language setting first, then set the corresponding URL to the appropriate EULA web page.
Load EULA Content From Local¶
For the local scenario, it is recommended to keep the EULA files in the res/raw
directory. Multiple raw
directories can be created with different qualifiers in the form raw-<qualifier>
, where qualifier
is "language, script (optional), and region (optional)". For example, raw-en
, raw-en-rGB
, raw-fr
and raw-fr-rFR
. Then, EULA files in different languages, but with the same filename, can be stored in the corresponding raw
folder. For additional details, see the Android Developer Guides. The final structure would look like the following screenshot:
In this scenario, a single URL linked to the local raw
directory (for instance: file:///android_res/raw/eula.html
) is sufficient to support internationalization. You must store the default EULA file in the local raw
directory without qualifiers, so that if there is a device language that is not supported yet (no corresponding EULA file has been provided), the device will display the content from the default EULA file. Otherwise, a NotFoundException
will occur, causing a crash.
For EULA files stored in the
res/raw
directory, the data is loaded usingInputStream
and converted toString
. Therefore, you need to ensure that the data can be interpreted correctly when passing the EULA file. In addition, file-based resource names can only consist of lowercase a-z, 0-9, or the underscore.
While storing EULA files elsewhere is feasible, if the storage directory doesn't support qualifiers, then different EULA URLs for corresponding EULA files may be required.
Please note that for the 5.0.0 release of the SDK, the default EULA screen is English and no additional languages are provided "out-of-the-box."