Skip to content

Commit

Permalink
fix(cordova): ensurePlatformImages should respect Orientation
Browse files Browse the repository at this point in the history
fixes #2417
  • Loading branch information
imhoffd committed Aug 3, 2017
1 parent 8f23767 commit 651ae0a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/cli-plugin-cordova/src/lib/utils/configXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class ConfigXml {

async ensurePlatformImages(platform: string, resourcesPlatform: ResourcesPlatform) {
const root = this.doc.getroot();
const orientation = await this.getPreference('Orientation') || 'default';

for (let imgName in resourcesPlatform) {
const imgType = resourcesPlatform[imgName];
Expand All @@ -160,7 +161,9 @@ export class ConfigXml {
platformElement = et.SubElement(root, 'platform', { name: platform });
}

for (let image of imgType.images) {
const images = imgType.images.filter(img => orientation === 'default' || typeof img.orientation === 'undefined' || img.orientation === orientation);

for (let image of images) {
const imgPath = path.join('resources', platform, imgType.nodeName, image.name); // TODO: hard-coded 'resources' dir
let imgElement = platformElement.find(`${imgType.nodeName}[@src='${imgPath}']`);

Expand Down

0 comments on commit 651ae0a

Please sign in to comment.