From 69a2a5b551e50bb2707cdbd7b0b768735f9f9a62 Mon Sep 17 00:00:00 2001 From: Vladimir Kotikov Date: Fri, 18 Mar 2016 15:07:16 +0300 Subject: [PATCH] CB-10837 Support platform-specific orientation on Android Remove processing of "orientation" preference and let user to specify any platform-specific value for Android This closes #281 --- bin/templates/cordova/lib/prepare.js | 35 +--------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/bin/templates/cordova/lib/prepare.js b/bin/templates/cordova/lib/prepare.js index 474ffd62..6e050c55 100644 --- a/bin/templates/cordova/lib/prepare.js +++ b/bin/templates/cordova/lib/prepare.js @@ -131,7 +131,7 @@ function updateProjectAccordingTo(platformConfig, locations) { var orig_pkg = manifest.getPackageId(); manifest.getActivity() - .setOrientation(findOrientationValue(platformConfig)) + .setOrientation(platformConfig.getPreference('orientation')) .setLaunchMode(findAndroidLaunchModePreference(platformConfig)); manifest.setVersionName(platformConfig.version()) @@ -344,36 +344,3 @@ function findAndroidLaunchModePreference(platformConfig) { return launchMode; } - -/** - * Queries ConfigParser object for the orientation value. Warns if - * global preference value is not supported by platform. - * - * @param {Object} platformConfig ConfigParser object - * - * @return {String} Global/platform-specific orientation in lower-case - * (or empty string if both are undefined). - */ -function findOrientationValue(platformConfig) { - - var ORIENTATION_DEFAULT = 'default'; - - var orientation = platformConfig.getPreference('orientation'); - if (!orientation) { - return ORIENTATION_DEFAULT; - } - - var GLOBAL_ORIENTATIONS = ['default', 'portrait','landscape']; - function isSupported(orientation) { - return GLOBAL_ORIENTATIONS.indexOf(orientation.toLowerCase()) >= 0; - } - - // Check if the given global orientation is supported - if (orientation && isSupported(orientation)) { - return orientation; - } - - events.emit('warn', 'Unsupported global orientation: ' + orientation + - '. Defaulting to value: ' + ORIENTATION_DEFAULT); - return ORIENTATION_DEFAULT; -}