Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25467] Android: "Ti.UI.Window.orientation" should return screen orientation in split-screen mode

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2017-11-15T00:09:06.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.0.0
ComponentsAndroid
Labelsandroid, orientation, parity
ReporterJoshua Quick
AssigneeJoshua Quick
Created2017-10-31T21:38:04.000+0000
Updated2017-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);
});

Comments

  1. Eric Merriman 2017-11-01

    Due to the schedule for 7.0.0 versus the remaining work, moving to 7.1.0
  2. Joshua Quick 2017-11-04

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/9585
  3. Lokesh Choudhary 2017-11-07

    FR Passed. Waiting for merge to get enabled to merge.
  4. Abir Mukherjee 2017-11-15

    PR merged.
  5. Abir Mukherjee 2017-11-15

    Changes are seen in SDK 7.0.0.v20171114202841.

JSON Source