Skip to content
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

Splash Screen plugin overrides status bar styles #1249

Closed
marcjulian opened this issue Oct 26, 2022 · 4 comments
Closed

Splash Screen plugin overrides status bar styles #1249

marcjulian opened this issue Oct 26, 2022 · 4 comments

Comments

@marcjulian
Copy link

Bug Report

Plugin(s)

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 4.4.0
  @capacitor/core: 4.4.0
  @capacitor/android: 4.4.0
  @capacitor/ios: 4.4.0

Installed Dependencies:

  @capacitor/ios: not installed
  @capacitor/core: 4.4.0
  @capacitor/cli: 4.4.0
  @capacitor/android: 4.4.0

[success] Android looking great! 👌

Platform(s)

Android

Current Behavior

Changing the styles of StatusBar and NavigationBar is overridden when the @capacitor/splash-screen plugin is installed in the project.

ngOnInit(): void {
    if (Capacitor.getPlatform() === "android") {
      StatusBar.setStyle({ style: Style.Dark });
      StatusBar.setBackgroundColor({ color: "#ef4444" });
      NavigationBar.setColor({ color: "#ef4444" });
    }
  }

Status and Navigation bar color w/ Splash Screen plugin

Expected Behavior

The StatusBar and NavigationBar styles should be applied as in the case without the @capacitor/splash-screen plugin.

Screenshot 2022-10-26 at 15 28 35

Code Reproduction

https://github.com/marcjulian/ng-cap-status-bar

Other Technical Details

Additional Context

@jcesarmobile
Copy link
Member

This is a bug on the Android 12 Splash Screen API, when using setOnExitAnimationListener (which Splash Screen uses), it won't allow to make modifications to the device UI while the splash screen is present if it has an exit animation listener.

Android 12 Splash Screen API is bundled into the OS now, so there is nothing we can do about it, only google can fix those kind of issues.
We are considering adding a configuration option for not adding the exit animation listener, which would cause the splash to not have a fade out animation, but would not present the issue neither.

A workaround for your app would be to set the status bar and navigation bar color from the styles
Add this to the AppTheme.NoActionBar style in styles.xml file.

<item name="android:navigationBarColor">#ef4444</item>
<item name="android:statusBarColor">#ef4444</item>

closing as duplicate of #1160 as the problem is the same

@jcesarmobile jcesarmobile closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2022
@marcjulian
Copy link
Author

Thanks for the clarification of the bug in Android 12 Splash Screen. Your propose workaround works perfect for me, thanks.

@tobiloeb
Copy link

I checked the code for the StatusBar Plugin and found this line:
windowInsetsControllerCompat.setAppearanceLightStatusBars(!style.equals("DARK"));

So I can fix the text color issue when set the following to my styles:
<item name="android:windowLightStatusBar">true</item>

May this helps someone else.

@ionitron-bot
Copy link

ionitron-bot bot commented Dec 16, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants