library-ui: install custom splash, never held, no exit animation
- Commit
ea8f20b0b288b5f189f794557a060c0405f30577- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-05 22:54 UTC (4 hours ago)
- Parents
209695e
MaActivity and MaFragmentActivity now call installSplashScreen()
(androidx.core:core-splashscreen 1.2.0, added to the version catalog
and :library:ui as implementation) before super.onCreate, via a small
shared installCustomSplash() helper:
- setKeepOnScreenCondition { false }: no enforced hold and no
artificial delay; the splash exits as soon as the first frame is
ready.
- setOnExitAnimationListener { it.remove() }: zero-duration exit
instead of the system fade/scale. The splash background is the
window background, so instant removal is invisible; a fade would
only linger. (The repo's Motion tokens are Compose easings and do
not govern this framework view animation, so no fade is faked from
them.)
Every launcher activity already extends one of these two shells, so
no app code changes. Activities that do not use the shells still get
the themed system splash; only the exit behaviour defaults to the
system's.
Verified: :library:ui lint/lintVitalRelease pass and the
representative apps build green (see previous commits). :library:ui
ktlintCheck still fails on pre-existing violations in untouched files
(OdfSerializer.kt, ZoomState.kt) on current main; MaActivity.kt itself
is clean and no ktlint backlog was taken on here.Diff
gradle/libs.versions.toml
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex e86505a25d..4964259be1 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -36,6 +36,7 @@ kotlinxDatetime = "0.8.0" # AndroidX – core & lifecycle coreKtx = "1.19.1"+coreSplashscreen = "1.2.0" fragmentKtx = "1.9.1" lifecycle = "2.11.0" savedstate = "1.5.0"@@ -218,6 +219,7 @@ kotlin-parcelize-runtime = { group = "org.jetbrains.kotlin", name = "kotlin-parc # AndroidX – core & lifecycle androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }+androidx-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "coreSplashscreen" } androidx-fragment-ktx = { group = "androidx.fragment", name = "fragment-ktx", version.ref = "fragmentKtx" } androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" } androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
library/ui/AGENTS.md
diff --git a/library/ui/AGENTS.md b/library/ui/AGENTS.mdindex f485efa276..f29467e5ab 100644--- a/library/ui/AGENTS.md+++ b/library/ui/AGENTS.md@@ -27,7 +27,7 @@ ## Key files ### Shell + scaffolds — start here-- com/vayunmathur/library/ui/MaActivity.kt — shared activity shell (incl. `MaFragmentActivity`); `deferAfterFirstFrame` queues non-essential startup work past the first drawn frame+- com/vayunmathur/library/ui/MaActivity.kt — shared activity shell (incl. `MaFragmentActivity`); installs the custom splash (`installSplashScreen`, never held, no exit animation — the theme in `:library` supplies icon/background) before `super.onCreate`; `deferAfterFirstFrame` queues non-essential startup work past the first drawn frame - com/vayunmathur/library/ui/StartupTiming.kt — permanent cold-start marks (activityCreate→firstFrame, logged via `Log`) + `FirstFrameGate`/`StartupMarks` - com/vayunmathur/library/ui/AppScaffold.kt - com/vayunmathur/library/ui/DetailScaffold.kt
library/ui/build.gradle.kts
diff --git a/library/ui/build.gradle.kts b/library/ui/build.gradle.ktsindex c4549d90fa..f196141977 100644--- a/library/ui/build.gradle.kts+++ b/library/ui/build.gradle.kts@@ -35,6 +35,10 @@ dependencies { // on every app's compile classpath. R8 strips them from APKs whose app never touches // a fragment (only passwords/photos keep them, and they already ship fragment anyway). api(libs.androidx.fragment.ktx)+ // MaActivity/MaFragmentActivity install the Android 12+ splash (see library+ // Theme.General for its icon/background). Apps never name this type, but the+ // splash view is created against the activity, so it ships as implementation.+ implementation(libs.androidx.core.splashscreen) // NavigationSuiteScaffold / currentWindowAdaptiveInfo used (via the facade) by openassistant. api(libs.androidx.compose.material3.adaptive.navigation.suite) // V2 adaptive info (currentWindowAdaptiveInfoV2) used by the facade in MaterialFunctions.kt.
library/ui/src/main/java/com/vayunmathur/library/ui/MaActivity.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/MaActivity.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/MaActivity.ktindex 5ec896325e..113f14133e 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/MaActivity.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/MaActivity.kt@@ -5,6 +5,7 @@ import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.compose.runtime.Composable+import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.fragment.app.FragmentActivity /**@@ -21,6 +22,11 @@ import androidx.fragment.app.FragmentActivity * notification channels, intent capture). `onNewIntent` / `onStart` / * `onStop` / `onDestroy` overrides stay in the app untouched. *+ * Cold start shows the shared custom splash (the app's launcher icon on the+ * theme background, from `Theme.General` in `:library`) via+ * [installCustomSplash]: it is never held and has no exit animation, so the+ * first frame replaces it the moment that frame is ready.+ * * Apps with their own theme (a game theme, office's dark chrome, the TV * receiver theme) override [AppTheme]; the one TV activity without * edge-to-edge sets [edgeToEdge] to false.@@ -32,6 +38,7 @@ abstract class MaActivity : ComponentActivity() { private val firstFrameGate = FirstFrameGate() override fun onCreate(savedInstanceState: Bundle?) {+ installCustomSplash() StartupTiming.mark(StartupMarks.ACTIVITY_CREATE) super.onCreate(savedInstanceState) if (edgeToEdge) applyEdgeToEdge()@@ -102,6 +109,7 @@ abstract class MaFragmentActivity : FragmentActivity() { private val firstFrameGate = FirstFrameGate() override fun onCreate(savedInstanceState: Bundle?) {+ installCustomSplash() StartupTiming.mark(StartupMarks.ACTIVITY_CREATE) super.onCreate(savedInstanceState) if (edgeToEdge) applyEdgeToEdge()@@ -141,3 +149,17 @@ abstract class MaFragmentActivity : FragmentActivity() { firstFrameGate.attach(this, window.decorView) } }++/**+ * Installs the Android 12+ splash for a shared-shell activity. Must run+ * before `super.onCreate`. The splash is never kept on screen (the first+ * frame dismisses it as soon as it is ready — no artificial hold), and the+ * exit listener removes the splash view immediately instead of playing the+ * system exit animation: the splash background is the window background, so+ * an instant removal is invisible, while any fade would only linger.+ */+private fun ComponentActivity.installCustomSplash() {+ val splash = installSplashScreen()+ splash.setKeepOnScreenCondition { false }+ splash.setOnExitAnimationListener { provider -> provider.remove() }+}