cordova-ios icon indicating copy to clipboard operation
cordova-ios copied to clipboard

feature(splash-screen): support setting background color

Open BorntraegerMarc opened this issue 7 years ago • 15 comments

I would like to request a feature to add the property SplashScreenBackgroundColor for iOS ~and Android~ for the reason outlined here: https://github.com/ionic-team/cordova-plugin-ionic/issues/151

BorntraegerMarc avatar Sep 24 '18 07:09 BorntraegerMarc

Just do understand the issue better: Why isn't adding a background color to the splashscreen an option?

janpio avatar Sep 24 '18 09:09 janpio

Thanks for the reply @janpio

Generally a background in the actual image could be added. But in our case we are using the same image in some places of the app (To save disk storage). And the background is only need for the splash screen.

BorntraegerMarc avatar Sep 24 '18 09:09 BorntraegerMarc

Thanks for the clarification, although very special case it makes sense.

janpio avatar Sep 24 '18 09:09 janpio

Windows platform (and maybe browser) already have a SplashScreenBackgroundColor preference.

On iOS would be as simple as adding a color to the image view where the splash is loaded, but it only applies to the legacy splash images, didn't check on the storyboard use case. Not sure about Android neither.

jcesarmobile avatar Sep 24 '18 11:09 jcesarmobile

About one year ago, I added support on Android for SplashScreenBackgroundColor and SplashScreenTheme in a private fork but never submitted a pull request. I'm not sure but I think the Android version of the plugin has been modified since then.

IndieSW avatar Sep 24 '18 17:09 IndieSW

If you still have the fork, please still open the pull request - we can fix those conflicts if there are any. The important thing are your changes @IndieSW 👍

janpio avatar Sep 24 '18 17:09 janpio

I'd be happy to but I don't have time right now to resolve conflicts and test. I've used my fork in an app and tested though so I know the changes work.

Should that be a fork of the master branch?

IndieSW avatar Sep 24 '18 19:09 IndieSW

Yeah, or whatever you already have. If you submit it and link to this issue, we can have a look and create a new fork based on your changes. Probably not that drastic.

janpio avatar Sep 24 '18 20:09 janpio

See PR: https://github.com/apache/cordova-plugin-splashscreen/pull/161

Github diff wasn't very kind. To summarize the changes:

  • a SplashScreenThemeId preference is initialized in pluginInitialize() and defaults to the previously hardcoded value. this follows the way drawableId is handled.
  • isActivityFullScreen() was added with logic removed from showSplashScreen().
  • in showSplashScreen() - before the Runnable:
    • int themeId is set to the SplashScreenThemeId preference value.
    • int backgroundColor is set according to the SplashScreenBackgroundColor preference and defaults to the previously coded value.
  • in showSplashScreen() - in the Runnable:
    • the background color of the ImageView is set to int backgroundColor.
    • the Dialog is created with int themeId.
    • isActivityFullScreen() is used to decide whether to add FLAG_FULLSCREEN to the Dialog Window LayoutParams.

Hope that helps. Please let me know if you have any questions. Also, the changes were made to version 4.0.4-dev according to the plugin.xml. I'm not sure which commit that corresponds to.

IndieSW avatar Sep 24 '18 21:09 IndieSW

I took your file and applied it to the 4.0.x release branch. Makes a much nicer diff: https://github.com/apache/cordova-plugin-splashscreen/pull/162/files

janpio avatar Sep 24 '18 21:09 janpio

@janpio Perfect!

IndieSW avatar Sep 24 '18 22:09 IndieSW

Any progress here?

Hadatko avatar Dec 03 '19 07:12 Hadatko

Hey there, any updates? It's a topic for Dark Mode too.

EinfachHans avatar Feb 11 '20 12:02 EinfachHans

Removing the android platform tag because cordova-android@11 splashscreen uses the Android 12 Splashscreen API, and exposes an option to set the background color.

I'm not sure if adding a background option is possible for iOS. I'm fairly certain you have to supply an image, but I'll leave this open for someone who is more knowledgeable in iOS development.

breautek avatar Sep 09 '22 17:09 breautek

As this repo also does not support iOS anymore, I will be moving this ticket to the cordova-ios repo

erisu avatar Sep 09 '22 17:09 erisu