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

Features/webp support for splashscreen #1113

Merged

Conversation

PieterVanPoyer
Copy link
Contributor

@PieterVanPoyer PieterVanPoyer commented Oct 28, 2020

Platforms affected

Android

Motivation and Context

A splashscreen image on Android can be in a webp format. ( https://developer.android.com/studio/write/convert-webp )
When a webp image is included the build breaks.

Description

If the inputted splash screen has a .webp extension, it is saved to the correct density folder as screen.webp.
An possible old screen.png of the same folder is deleted.

If the inputted splash screen has another extension (png or jpg), it is saved to the correct density folder as screen.png.
An possible old screen.webp of the same folder is deleted.

If android encouters a webp and a png with the same name and density a compilation error is thrown by Android

Testing

  • added Unittests

Todo

  • Maybe something must be added in the (SplashScreen plugin) documentation.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@timbru31
Copy link
Member

Could you also test if .jpg splashscreen do work? It's stated in the docs, but it seems like that there is a hardcoded check to screen.png.

bin/templates/cordova/lib/prepare.js Outdated Show resolved Hide resolved
bin/templates/cordova/lib/prepare.js Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Oct 29, 2020

Codecov Report

Merging #1113 (30bcaa5) into master (335b0f2) will increase coverage by 2.09%.
The diff coverage is 38.46%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1113      +/-   ##
==========================================
+ Coverage   69.71%   71.80%   +2.09%     
==========================================
  Files          20       21       +1     
  Lines        1806     1745      -61     
==========================================
- Hits         1259     1253       -6     
+ Misses        547      492      -55     
Impacted Files Coverage Δ
bin/templates/cordova/lib/prepare.js 47.79% <38.46%> (+3.88%) ⬆️
bin/templates/cordova/lib/utils.js 92.85% <0.00%> (-7.15%) ⬇️
bin/templates/cordova/lib/Adb.js 100.00% <0.00%> (ø)
bin/templates/cordova/lib/run.js 100.00% <0.00%> (ø)
bin/templates/cordova/lib/device.js 100.00% <0.00%> (ø)
bin/templates/cordova/lib/target.js 96.77% <0.00%> (ø)
bin/templates/cordova/lib/emulator.js 98.84% <0.00%> (+0.71%) ⬆️
...n/templates/cordova/lib/builders/ProjectBuilder.js 74.83% <0.00%> (+1.62%) ⬆️
bin/templates/cordova/lib/build.js 33.33% <0.00%> (+2.22%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 335b0f2...30bcaa5. Read the comment docs.

PieterVanPoyer added a commit to PieterVanPoyer/cordova-plugin-splashscreen-testing-app that referenced this pull request Oct 29, 2020
@PieterVanPoyer
Copy link
Contributor Author

PieterVanPoyer commented Oct 29, 2020

Could you also test if .jpg splashscreen do work? It's stated in the docs, but it seems like that there is a hardcoded check to screen.png.

@timbru31 Hey I did test the .jpg flow. Really odd, but it works. So what happens, the .jpg is saved as a screen.png in the android project. But android is just displaying it nice.

A testrepo is available at: https://github.com/PieterVanPoyer/cordova-plugin-splashscreen-testing-app/tree/testing/jpg-splash-screen

image

- platform independent paths in testing
- addes some unittest
- remove duplication + add comments
- delete webp's if png's added, delete png's if webp' added.
- Update bin/templates/cordova/lib/prepare.js Co-authored-by: エリス <[email protected]>
- fix apache/cordova-plugin-splashscreen#257 webp support for android
@PieterVanPoyer PieterVanPoyer force-pushed the features/webp-support-for-splashscreen branch from 76f439f to e778854 Compare November 1, 2020 21:15
@PieterVanPoyer PieterVanPoyer changed the title WIP: Features/webp support for splashscreen Features/webp support for splashscreen Nov 1, 2020
@PieterVanPoyer
Copy link
Contributor Author

@erisu and @timbru31 I hate to disturb you guys. But is anyone able to review this PR. Kind regards.

Copy link
Contributor

@breautek breautek left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Tested it on one of my apps 👍

Copy link
Contributor

@raphinesse raphinesse left a comment

Choose a reason for hiding this comment

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

I only had the time to take a quick look at this. It is great that we have test coverage for this feature and the code looks clean 👍

However, I can't help to think that it is not optimal that we have to hard-code the handling of a specific set of extensions into the core platform to implement a plugin feature.

So can someone shed some light on why we have the splash-screen logic here in the first place?

And could we at least implement this in a more generic way? Something more like

delete $dest/screen.*
copy $splashImg $dest/$splashImg

@PieterVanPoyer
Copy link
Contributor Author

Hi @raphinesse thanks for your time.

I was also happy with the testcoverage. There were some examples and it was easy to just add my stuff and improve the coverage. And like you said: 'the code is clean'.

I must admit, when I was looking for fixing the issue, I was surprised to find the handling of the splashscreens in the cordova-android lib and not in the plugin code. Unfortunately I cannot shed any light on that matter.

I think making this stuff more generic wouldn't be a real improvement, and I don't exactly know how you'd like that to be.
On the other hand, taking the time to make an issue in the splashscreen plugin to move the splashscreen code to the right place would be a good first step.
When the handling (copying, deleting) of splashscreens is in the plugin, it can be less generic, because that's what the plugin should do. Handling splashscreens.

Kind regards
Pieter

@raphinesse
Copy link
Contributor

taking the time to make an issue in the splashscreen plugin to move the splashscreen code to the right place would be a good first step.

Actually, it seems that we have plans to move things in the opposite direction. Sorry, I did not remember that. I don't know why this functionality should be moved from plugin to platform, but there is probably a good reason. So the platform seems indeed like the right location for these changes.

I'll get back to you regarding a more generic way to implement this.

@raphinesse
Copy link
Contributor

@PieterVanPoyer FYI: I made a pull request (PieterVanPoyer#1) against this branch

…hscreen

Features/webp support for splashscreen
@PieterVanPoyer PieterVanPoyer marked this pull request as draft December 13, 2020 16:17
@PieterVanPoyer PieterVanPoyer marked this pull request as ready for review December 13, 2020 16:39
Copy link
Contributor

@raphinesse raphinesse left a comment

Choose a reason for hiding this comment

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

LGTM now. Thanks a lot for testing and fixing my changes @PieterVanPoyer !

@breautek
Copy link
Contributor

Thank you for the review @raphinesse

Our current dev version is targeting a minor release so I'll go ahead and merge this. Thank you @PieterVanPoyer for your time and effort in preparing this PR!

@breautek breautek merged commit 7428bd3 into apache:master Dec 16, 2020
@PieterVanPoyer
Copy link
Contributor Author

@breautek thanks for the effort. Maybe I should make an issue in the Cordova Docs repo, to add some info about the webp - support to the docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build breaks using webp splash images instead of PNG
6 participants