Status Update
Comments
jo...@meanguppy.com <jo...@meanguppy.com> #2
Adding on to this. I'm aware that setKeepOnScreenCondition
can help by hiding the initial delay I set. One problem is that I also replace the initial/static icon with a custom Drawable that is animated, which works great even on the lower API levels, but I'm unable to pause the drawing of frames. Regardless, the problem still stands that during the actual animation, the navigation/status bar colors are inconsistent across versions.
al...@google.com <al...@google.com>
jo...@meanguppy.com <jo...@meanguppy.com> #3
Update:
Some parts of my original post were a bit inaccurate. I've found that the critical issue here is that the SplashScreen lives in its own window
object on API 31+, allowing it to keep the splash theme. And on API <31, it lives in the same window
object as the activity, which means they share the same navigation and status bar colors. I've implemented a somewhat hacky solution to this problem:
- The SplashScreenViewProvider is created, the
postSplashScreenTheme
has been applied. - Take note of the current system bar colors.
- Make the system bars transparent.
- Take note of inset sizes from
WindowInsetsCompat.Type.systemBars()
. - Create two (or more?)
View
s and add them tosplashScreenViewProvider.view
to act as fake system bars. - Set the views' color and height corresponding to the values read earlier. Set gravity appropriately.
- Call
splashScreenViewProvider.iconView.bringToFront()
to allow the icon to draw over the fake system bar colors. - Before calling
splashScreenViewProvider.remove()
, restore the actual system bar colors.
(Optional?: I also set the FrameLayout's background to transparent, and animate the icon directly, so that the fake insets remain in place)
Any thoughts on conditions that may make this approach problematic?
ca...@google.com <ca...@google.com> #4
I found a simple fix for this. Calling splashscreenViewProvider.view.bringToFront()
will make it display on top of the systembar's background.
I'm submitting the fix and it should be available in beta02 within the next 2 weeks.
ap...@google.com <ap...@google.com> #5
Branch: androidx-main
commit cd2847603a1f6ae18815e0070423d5af11a67534
Author: Vadim Caen <caen@google.com>
Date: Mon Feb 28 13:31:42 2022
Bring splashscreenview in front of systembars bg
To replicate Android 12 behavior, the systembars' background needs to be
shown only when remove() is called, so by bringing the splashscreenview
to the front, we cover the systembar background view.
Fixes: 217991641
Test: Manual on API 29-31
Change-Id: I1227c4ac0e251cba93511dac8c57d6fd0ee73439
M core/core-splashscreen/src/main/java/androidx/core/splashscreen/SplashScreen.kt
Description
Component used: androidx.core:core-splashscreen Version used: 1.0.0-beta01 Devices/Android versions reproduced on: AVD running Android 8, 10, and 12.
When setting a custom exit animation via
setOnExitAnimationListener
, the timing of the theme change for navigation/status bars are inconsistent across Android versions:.remove()
-ed.I'm aware API <31 uses a custom implementation designed to imitate the new behavior. However, I feel this inconsistency can be reasonably addressed. I prefer the behavior of API 31.
Example and videos:
Using the following theme:
With this theme, I expect the navigation bars to be transparent during the splash screen, and change to the holo colors after my exit animation. This works as expected on 31, but not on the others.
I intentionally delay the start of my animation to demonstrate the inconsistency. The attachments are examples from API 31 and API 29 (see filenames).