[TIMOB-25483] Android: Add FACE_UP/FACE_DOWN support to Ti.Gesture
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-11-15T00:08:44.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.0.0 |
Components | Android |
Labels | android, gesture, orientation |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2017-11-06T18:27:03.000+0000 |
Updated | 2017-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);
});
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.