mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
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
This commit is contained in:
parent
bc9e895e25
commit
69a2a5b551
35
bin/templates/cordova/lib/prepare.js
vendored
35
bin/templates/cordova/lib/prepare.js
vendored
@ -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 <preference> 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user