Splash Screen
The splash screen is the very first Android
View
that is shown in the TomTom
Digital Cockpit at startup. It covers the UI until all frontends with
FrontendCreationPolicy.CREATE_FRONTEND_AT_STARTUP
are initialized. The
design documentation for it can be found
here.
Providing a custom TomTom Digital Cockpit Splash Screen
TomTom Digital Cockpit's default SystemUiHost
requires a
SystemUiHostContext
in its constructor, which in turn takes a
SplashScreenProvider
as constructor arguments. The latter is the interface
that has to be implemented for any splash screen customization.
A splash screen can be provided at different levels with a similar syntax. It can be overridden in
an activity that inherits the TomTom Digital Cockpit DefaultActivity
,
see this
tutorial
to learn more.
As well as passed right in the constructor of SystemUiHostContext
:
1SystemUiHost(2 SystemUiHostContext(3 ...4 splashScreenProvider = object : SplashScreenProvider {5 override fun createSplashScreenView(splashScreenContainer: ViewGroup): View {6 // return any Android View7 }8 }9 )10)
If TomTom Digital Cockpit's DefaultActivity
is used,
getSplashScreenProvider()
can be passed to the SystemUiHostContext
to get
the default TomTom Digital Cockpit splash screen.
In an activity that inherits DefaultActivity
:
1SystemUiHost(2 SystemUiHostContext(3 ...4 getSplashScreenProvider(),5 )6)
If the TomTom Digital Cockpit splash screen is not needed, for example when another system takes
care of showing a splash screen, the SplashScreenProvider
should provide an
empty View
.
1SplashScreenProvider {2 override fun createSplashScreenView(splashScreenContainer: ViewGroup): View {3 return View(splashScreenContainer.context)4 }5}
Running a custom action upon Splash Screen dismissal
TomTom Digital Cockpit allows triggering any action or animation on the splash screen dismissal. To
hook into this mechanism, one needs to observe splashScreenDismissed: LiveData<Boolean>
of the
CoreSystemUiViewModel
.
1coreSystemUiViewModel.splashScreenDismissed.observe(this) { splashScreenDismissed ->2 if (splashScreenDismissed) {3 // Action upon splash screen dismissal4 }5}
Defining frontend creation policies
The splash screen immediately hides after all frontends with
FrontendCreationPolicy.CREATE_FRONTEND_AT_STARTUP
have become ready, and
just before frontends with
FrontendCreationPolicy.CREATE_FRONTEND_AFTER_STARTUP
start initializing.
Frontends with FrontendCreationPolicy.CREATE_FRONTEND_ON_DEMAND
are
created on demand, for example when the user clicks its menu item from the main menu. These are
independent from the splash screen behavior. Frontend readiness is marked by the isReady: LiveData<Boolean>
of the Frontend
. To define a frontend creation policy,
you should pass it to the FrontendConfig
.
1FrontendConfig(2 ...3 creationPolicy = FrontendCreationPolicy.CREATE_AT_STARTUP4)