diff --git a/bin/templates/cordova/lib/prepare.js b/bin/templates/cordova/lib/prepare.js index bd0788a1..c689f0ee 100644 --- a/bin/templates/cordova/lib/prepare.js +++ b/bin/templates/cordova/lib/prepare.js @@ -244,11 +244,11 @@ function default_versionCode(version) { return versionCode; } -function getImageResourcePath(resourcesDir, density, name, sourceName) { +function getImageResourcePath(resourcesDir, type, density, name, sourceName) { if (/\.9\.png$/.test(sourceName)) { name = name.replace(/\.png$/, '.9.png'); } - var resourcePath = path.join(resourcesDir, (density ? 'drawable-' + density : 'drawable'), name); + var resourcePath = path.join(resourcesDir, (density ? type + '-' + density : type), name); return resourcePath; } @@ -261,7 +261,7 @@ function updateSplashes(cordovaProject, platformResourcesDir) { return; } - var resourceMap = mapImageResources(cordovaProject.root, platformResourcesDir, 'screen.png'); + var resourceMap = mapImageResources(cordovaProject.root, platformResourcesDir, 'drawable', 'screen.png'); var hadMdpi = false; resources.forEach(function (resource) { @@ -272,14 +272,14 @@ function updateSplashes(cordovaProject, platformResourcesDir) { hadMdpi = true; } var targetPath = getImageResourcePath( - platformResourcesDir, resource.density, 'screen.png', path.basename(resource.src)); + 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, 'mdpi', 'screen.png', path.basename(resources.defaultResource.src)); + platformResourcesDir, 'drawable', 'mdpi', 'screen.png', path.basename(resources.defaultResource.src)); resourceMap[targetPath] = resources.defaultResource.src; } @@ -291,7 +291,7 @@ function updateSplashes(cordovaProject, platformResourcesDir) { function cleanSplashes(projectRoot, projectConfig, platformResourcesDir) { var resources = projectConfig.getSplashScreens('android'); if (resources.length > 0) { - var resourceMap = mapImageResources(projectRoot, platformResourcesDir, 'screen.png'); + var resourceMap = mapImageResources(projectRoot, platformResourcesDir, 'drawable', 'screen.png'); events.emit('verbose', 'Cleaning splash screens at ' + platformResourcesDir); // No source paths are specified in the map, so updatePaths() will delete the target files. @@ -309,7 +309,7 @@ function updateIcons(cordovaProject, platformResourcesDir) { return; } - var resourceMap = mapImageResources(cordovaProject.root, platformResourcesDir, 'icon.png'); + var resourceMap = mapImageResources(cordovaProject.root, platformResourcesDir, 'mipmap', 'icon.png'); var android_icons = {}; var default_icon; @@ -360,14 +360,14 @@ function updateIcons(cordovaProject, platformResourcesDir) { // project's config.xml location, so we use it as base path. for (var density in android_icons) { var targetPath = getImageResourcePath( - platformResourcesDir, density, 'icon.png', path.basename(android_icons[density].src)); + platformResourcesDir, 'mipmap', 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) { var defaultTargetPath = getImageResourcePath( - platformResourcesDir, 'mdpi', 'icon.png', path.basename(default_icon.src)); + platformResourcesDir, 'mipmap', 'mdpi', 'icon.png', path.basename(default_icon.src)); resourceMap[defaultTargetPath] = default_icon.src; } @@ -379,7 +379,7 @@ function updateIcons(cordovaProject, platformResourcesDir) { function cleanIcons(projectRoot, projectConfig, platformResourcesDir) { var icons = projectConfig.getIcons('android'); if (icons.length > 0) { - var resourceMap = mapImageResources(projectRoot, platformResourcesDir, 'icon.png'); + var resourceMap = mapImageResources(projectRoot, platformResourcesDir, 'mipmap', 'icon.png'); events.emit('verbose', 'Cleaning icons at ' + platformResourcesDir); // No source paths are specified in the map, so updatePaths() will delete the target files. @@ -391,9 +391,9 @@ function cleanIcons(projectRoot, projectConfig, platformResourcesDir) { /** * Gets a map containing resources of a specified name from all drawable folders in a directory. */ -function mapImageResources(rootDir, subDir, resourceName) { +function mapImageResources(rootDir, subDir, type, resourceName) { var pathMap = {}; - shell.ls(path.join(rootDir, subDir, 'drawable-*')) + shell.ls(path.join(rootDir, subDir, type + '-*')) .forEach(function (drawableFolder) { var imagePath = path.join(subDir, path.basename(drawableFolder), resourceName); pathMap[imagePath] = null; diff --git a/bin/templates/project/AndroidManifest.xml b/bin/templates/project/AndroidManifest.xml index fc44b2ee..bb60a071 100644 --- a/bin/templates/project/AndroidManifest.xml +++ b/bin/templates/project/AndroidManifest.xml @@ -30,7 +30,7 @@ -