Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

[expo-cli][eject] Fix generated orientation in AndroidManifest #2431

Merged
merged 3 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/config/src/android/Orientation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export async function setAndroidOrientation(config: ExpoConfig, manifestDocument
const mainActivity = manifestDocument.manifest.application[0].activity.filter(
(e: any) => e['$']['android:name'] === '.MainActivity'
);
mainActivity[0]['$'][SCREEN_ORIENTATION_ATTRIBUTE] = orientation;
mainActivity[0]['$'][SCREEN_ORIENTATION_ATTRIBUTE] =
orientation !== 'default' ? orientation : 'unspecified';

return manifestDocument;
}
13 changes: 13 additions & 0 deletions packages/config/src/android/__tests__/Orientation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,18 @@ describe('Android orientation', () => {
);
expect(mainActivity[0]['$']['android:screenOrientation']).toMatch('portrait');
});

it('replaces orientation with unspecified if provided default', async () => {
androidManifestJson = await readAndroidManifestAsync(sampleManifestPath);
androidManifestJson = await setAndroidOrientation(
{ orientation: 'default' },
androidManifestJson
);

const mainActivity = androidManifestJson.manifest.application[0].activity.filter(
e => e['$']['android:name'] === '.MainActivity'
);
expect(mainActivity[0]['$']['android:screenOrientation']).toMatch('unspecified');
});
});
});