Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4511] Orientation properties report differing values on Android, and differ from iOS

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-03-27T13:50:17.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterTim Poulsen
AssigneeAllen Yeung
Created2011-06-15T11:46:03.000+0000
Updated2012-03-27T13:50:17.000+0000

Description

Problem

On Android, Ti.Gesture.orientation is returning different values than e.orientation, and neither are differentiating landscape left and right.

Sample Code

The following code reports the different orientation values. Run it on iOS, and you will see the Ti.Gesture.orientation is in sync with the evt.orientation. But run it on Android, and you will see they differ.
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var lblOrientation = Ti.UI.createLabel({
    color: '#999',
    text: 'Ti.Gesture.orientation',
    font: { fontSize: 20, fontFamily: 'Helvetica Neue' },
    textAlign: 'center',
    width: 'auto', height: 'auto',
    top: 20
});
win.add(lblOrientation);
var lblEvtOrientation = Ti.UI.createLabel({
    color: '#999',
    text: 'e.orientation',
    font: { fontSize: 20, fontFamily: 'Helvetica Neue' },
    textAlign: 'center',
    width: 'auto', height: 'auto',
    top: 50
});
win.add(lblEvtOrientation);
var lblIsPortrait = Ti.UI.createLabel({
    color: '#999',
    text: 'isPortrait',
    font: { fontSize: 20, fontFamily: 'Helvetica Neue' },
    textAlign: 'center',
    width: 'auto',
    height: 'auto',
    top: 80
});
win.add(lblIsPortrait);
var lblIsLandscape = Ti.UI.createLabel({
    color: '#999',
    text: 'isLandscape',
    font: { fontSize: 20, fontFamily: 'Helvetica Neue' },
    textAlign: 'center',
    width: 'auto', height: 'auto',
    top: 110
});
win.add(lblIsLandscape);

Ti.Gesture.addEventListener('orientationchange', function(evt) {
    lblOrientation.text = Ti.Gesture.orientation;
    lblEvtOrientation.text = evt.orientation;
    lblIsPortrait.text = evt.source.isPortrait();
    lblIsLandscape.text = evt.source.isLandscape();
});

win.open();

Screenshots

See attached screens.

May Duplicate

[TIMOB-1294]

Attachments

FileDateSize
left.png2011-06-15T11:46:03.000+000017468
right.png2011-06-15T11:46:03.000+000017468
Screenshot_18.png2011-06-15T11:46:03.000+0000116526
Screenshot_19.png2011-06-15T11:46:03.000+0000116654

Comments

  1. Dawson Toth 2011-06-15

    I think this only half duplicates [TIMOB-1294]. You bring up two bugs: 1. e.orientation should equal Ti.Gesture.orientation. This duplicates [TIMOB-1294]. 2. The orientations are incorrect for left and right landscape; they should be consistent between iOS and Android. So this ticket could be repurposed for the 2nd issue you brought up, and the 1st can be removed. You could provide more details and sample code on [TIMOB-1294] to help it on its way, too.
  2. Tim Poulsen 2011-06-15

    Just to be clear: On Android * e.orientation reports the same value whether phone is landscape left or right * Ti.Gesture.orientation is also the same whether left or right * But e.orientation != Ti.Gesture.orientation regardless of phone's orientation On iOS * e.orientation reports the different values when phone is landscape left or right * Ti.Gesture.orientation is also reports different when left or right * And e.orientation == Ti.Gesture.orientation iOS appears to be working correctly and as I'd expect. I've provided info on it just as a contrast to what's happening on Android.
  3. Paul Dowsett 2011-06-20

    Tim Being an employee, you should have write access to the main projects. Can you confirm this, please? Thus, you should be able to move this ticket yourself to the correct project. Thanks
  4. Tim Poulsen 2011-06-28

    Paul, I can create issues under two projects: Aptana Studio and Titanium Community.
  5. Paul Dowsett 2011-06-28

    Tim, OK, my apologies - it isn't actually available to *all* employees but, rather, some departments.
  6. Allen Yeung 2011-12-20

    I was not able to reproduce this bug in master. I will be filing a separate bug for apidocs regarding what ti.gesture.orientation returns.
  7. Tim Poulsen 2011-12-21

    Yes, this seems to have been fixed in the 1.8 series as I can't reproduce the problem any more either.

JSON Source