cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vladimir-kotikov <...@git.apache.org>
Subject [GitHub] cordova-android pull request: CB-11117: Use FileUpdater to optimiz...
Date Thu, 28 Apr 2016 08:50:43 GMT
Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-android/pull/295#discussion_r61393298
  
    --- Diff: bin/templates/cordova/lib/prepare.js ---
    @@ -295,25 +344,47 @@ function handleIcons(projectConfig, platformRoot) {
     
         // The source paths for icons and splashes are relative to
         // project's config.xml location, so we use it as base path.
    -    var projectRoot = path.dirname(projectConfig.path);
    -    var destination = path.join(platformRoot, 'res');
         for (var density in android_icons) {
    -        copyImage(path.join(projectRoot, android_icons[density].src), destination, density,
'icon.png');
    +        var targetPath = getImageResourcePath(
    +            platformResourcesDir, density, 'icon.png', path.basename(android_icons[density].src));
    +        resourceMap[targetPath] = android_icons[density].src;
         }
    +
         // There's no "default" drawable, so assume default == mdpi.
         if (default_icon && !android_icons.mdpi) {
    -        copyImage(path.join(projectRoot, default_icon.src), destination, 'mdpi', 'icon.png');
    +        var targetPath = getImageResourcePath(
    +            platformResourcesDir, 'mdpi', 'icon.png', path.basename(default_icon.src));
    +        resourceMap[targetPath] = default_icon.src;
         }
    +
    +    events.emit('verbose', 'Updating icons at ' + platformResourcesDir);
    +    FileUpdater.updatePaths(
    +        resourceMap, { rootDir: cordovaProject.root }, logFileOp);
     }
     
    -// remove the default resource name from all drawable folders
    -function deleteDefaultResourceAt(baseDir, resourceName) {
    -    shell.ls(path.join(baseDir, 'res/drawable-*'))
    +function cleanIcons(projectRoot, projectConfig, platformResourcesDir) {
    +    var icons = projectConfig.getIcons('android');
    +    if (icons.length > 0) {
    +        var resourceMap = mapImageResources(projectRoot, platformResourcesDir, 'icon.png');
    +        events.emit('verbose', 'Cleaning icons at ' + platformResourcesDir);
    +
    +        // No source paths are specified in the map, so updatePaths() will delete the
target files.
    +        FileUpdater.updatePaths(
    --- End diff --
    
    Just like in `cleanWww` - is there any advantage of calling this rather than doing `shell.rm`
on these files? This would  eliminate the need to know how `mapImageResources` and `FileUpdater.updatePaths`
works internally and IMO improve readability a lot.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message