Repository: cordova-cli Updated Branches: refs/heads/master ad15396f9 -> 6fae83eb0
CB-6209 Uplevel changes from android_parser to amazon_fireos_parser Added orientation related config changes from android_parser. Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/6fae83eb Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/6fae83eb Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/6fae83eb Branch: refs/heads/master Commit: 6fae83eb036ca9d5a7f1ca89eb4f90cb9d00208b Parents: ad15396 Author: Archana Naik <[email protected]> Authored: Mon Mar 10 12:55:20 2014 -0700 Committer: Archana Naik <[email protected]> Committed: Mon Mar 10 12:55:20 2014 -0700 ---------------------------------------------------------------------- src/metadata/amazon_fireos_parser.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6fae83eb/src/metadata/amazon_fireos_parser.js ---------------------------------------------------------------------- diff --git a/src/metadata/amazon_fireos_parser.js b/src/metadata/amazon_fireos_parser.js index 7e9d36d..725e7bc 100644 --- a/src/metadata/amazon_fireos_parser.js +++ b/src/metadata/amazon_fireos_parser.js @@ -51,6 +51,16 @@ module.exports.check_requirements = function(project_root) { }; module.exports.prototype = { + findOrientationPreference: function(config) { + var ret = config.getPreference('orientation'); + if (ret && ret != 'default' && ret != 'portrait' && ret != 'landscape') { + events.emit('warn', 'Unknown value for orientation preference: ' + ret); + ret = null; + } + + return ret; + }, + update_from_config:function(config) { if (config instanceof ConfigParser) { } else throw new Error('update_from_config requires a ConfigParser object'); @@ -73,6 +83,23 @@ module.exports.prototype = { var orig_pkg = manifest.getroot().attrib.package; manifest.getroot().attrib.package = pkg; + // Set the orientation in the AndroidManifest + var orientationPref = this.findOrientationPreference(config); + if (orientationPref) { + var act = manifest.getroot().find('./application/activity'); + switch (orientationPref) { + case 'default': + delete act.attrib["android:screenOrientation"]; + break; + case 'portrait': + act.attrib["android:screenOrientation"] = 'userPortrait'; + break; + case 'landscape': + act.attrib["android:screenOrientation"] = 'userLandscape'; + } + } + + // Write out AndroidManifest.xml fs.writeFileSync(this.manifest, manifest.write({indent: 4}), 'utf-8');
