-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Status bar background color overridden by the splash screen animation on Android 13 #1501
Comments
Moving this to the cordova-android repo as that is what contains the splashscreen code. |
More investigation is needed. The code you commented out is for supporting the new Android 12 Splash Screen API, which has been proven to work on Android <= 12L. As you said, the issue appears in Android 13+. There is a possibility that Google has introduced a change that broke this and the issue is on Google's end, and not Cordova. Maybe Google introduced a new process for setting the status bar color, in Android 13, only if the Android 12 Splash Screen API compatibility library is used? But nothing seems apparent in the Android 13 release notes regarding such a change. |
Yeah that was only a quick test I did but removing that part was solving the issue. I suppose there must be something in there that causes the bug. I've tried playing with the methods for the animation but it seems that's the whole animation that's causing the issue. |
Here was one thing I noticed Following your previous steps:
<preference name="StatusBarBackgroundColor" value="#cccccc" />
This is one of the reasons why I am wondering if it is an Android bug and not Cordova. It seems kind of unusualy why changing the system settings will make changes to the app display. And yet its not anytrhing related to the color you picked in the settings. |
I can replicate this, @erisu, and would just add that between 7. and 8. my app does a sort of restart. Any window I had opened within my app is closed upon returning to the app. Also, it is not just the color of the status bar. I am using |
@erisu my previous comment that the "app does a sort of restart" might actually be quite relevant when you look at this issue: There, the author states that using So I think that is the answer why your steps work to "solve" the issue (...until the next "proper" app restart). |
The key here seems to be the With Android 12+, this theme doesn't apply until the splash screen is fully hidden, and when it does apply it will clobber any settings configured by the Statusbar plugin while the splash was displayed. In my case, I've added a
Added to the
|
It's not entirely clear that this can be fixed, given the root issue is that Android itself applies the theme at it's own discretion. If the post splash theme is significantly different from the Statusbar configuration, any attempted fix will likely result in the status bar flickering through the wrong state before showing the desired state. Given this behaviour, I feel that the best solution in practice is to recommend developers create a customised post-splash style, and reduce their dependency on the Statusbar plugin for Android for setting the initial static styles. |
Oh... another sharp edge... launching the app on to a phone directly from Android studio will bypass the normal Splashscreen behaviours! This confused me for quite a while as it seemed like no changes I made really applied. To test whether the post-splash theme is properly applying, you will need to close the app and relaunching via the phone, NOT via Android Studio. |
Thanks a lot for your solution, it helped me and it worked. I just changed 2 things:
|
I wonder if we can extend the splashscreen theme so that we can set the statusbar stuff like |
I've added this to a 12.0.1 for now... But I think the solution might be to create a Cordova Theme and have the statusbar preferences manipulate the statusbar theme values respectively. The post theme can default to this new cordova theme. If that's the route we take, then that may be considered a breaking change... in which case we'd want to change the milestone to 13.x. FWIW I've ran into this issue on my own apps and #1501 (comment) served as a workaround for the time being. I created a theme xml file that looks like this (style name can be changed if desired): <?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.App.TotalPave" parent="Theme.AppCompat.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources> and inside my config xml: <preference name="StatusBarOverlaysWebView" value="true" />
<preference name="AndroidPostSplashScreenTheme" value="@style/Theme.App.TotalPave" />
<platform name="android">
<content src="index.html" />
<resource-file src="./res/android/values/TotalPaveTheme.xml" target="app/src/main/res/values/TotalPaveTheme.xml" />
... Without the workaround, after app launch, the splashscreen will turn black, while maintaining the overlay state. This workaround allowed me to keep the colour transparent as one would expect for an overlay state. If you use the statusbar differently, then the theme config may need to be adjusted to fit your needs. |
I think setting |
I can verify this is correct. Setting |
Thanks for confirmation, since the reporter have not answered I'll close the issue |
Bug Report
Problem
On Android 13 the status bar background color is always black. I've set the color on the config.xml with the StatusBarBackgroundColor preference and it works on ios and android < 13 but not on Android 13.
What is expected to happen?
Status bar should have the color set in the config.xml.
What does actually happen?
Status bar color is black. It shows the correct color for a few milliseconds than it becomes black.
Information
Just set the background color with StatusBarBackgroundColor in the config.xml and run the application on Android 13.
Command or Code
<preference name="StatusBarBackgroundColor" value="#cccccc" /> in config.xml
This issue is solved removing the splash screen animation from the splash screen plugin:
so the splash screen plugin should fix this part of the code.
Environment, Platform, Device
Android 13, Android studio 2021.2.1 patch 2
Version information
cordova cli v 11.0.0
cordova-android v 11.0.0
cordova-plugin-statusbar v3.0.0
Checklist
The text was updated successfully, but these errors were encountered: