Skip to content

Commit

Permalink
CB-2606, CB-3571 Add support for <icon>, <splash>
Browse files Browse the repository at this point in the history
This commit fixes the following issues:
CB-2606 Add support for <icon> elements in config.xml
CB-3571 Add support for <splash> elements in config.xml

Copys <icon> and <splash> assets from the config.xml file to
the approriate platform paths.

Uses ImageMagick if it's available to resize all images
from a source image.
  • Loading branch information
leahciMic committed Aug 8, 2013
1 parent 83a042a commit f36666d
Show file tree
Hide file tree
Showing 6 changed files with 622 additions and 56 deletions.
154 changes: 109 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"preferGlobal": "true",
"description": "Cordova command line interface tool",
"main": "cordova",
"engines":{
"node":">=0.9.9"
"engines": {
"node": ">=0.9.9"
},
"engineStrict":true,
"engineStrict": true,
"bin": {
"cordova": "./bin/cordova"
},
Expand All @@ -18,61 +18,125 @@
"type": "git",
"url": "https://git-wip-us.apache.org/repos/asf/cordova-cli.git"
},
"bugs":{
"url" : "https://issues.apache.org/jira/browse/CB",
"email" : "dev@cordova.apache.org"
"bugs": {
"url": "https://issues.apache.org/jira/browse/CB",
"email": "dev@cordova.apache.org"
},
"keywords": [
"cordova",
"client",
"cli"
],
"dependencies": {
"colors":">=0.6.0",
"elementtree":"0.1.3",
"plugman":"0.10.0",
"plist":"0.4.x",
"xcode":"0.5.1",
"express":"3.0.0",
"shelljs":"0.1.2",
"ncallbacks":"1.0.0",
"request":"2.22.0",
"ripple-emulator":"0.9.18",
"semver":"1.1.0",
"glob":"3.2.x",
"follow-redirects":"0.0.x",
"prompt":"0.2.7",
"tar":"0.1.x",
"colors": ">=0.6.0",
"elementtree": "0.1.3",
"plugman": "0.10.0",
"plist": "0.4.x",
"xcode": "0.5.1",
"express": "3.0.0",
"shelljs": "0.1.2",
"ncallbacks": "1.0.0",
"request": "2.22.0",
"ripple-emulator": "0.9.18",
"semver": "1.1.0",
"glob": "3.2.x",
"follow-redirects": "0.0.x",
"prompt": "0.2.7",
"tar": "0.1.x",
"open": "0.0.3",
"npm":"1.3.x",
"optimist":"0.6.0"
"npm": "1.3.x",
"optimist": "0.6.0",
"imagemagick": "~0.1.3"
},
"devDependencies": {
"jasmine-node":"1.8.x"
"jasmine-node": "1.8.x"
},
"author": "Anis Kadri",
"contributors": [
{"name": "Brian LeRoux","email": "b@brian.io"},
{"name": "Fil Maj", "email": "maj.fil@gmail.com"},
{"name": "Mike Reinstein", "email":"reinstein.mike@gmail.com"},
{"name": "Darry Pogue", "email":"darryl@dpogue.ca"},
{"name": "Michael Brooks", "email":"michael@michaelbrooks.ca"},
{"name": "Braden Shepherdson", "email":"braden@chromium.org"},
{"name": "Gord Tanner", "email":"gtanner@gmail.com"},
{"name": "Tim Kim", "email": "timk@adobe.com"},
{"name": "Benn Mapes", "email": "Benn.Mapes@gmail.com"},
{"name": "Michael Wolf", "email": "Michael.Wolf@Cynergy.com"},
{"name": "Andrew Grieve", "email": "agrieve@chromium.org"},
{"name": "Bryan Higgins", "email": "bhiggins@blackberry.com"},
{"name": "Don Coleman", "email": "dcoleman@chariotsolutions.com"},
{"name": "Germano Gabbianelli", "email": "tyron.mx@gmail.com"},
{"name": "Ian Clelland", "email": "iclelland@chromium.org"},
{"name": "Lucas Holmqust", "email": "lholmqui@redhat.com"},
{"name": "Matt LeGrand", "email": "mlegrand@gmail.com"},
{"name": "Michal Mocny", "email": "mmocny@gmail.com"},
{"name": "Sam Breed", "email": "sam@quickleft.com"},
{"name": "Tommy-Carlos Williams", "email": "tommy@devgeeks.org"},
{"name": "Rubén Norte", "email": "rubennorte@gmail.com"}
{
"name": "Brian LeRoux",
"email": "b@brian.io"
},
{
"name": "Fil Maj",
"email": "maj.fil@gmail.com"
},
{
"name": "Mike Reinstein",
"email": "reinstein.mike@gmail.com"
},
{
"name": "Darry Pogue",
"email": "darryl@dpogue.ca"
},
{
"name": "Michael Brooks",
"email": "michael@michaelbrooks.ca"
},
{
"name": "Braden Shepherdson",
"email": "braden@chromium.org"
},
{
"name": "Gord Tanner",
"email": "gtanner@gmail.com"
},
{
"name": "Tim Kim",
"email": "timk@adobe.com"
},
{
"name": "Benn Mapes",
"email": "Benn.Mapes@gmail.com"
},
{
"name": "Michael Wolf",
"email": "Michael.Wolf@Cynergy.com"
},
{
"name": "Andrew Grieve",
"email": "agrieve@chromium.org"
},
{
"name": "Bryan Higgins",
"email": "bhiggins@blackberry.com"
},
{
"name": "Don Coleman",
"email": "dcoleman@chariotsolutions.com"
},
{
"name": "Germano Gabbianelli",
"email": "tyron.mx@gmail.com"
},
{
"name": "Ian Clelland",
"email": "iclelland@chromium.org"
},
{
"name": "Lucas Holmqust",
"email": "lholmqui@redhat.com"
},
{
"name": "Matt LeGrand",
"email": "mlegrand@gmail.com"
},
{
"name": "Michal Mocny",
"email": "mmocny@gmail.com"
},
{
"name": "Sam Breed",
"email": "sam@quickleft.com"
},
{
"name": "Tommy-Carlos Williams",
"email": "tommy@devgeeks.org"
},
{
"name": "Rubén Norte",
"email": "rubennorte@gmail.com"
}
],
"license": "Apache version 2.0"
}
78 changes: 77 additions & 1 deletion spec/metadata/android_parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,14 @@ describe('android project parser', function() {
});
});
describe('update_project method', function() {
var config, www, overrides, staging, svn;
var config, www, overrides, staging, svn, copy;
beforeEach(function() {
config = spyOn(p, 'update_from_config');
www = spyOn(p, 'update_www');
overrides = spyOn(p, 'update_overrides');
staging = spyOn(p, 'update_staging');
svn = spyOn(util, 'deleteSvnFolders');
copy = spyOn(p, 'copy_resources');
});
it('should call update_from_config', function() {
p.update_project();
Expand All @@ -287,10 +288,85 @@ describe('android project parser', function() {
p.update_project();
expect(staging).toHaveBeenCalled();
});
it('should call copy_resources', function() {
p.update_project();
expect(copy).toHaveBeenCalled();
})
it('should call deleteSvnFolders', function() {
p.update_project();
expect(svn).toHaveBeenCalled();
});
});
});
describe('copy resources', function() {
var p, cp, is_cordova;
var android_proj = path.join(proj, 'platforms', 'android');

beforeEach(function() {
p = new platforms.android.parser(proj);
cp = spyOn(shell, 'cp');
is_cordova = spyOn(util, 'isCordova').andReturn(proj);
});

var cfg = {
doc: {
getroot: function() {
return {
findall: function(xpath) {
if (xpath == './/icon') {
return [
{attrib: {src: 'test-ldpi.png', density: 'ldpi', 'gap:platform': 'android'}},
{attrib: {src: 'test-mdpi.png', density: 'mdpi', 'gap:platform': 'android'}},
{attrib: {src: 'test-hdpi.png', density: 'hdpi', 'gap:platform': 'android'}},
{attrib: {src: 'test-xhdpi.png', density: 'xhdpi', 'gap:platform': 'android'}}
];
} else if (xpath == './/splash') {
return [
{attrib: {src: 'test-ldpi.png', density: 'ldpi', 'gap:platform': 'android'}},
{attrib: {src: 'test-mdpi.png', density: 'mdpi', 'gap:platform': 'android'}},
{attrib: {src: 'test-hdpi.png', density: 'hdpi', 'gap:platform': 'android'}},
{attrib: {src: 'test-xhdpi.png', density: 'xhdpi', 'gap:platform': 'android'}},
];
}
}
};
}
}
};

it('should copy icons', function() {
p.copy_icons(cfg);
expect(cp).toHaveBeenCalledWith(
'-f', 'test-ldpi.png', 'some/path/res/drawable-ldpi/icon.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'test-mdpi.png', 'some/path/res/drawable-mdpi/icon.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'test-hdpi.png', 'some/path/res/drawable-hdpi/icon.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'test-xhdpi.png', 'some/path/res/drawable-xhdpi/icon.png'
);
});

it('should copy splashes', function() {
p.copy_splashes(cfg);
expect(cp).toHaveBeenCalledWith(
'-f', 'test-ldpi.png', 'some/path/res/drawable-ldpi/ic_launcher.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'test-mdpi.png', 'some/path/res/drawable-mdpi/ic_launcher.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'test-hdpi.png', 'some/path/res/drawable-hdpi/ic_launcher.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'test-xhdpi.png', 'some/path/res/drawable-xhdpi/ic_launcher.png'
);
});


});

});
88 changes: 87 additions & 1 deletion spec/metadata/ios_parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,14 @@ describe('ios project parser', function () {
});
});
describe('update_project method', function() {
var config, www, overrides, staging, svn;
var config, www, overrides, staging, svn, copy;
beforeEach(function() {
config = spyOn(p, 'update_from_config').andCallFake(function(cfg, cb) { cb() });
www = spyOn(p, 'update_www');
overrides = spyOn(p, 'update_overrides');
staging = spyOn(p, 'update_staging');
svn = spyOn(util, 'deleteSvnFolders');
copy = spyOn(p, 'copy_resources');
});
it('should call update_from_config', function() {
p.update_project();
Expand Down Expand Up @@ -324,10 +325,95 @@ describe('ios project parser', function () {
p.update_project();
expect(staging).toHaveBeenCalled();
});
it('should call copy_resources', function() {
p.update_project();
});
it('should call deleteSvnFolders', function() {
p.update_project();
expect(svn).toHaveBeenCalled();
});
});
});
describe('copy resources', function() {
var p, cp;
var ios_proj = path.join(proj, 'platforms', 'ios');

beforeEach(function() {
p = new platforms.ios.parser(ios_proj);
cp = spyOn(shell, 'cp');
});

var cfg = {
doc: {
getroot: function() {
return {
findall: function(xpath) {
if (xpath == './/icon') {
return [
{attrib: {src: 'test.png', width: '57', 'gap:platform': 'ios'}},
{attrib: {src: 'test-72.png', width: '72', 'gap:platform': 'ios'}},
{attrib: {src: 'test@2x.png', width: '114', 'gap:platform': 'ios'}},
{attrib: {src: 'test-72@2x.png', width: '144', 'gap:platform': 'ios'}}
];
} else if (xpath == './/splash') {
return [
{attrib: {src: 'test.png', height: '480', 'gap:platform': 'ios'}},
{attrib: {src: 'test.png', height: '960', 'gap:platform': 'ios'}},
{attrib: {src: 'test.png', height: '1136', 'gap:platform': 'ios'}},
{attrib: {src: 'test.png', height: '1004', 'gap:platform': 'ios'}},
{attrib: {src: 'test.png', height: '2008', 'gap:platform': 'ios'}},
{attrib: {src: 'test.png', height: '748', 'gap:platform': 'ios'}},
{attrib: {src: 'test.png', height: '1496', 'gap:platform': 'ios'}},
];
}
}
};
}
}
};

it('should copy icons', function() {
p.copy_icons(cfg);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test.png', 'some/path/platforms/ios/test/Resources/icons/icon.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test-72.png', 'some/path/platforms/ios/test/Resources/icons/icon-72.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test@2x.png', 'some/path/platforms/ios/test/Resources/icons/icon@2x.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test-72@2x.png', 'some/path/platforms/ios/test/Resources/icons/icon-72@2x.png'
);
});

it('should copy splashes', function() {
p.copy_splashes(cfg);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test.png', 'some/path/platforms/ios/test/Resources/splash/Default~iphone.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test.png', 'some/path/platforms/ios/test/Resources/splash/Default@2x~iphone.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test.png', 'some/path/platforms/ios/test/Resources/splash/Default-568h@2x~iphone.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test.png', 'some/path/platforms/ios/test/Resources/splash/Default-Portrait~ipad.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test.png', 'some/path/platforms/ios/test/Resources/splash/Default-Portrait@2x~ipad.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test.png', 'some/path/platforms/ios/test/Resources/splash/Default-Landscape~ipad.png'
);
expect(cp).toHaveBeenCalledWith(
'-f', 'some/path/platforms/ios/www/test.png', 'some/path/platforms/ios/test/Resources/splash/Default-Landscape@2x~ipad.png'
);

});


});
});
Loading

0 comments on commit f36666d

Please sign in to comment.