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

bug: Splash screen does not respect navigationBar color setting #2422

Closed
1 of 4 tasks
xzilja opened this issue Feb 7, 2020 · 6 comments
Closed
1 of 4 tasks

bug: Splash screen does not respect navigationBar color setting #2422

xzilja opened this issue Feb 7, 2020 · 6 comments

Comments

@xzilja
Copy link
Contributor

xzilja commented Feb 7, 2020

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 1.5.0

  @capacitor/core: 1.5.0

  @capacitor/android: 1.5.0

  @capacitor/ios: 1.5.0

Installed Dependencies:

  @capacitor/cli 1.5.0

  @capacitor/ios 1.5.0

  @capacitor/core 1.5.0

  @capacitor/android 1.5.0


[success] Android looking great! 👌
  Found 0 Capacitor plugins for ios:
[success] iOS looking great! 👌

Affected Platform(s)

  • Android
  • iOS
  • Electron
  • Web

Current Behavior

I have custom code in my MainApplication.java file that sets android's navbar color to black.
It works initially when I launch my app, but after it goes to capacitor splash screen, color is changed back to default android one, which in my case happens to be light grey (samsung galaxy s8). Gif below demonstrates this: notice how it goes from black -> default gray

giphy

Expected Behavior

Should keep navbar black all the time.

Sample Code or Sample Application Repo

This is my MainApplication.java and setAndroidUiColor(); is what sets color of navbar to be black.

package com.asimetriq.skimitar;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;

import java.util.ArrayList;

public class MainActivity extends BridgeActivity {


  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setAndroidUiColor();

    /**
     * Initialize capacitor bridge
     */
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
    }});
  }

  @Override
  public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
      setAndroidUiColor();
    }
  }

  private void setAndroidUiColor() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      getWindow().setNavigationBarColor(Color.rgb(0, 0, 0));
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
      getWindow().setNavigationBarDividerColor(Color.rgb(0, 0, 0));
    }
  }
}

Reproduction Steps

You can add setAndroidUiColor(); implementation to default capacitor app and launch it in simulator on a samsung galaxy s8 device, or perhaps newer model, I assume they will run similar version of android.

Other Technical Details

npm --version output: 6.13.4

node --version output:v12.14.1

pod --version output (iOS issues only): 1.8.4

Other Information

This is happening on android 9 for me. I also don't see it on all devices i.e. simulator for pixel 3 seems ok, but I think default color for navbar there is transparent, so it could be setting it back to transparent and blending with black background.

@jcesarmobile
Copy link
Member

this would need a new configuration option for Splash plugin to set the Navigation Bar color

@xzilja
Copy link
Contributor Author

xzilja commented Feb 8, 2020

I'm having few issues implementing this inside Splash.java atm. It requires getWindow() which is only available on activity. I can see that methods showOnLaunch and show expose it. so I tried to add following in all of these methods, but it seems that it doesn't have any effect. Can I access getWindow earlier somewhere?

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      a.getWindow().setNavigationBarColor(Color.rgb(0, 0, 0));
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
      a.getWindow().setNavigationBarDividerColor(Color.rgb(0, 0, 0));
    }

@jcesarmobile
Copy link
Member

looks like it got fixed by #2603

@xzilja
Copy link
Contributor Author

xzilja commented Mar 20, 2020

Nice! I'll test this tomorrow. I think https://github.com/ionic-team/capacitor/pull/2603/files#diff-ecbcf16403a887804cbb3a64cbe56e6dR57 might also fix "jump" effect I had in this PR #2425 but I will confirm for sure once I'm next to my mac.

@jcesarmobile
Copy link
Member

yes, it does

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 12, 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 Capacitor, please create a new issue and ensure the template is fully filled out.

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

No branches or pull requests

2 participants