Skip to content

Instantly share code, notes, and snippets.

@ricardoalcocer
Created July 30, 2013 18:38
Show Gist options
  • Save ricardoalcocer/6115571 to your computer and use it in GitHub Desktop.
Save ricardoalcocer/6115571 to your computer and use it in GitHub Desktop.
Alloy JMK file to transfer Android settings from the tiapp.xml to the Alloy assets folder. The use-case for this is that you can know at runtime which Holo Theme the app is using (if any) and based on this, make UI/UX or graphic decisions like setting colors, images, etc. Next on this idea is an app.tss with pre-defined color for Holo Dark and H…
task("pre:compile",function(event,logger){
var fs = require('fs'),
xml2js = require('xml2js');
var parser = new xml2js.Parser();
parser.addListener('end', function(result) {
var androidSettings=JSON.stringify(result["ti:app"].android[0]);
fs.writeFile(event.dir.project + '/app/assets/holosettings.json', androidSettings, function (err) {
if (err) throw err;
logger.info('It\'s saved!');
});
});
fs.readFile(event.dir.project + '/tiapp.xml', function(err, data) {
parser.parseString(data);
});
});
task("post:compile",function(event,logger){
logger.info('compile finished!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment