library: disable the starting window entirely
- Commit
fe8334bf3c5a27eaa8e542b21a34ac05b5fda08b- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-05 18:20 UTC (18 hours ago)
- Parents
33d38a0
Owner follow-up: the blank splash surface was still visible on cold start. Theme.General already made the API 31+ splash invisible (empty icon, duration 0, window-background colour), but the system still drew that surface before the first frame. Add android:windowDisablePreview=true to Theme.General and Theme.General.Translucent in every variant (base, night, v33, night-v33). Per the platform attrs documentation the system can then never use the theme to show a splash/starting window before the activity instance is shown, so the app UI is the first visible frame (WhatsApp-style), with only the launcher icon-press animation as feedback. The invisible-splash attrs are kept as the fallback: AOSP ignores windowDisablePreview for launches from a system surface (HOME/launcher, system, SystemUI - see ActivityRecord.validateStartingWindowTheme), and OEM builds may do the same, in which case the splash surface is still created but remains empty, unanimated and background-matched. A transparent splash background was rejected for the same case: Shell estimates the splash colour from windowBackground when windowSplashScreenBackground is transparent, so it would not be see-through for opaque apps. Translucent already got no starting window (translucent/floating themes are skipped); the flag is explicit there for the same intent. Light/dark correctness is unchanged, and with no preview there is no pre-frame surface that could flash white or black. Verified: :library:lint, :library:lintVitalRelease, :library:assembleRelease and :library:testDebugUnitTest pass (in the combined run); aapt2 dump of the notes release APK shows Theme.General carrying 0x01010222 (windowDisablePreview) =true with the empty splash icon in day and night configs.
Diff
library/src/main/res/values-night-v33/themes.xml
diff --git a/library/src/main/res/values-night-v33/themes.xml b/library/src/main/res/values-night-v33/themes.xmlindex c47ce59cd6..2cff022527 100644--- a/library/src/main/res/values-night-v33/themes.xml+++ b/library/src/main/res/values-night-v33/themes.xml@@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <!-- API 33+ night twin of Theme.General: dark parent, identical no-splash attrs- (empty icon, dark window background). -->+ <!-- API 33+ night twin of Theme.General: dark parent, identical+ no-visible-splash attrs (disablePreview, empty icon, dark background). --> <style name="Theme.General" parent="android:Theme.Material.NoActionBar"> <item name="android:windowSoftInputMode">stateUnchanged</item>+ <item name="android:windowDisablePreview">true</item> <item name="android:windowSplashScreenBackground">?android:attr/colorBackground</item> <item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash_empty</item> <item name="android:windowSplashScreenIconBackgroundColor">@android:color/transparent</item>@@ -16,6 +17,7 @@ window must not paint an opaque background over the calling app. --> <style name="Theme.General.Translucent" parent="android:Theme.Material.NoActionBar"> <item name="android:windowIsTranslucent">true</item>+ <item name="android:windowDisablePreview">true</item> <item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash_empty</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item>
library/src/main/res/values-night/themes.xml
diff --git a/library/src/main/res/values-night/themes.xml b/library/src/main/res/values-night/themes.xmlindex 3b34afa744..d48d074fc8 100644--- a/library/src/main/res/values-night/themes.xml+++ b/library/src/main/res/values-night/themes.xml@@ -1,11 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <!-- Night twin of Theme.General: same style, dark Material parent, so the pre-first-frame- window is dark in dark mode instead of flashing white. Splash attrs mirror day: no- icon, background is the dark window background. -->+ <!-- Night twin of Theme.General: same style, dark Material parent. No visible+ splash (see day twin): disablePreview first, invisible splash as fallback. --> <style name="Theme.General" parent="android:Theme.Material.NoActionBar"> <item name="android:windowSoftInputMode">stateUnchanged</item>+ <item name="android:windowDisablePreview">true</item> <item name="android:windowSplashScreenBackground">?android:attr/colorBackground</item> <item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash_empty</item> <item name="android:windowSplashScreenIconBackgroundColor">@android:color/transparent</item>@@ -17,6 +17,7 @@ window must not paint an opaque background over the calling app. --> <style name="Theme.General.Translucent" parent="android:Theme.Material.NoActionBar"> <item name="android:windowIsTranslucent">true</item>+ <item name="android:windowDisablePreview">true</item> <item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash_empty</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item>
library/src/main/res/values-v33/themes.xml
diff --git a/library/src/main/res/values-v33/themes.xml b/library/src/main/res/values-v33/themes.xmlindex 5dd3e65603..347154dcde 100644--- a/library/src/main/res/values-v33/themes.xml+++ b/library/src/main/res/values-v33/themes.xml@@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <!-- API 33+ twin of Theme.General: identical no-splash attrs (empty icon, window- background). Nothing here re-enables the icon the base file removes. -->+ <!-- API 33+ twin of Theme.General: identical no-visible-splash attrs+ (disablePreview, empty icon, window background). --> <style name="Theme.General" parent="android:Theme.Material.Light.NoActionBar"> <item name="android:windowSoftInputMode">stateUnchanged</item>+ <item name="android:windowDisablePreview">true</item> <item name="android:windowSplashScreenBackground">?android:attr/colorBackground</item> <item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash_empty</item> <item name="android:windowSplashScreenIconBackgroundColor">@android:color/transparent</item>@@ -16,6 +17,7 @@ window must not paint an opaque background over the calling app. --> <style name="Theme.General.Translucent" parent="android:Theme.Material.Light.NoActionBar"> <item name="android:windowIsTranslucent">true</item>+ <item name="android:windowDisablePreview">true</item> <item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash_empty</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item>
library/src/main/res/values/themes.xml
diff --git a/library/src/main/res/values/themes.xml b/library/src/main/res/values/themes.xmlindex b2bda69c97..dcf5b312ab 100644--- a/library/src/main/res/values/themes.xml+++ b/library/src/main/res/values/themes.xml@@ -3,9 +3,13 @@ <style name="Theme.General" parent="android:Theme.Material.Light.NoActionBar"> <item name="android:windowSoftInputMode">stateUnchanged</item>- <!-- No system splash (API 31+ forces the surface, so make it invisible): no icon- (empty animated icon, no disc behind it), no animation, and the background is- the window background so the splash is indistinguishable from the first frame. -->+ <!-- No visible splash: windowDisablePreview stops the system drawing any+ starting window/splash surface before the first app frame, so the app UI+ is the first thing shown. The splash attrs below stay as the fallback for+ launches where the system ignores disablePreview (HOME/system-surface+ launches on some Android versions): empty icon, no disc, no animation,+ background matched to the window background. -->+ <item name="android:windowDisablePreview">true</item> <item name="android:windowSplashScreenBackground">?android:attr/colorBackground</item> <item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash_empty</item> <item name="android:windowSplashScreenIconBackgroundColor">@android:color/transparent</item>@@ -17,6 +21,7 @@ window must not paint an opaque background over the calling app. --> <style name="Theme.General.Translucent" parent="android:Theme.Material.Light.NoActionBar"> <item name="android:windowIsTranslucent">true</item>+ <item name="android:windowDisablePreview">true</item> <item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash_empty</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item>