Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[prebuild config] Created android splash plugin #3576

Merged
merged 20 commits into from Jun 23, 2021

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented Jun 14, 2021

Why

How

  • Created a plugin to remove the splash screen style that doesn't extend the base style
  • Created a plugin to remove the generated API in favor of a version that is wrapped in hashes
  • Added android.colorsNight to handle android/app/src/main/res/values-night/colors.xml

Added pseudo support for undocumented props:

{
  "android": {
    "splash": {
        "mdpi": "./assets/splash/light/mdpi.png",
        "hdpi": "./assets/splash/light/hdpi.png",
        "xhdpi": "./assets/splash/light/xhdpi.png",
        "xxhdpi": "./assets/splash/light/xxhdpi.png",
        "xxxhdpi": "./assets/splash/light/xxxhdpi.png",
        "backgroundColor": "#0000ff",
        "resizeMode": "native",
        "dark": {
          "mdpi": "./assets/splash/dark/mdpi.png",
          "hdpi": "./assets/splash/dark/hdpi.png",
          "xhdpi": "./assets/splash/dark/xhdpi.png",
          "xxhdpi": "./assets/splash/dark/xxhdpi.png",
          "xxxhdpi": "./assets/splash/dark/xxxhdpi.png",
          "backgroundColor": "#FF00ff"
        }
      }
    }
  }
}

Test images:
splash.zip

Test Plan

  • Unit tests
  • Manual E2E testing

@linear
Copy link

linear bot commented Jun 15, 2021

@EvanBacon EvanBacon marked this pull request as ready for review June 17, 2021 22:11
@brentvatne brentvatne requested a review from Kudo June 17, 2021 22:29
if (config.androidStatusBar?.backgroundColor) {
if (backgroundColor.toLowerCase() !== config.androidStatusBar?.backgroundColor.toLowerCase()) {
if (backgroundColor !== config.androidStatusBar?.backgroundColor.toLowerCase()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the backgroundColor is from app config, do we ensure this is in lowercase?

besides, the backgroundColor is verified by schema /^#|(#)\\d{6}$/
https://github.com/expo/universe/blob/266e38e4b1edb23cd9c7297c3219814c490f7937/server/www/xdl-schemas/UNVERSIONED-schema.json#L46
i am getting a little confused from this regexp, though i know is from a historical code.

/^#|(#)\\d{6}$/.test('#HelloWorld') === true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the validation matters too much here (or for this PR). Android allows lots of different types of colors in the colors.xml file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes sense, thanks for the classification.

if (config.android?.splash) {
const splash = config.android?.splash;
return {
// TODO: Does this not support `image`?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it kinda does, i believe, but if you provide an image that is too large it could crash the app on low end devices

@EvanBacon EvanBacon merged commit 1f21b21 into master Jun 23, 2021
@EvanBacon EvanBacon deleted the @evanbacon/prebuild-config/new-android-splash branch June 23, 2021 17:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants