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

[TIMOB-19707] If the DefaultIcon.png or DefaultIcon-ios.png contains … #7340

Merged
merged 1 commit into from
Oct 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 39 additions & 14 deletions iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var appc = require('node-appc'),
jsanalyze = require('titanium-sdk/lib/jsanalyze'),
moment = require('moment'),
path = require('path'),
PNG = require('pngjs').PNG,
spawn = require('child_process').spawn,
ti = require('titanium-sdk'),
util = require('util'),
Expand Down Expand Up @@ -4388,29 +4389,53 @@ iOSBuilder.prototype.copyResources = function copyResources(next) {

writeAssetContentsFile.call(this, path.join(appIconSetDir, 'Contents.json'), appIconSet);

if (missingIcons.length) {
if (defaultIcon && defaultIconHasAlpha) {
this.logger.error(__('%s cannot be used because it contains an alpha channel', defaultIcon));
this.logger.error(__('Create an image named "%s" that does not have an alpha channel in the root of your project', 'DefaultIcon-ios.png'));
this.logger.error(__('It is highly recommended that the DefaultIcon.png be 1024x1024') + '\n');
process.exit(1);
}
if (!missingIcons.length) {
return next();
}

this.logger.debug(__n(
'Missing %s app icon, generating missing icon',
'Missing %s app icons, generating missing icons',
missingIcons.length
));
this.logger.debug(__n(
'Missing %s app icon, generating missing icon',
'Missing %s app icons, generating missing icons',
missingIcons.length
));

var generate = function generate() {
if (defaultIcon && defaultIconChanged && !this.forceRebuild) {
this.logger.info(__('Forcing rebuild: %s changed since last build', defaultIcon));
this.forceRebuild = true;
}

this.generateAppIcons(missingIcons, next);
} else {
next();
}.bind(this);

if (!defaultIcon || !defaultIconChanged || !defaultIconHasAlpha) {
return generate();
}

// strip alpha
this.logger.warn(__('The default icon "%s" contains an alpha channel which is not supported by iOS', defaultIcon));
this.logger.warn(__('The image will be flattened against a white background'));
this.logger.warn(__('You may create an image named "%s" that does not have an alpha channel in the root of your project', 'DefaultIcon-ios.png'));
this.logger.warn(__('It is highly recommended that the DefaultIcon.png be 1024x1024'));

var flattenedImage = path.join(this.buildDir, 'DefaultIcon.png');
this.defaultIcons = [ flattenedImage ];

this.logger.debug(__('Stripping alpha channel: %s => %s', defaultIcon.cyan, flattenedImage.cyan));
fs.createReadStream(defaultIcon)
.pipe(new PNG({
colorType: 2,
bgColor: {
red: 255,
green: 255,
blue: 255
}
}))
.on('parsed', function() {
this.pack()
.on('end', generate)
.pipe(fs.createWriteStream(flattenedImage));
});
},

function createLaunchImageSet() {
Expand Down
184 changes: 184 additions & 0 deletions node_modules/pngjs/.eslintrc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions node_modules/pngjs/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions node_modules/pngjs/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.