You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/10/29 14:21:19 UTC

[GitHub] [cordova-android] erisu commented on a change in pull request #1113: WIP: Features/webp support for splashscreen

erisu commented on a change in pull request #1113:
URL: https://github.com/apache/cordova-android/pull/1113#discussion_r514294035



##########
File path: bin/templates/cordova/lib/prepare.js
##########
@@ -336,15 +336,27 @@ function updateSplashes (cordovaProject, platformResourcesDir) {
         if (resource.density === 'mdpi') {
             hadMdpi = true;
         }
-        var targetPath = getImageResourcePath(
-            platformResourcesDir, 'drawable', resource.density, 'screen.png', path.basename(resource.src));
+        var targetPath;
+        if (path.extname(resource.src) === '.webp') { // splashsreens could be in .webp format
+            targetPath = getImageResourcePath(
+                platformResourcesDir, 'drawable', resource.density, 'screen.webp', path.basename(resource.src));
+        } else {
+            targetPath = getImageResourcePath(
+                platformResourcesDir, 'drawable', resource.density, 'screen.png', path.basename(resource.src));
+        }

Review comment:
       ```suggestion
           const imgDestExt = path.extname(resource.src) === '.webp' ? '.webp' : '.png';
           const imgDestName = `screen${imgExt}`;
           targetPath = getImageResourcePath(platformResourcesDir, 'drawable', resource.density, imgDestName, path.basename(resource.src));
   ```

##########
File path: bin/templates/cordova/lib/prepare.js
##########
@@ -336,15 +336,27 @@ function updateSplashes (cordovaProject, platformResourcesDir) {
         if (resource.density === 'mdpi') {
             hadMdpi = true;
         }
-        var targetPath = getImageResourcePath(
-            platformResourcesDir, 'drawable', resource.density, 'screen.png', path.basename(resource.src));
+        var targetPath;
+        if (path.extname(resource.src) === '.webp') { // splashsreens could be in .webp format
+            targetPath = getImageResourcePath(
+                platformResourcesDir, 'drawable', resource.density, 'screen.webp', path.basename(resource.src));
+        } else {
+            targetPath = getImageResourcePath(
+                platformResourcesDir, 'drawable', resource.density, 'screen.png', path.basename(resource.src));
+        }
         resourceMap[targetPath] = resource.src;
     });
 
     // There's no "default" drawable, so assume default == mdpi.
     if (!hadMdpi && resources.defaultResource) {
-        var targetPath = getImageResourcePath(
-            platformResourcesDir, 'drawable', 'mdpi', 'screen.png', path.basename(resources.defaultResource.src));
+        var targetPath;
+        if (path.extname(resources.defaultResource.src) === '.webp') { // splashsreens could be in .webp format
+            targetPath = getImageResourcePath(
+                platformResourcesDir, 'drawable', 'mdpi', 'screen.webp', path.basename(resources.defaultResource.src));
+        } else {
+            targetPath = getImageResourcePath(
+                platformResourcesDir, 'drawable', 'mdpi', 'screen.png', path.basename(resources.defaultResource.src));
+        }

Review comment:
       ```suggestion
           const imgDestExt = path.extname(resource.src) === '.webp' ? '.webp' : '.png';
           const imgDestName = `screen${imgExt}`;
           const targetPath = getImageResourcePath(platformResourcesDir, 'drawable', 'mdpi', imgDestName, path.basename(resources.defaultResource.src));
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org