Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25483] Android: Add FACE_UP/FACE_DOWN support to Ti.Gesture

GitHub Issuen/a
TypeImprovement
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2017-11-15T00:08:44.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.0.0
ComponentsAndroid
Labelsandroid, gesture, orientation
ReporterJoshua Quick
AssigneeJoshua Quick
Created2017-11-06T18:27:03.000+0000
Updated2017-11-15T06:20:05.000+0000

Description

*Summary:* On Android, the "Ti.Gesture.orientation" property and the "orientationchange" event currently only support orientations PORTRAIT, UPSIDE_PORTRAIT, LANDSCAPE_LEFT, and LANDSCAPE_RIGHT. We should also add support for FACE_UP and FACE_DOWN like iOS and Windows Phone for feature parity. *Test Procedure:*

Build and run the below on a physical Android device. (Cannot be tested via emulator.)

Lay the android device flat on a table with the screen facing up towards the sky.

Verify that the app displays "Face Up" onscreen.

Lift the device above your head, with the screen facing straight down towards the Earth.

Verify that the app display "Face Down" onscreen.

*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(
{
	orientationModes: [Ti.UI.PORTRAIT],
});
var label = Ti.UI.createLabel(
{
	text: getNameFromOrientationId(Ti.Gesture.orientation),
});
window.add(label);
window.open();
Ti.Gesture.addEventListener("orientationchange", function(e) {
	label.text = getNameFromOrientationId(e.orientation);
});

Comments

  1. Joshua Quick 2017-11-06

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

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

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

    Changes are seen in SDK 7.0.0.v20171114202841.

JSON Source