Application Themes¶
The Application Themes module allows you to download custom theming files for an application at runtime. The application is then responsible for providing these files to the Fiori UI Theming component.
Downloading Themes¶
Two APIs are provided to download theme files from the mobile server:
suspend fun downloadTheme(host: String, appID: String, protocol: String = "https", port: Int = 443, silent: Boolean = false): ServiceResult<List<String>> = withContext(IO) { ... }
suspend fun downloadTheme(serviceUrl: String, appID: String, silent: Boolean = false): ServiceResult<List<String>> { ... }
Both APIs will run on the IO thread and return the result using ServiceResult. The result is a list of downloaded theme file paths. To download theme files, set appID and host or serviceUrl. Other parameters have default values and can be left alone.
Sample usage:
runOnUiThread(() -> new ThemeDownloadService(context).downloadTheme("https://example/mobileservices", "com.sap.wizapp", false, new Continuation<ServiceResult<List<String>>>() {
@NonNull
@Override
public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
@Override
public void resumeWith(@NonNull Object o) {
if (o instanceof ServiceResult.SUCCESS) {
String filePaths = ((ServiceResult.SUCCESS<?>) o).getData().toString();
...
} else {
Log.e("TEST", ((ServiceResult.FAILURE<?>) o).getMessage());
}
}
}));
MainScope().launch {
when(val result = ThemeDownloadService(context).downloadTheme(serviceUrl = "https://example/mobileservices", appID = "com.sap.wizapp")) {
is ServiceResult.SUCCESS -> {
result.data?.also { filePaths ->
...
}
}
is ServiceResult.FAILURE -> Log.e("TEST", result.message)
}
}
Get Theme File And Logos¶
There are APIs provided to get a theme file and logos:
getThemeFile()to get the theme file in JSON formatgetLightLogo()to get the logo image for a light themegetDarkLogo()to get the logo image for a dark theme
Last update: November 17, 2022