[TIMOB-25467] Android: "Ti.UI.Window.orientation" should return screen orientation in split-screen mode
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-11-15T00:09:06.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.0.0 |
Components | Android |
Labels | android, orientation, parity |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2017-10-31T21:38:04.000+0000 |
Updated | 2017-11-15T06:20:58.000+0000 |
Description
*Summary:*
The "Ti.UI.Window.orientation" property should return the orientation that the OS is displaying its screen contents. This is how it works on iOS. Instead, on Android, it returns the orientation of the app window based on its width and height (ex: if width > height, then it's landscape).
This is an issue when displaying the app in split-screen mode. For example, when the device is held landscape, apps are displayed side-by-side in portrait form. Android currently returns portrait in this case when it should return landscape (the screen's orientation).
*Steps to Reproduce:*
Run the below code on an Android 7.0 or newer device.
Hold the device in portrait orientation.
On the bottom navigation bar, hold the square button (aka: the multi-tasking button).
Select an app from the multi-tasking app list to put it into split-screen mode.
Notice that this app displays "Landscape" instead of "Portrait".
Rotate the device 90 degrees to landscape form.
Notice that this app displays "Portrait" instead of "Landscape".
*Test Code:*
function getNameFromOrientationId(orientationId) {
switch (orientationId) {
case Ti.UI.PORTRAIT:
return "Portrait Upright";
case Ti.UI.UPSIDE_PORTRAIT:
return "Portrait Upside-Down";
case Ti.UI.LANDSCAPE_LEFT:
return "Landscape Left";
case Ti.UI.LANDSCAPE_RIGHT:
return "Landscape Right";
case Ti.UI.FACE_UP:
return "Face Up";
case Ti.UI.FACE_DOWN:
return "Face Down";
}
return "Unknown";
}
var window = Ti.UI.createWindow();
var label = Ti.UI.createLabel(
{
text: getNameFromOrientationId(Ti.Gesture.orientation),
});
window.add(label);
window.open();
var timerId = setInterval(function() {
if (window) {
label.text = getNameFromOrientationId(window.orientation);
}
}, 1000);
window.addEventListener("close", function(e) {
window = null;
clearInterval(timerId);
});
Due to the schedule for 7.0.0 versus the remaining work, moving to 7.1.0
PR (master): https://github.com/appcelerator/titanium_mobile/pull/9585
FR Passed. Waiting for merge to get enabled to merge.
PR merged.
Changes are seen in SDK 7.0.0.v20171114202841.