Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19558] Ti.Gesture: orientationchange event reports incorrect orientation

GitHub Issuen/a
TypeBug
PriorityCritical
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 4.1.0, Release 4.1.1, Release 5.0.0
Fix Version/sn/a
ComponentsAndroid
Labelsandoid, android-4.0, orientation, orientationChange, titanbeta
ReporterShawn Lipscomb
AssigneeFrankie Merzadyan
Created2015-09-21T16:34:17.000+0000
Updated2017-03-27T16:07:29.000+0000

Description

The Ti.Gesture orientationchange event reports incorrect orientation. Run the following code, holding the device in portrail orientation, and it will report Landscape Left. Rotate the device, and the reported orientation will always be 90 degrees off.
Ti.UI.setBackgroundColor('#000');

// Ti.UI.PORTRAIT=1
// Ti.UI.LANDSCAPE_LEFT=2
// Ti.UI.UPSIDE_PORTRAIT=3
// Ti.UI.LANDSCAPE_RIGHT=4

var OrientationNames=[ 'Unknown', 'Portrait', 'Landscape Left', 'Upside Down Portrait', 'Landscape Right' ];

var win1=Ti.UI.createWindow({
           exitOnClose:true,
           navBarHidden:false,
           backgroundColor:'#fff',
           layout:'vertical'
         });

var OrigOri=Ti.Gesture.orientation;
var label1=Ti.UI.createLabel({
             color:'#999',
             text:'Original Orientation: '+OrientationNames[OrigOri]+' ('+OrigOri+')',
             font:{fontSize:20,fontFamily:'Helvetica Neue'},
             textAlign:'center',
             top:'25%',
             width:'auto'
           });
var label2=Ti.UI.createLabel({
             color:'#999',
             text:'Current Orientation: '+OrientationNames[OrigOri]+' ('+OrigOri+')',
             font:{fontSize:20,fontFamily:'Helvetica Neue'},
             textAlign:'center',
             top:'25%',
             width:'auto'
           });

win1.add(label1);
win1.add(label2);
win1.open();

Ti.Gesture.addEventListener('orientationchange',TestOrientationChange);
function TestOrientationChange(evt)
{
  var CurrOri=evt.orientation;
  label2.text='Current Orientation: '+OrientationNames[CurrOri]+' ('+CurrOri+')';
}

Comments

  1. Chee Kiat Ng 2015-09-22

    Is this a regression?
  2. Stefan Schüller 2015-09-22

  3. Shawn Lipscomb 2015-09-22

    Yes, it is a regression. Works fine in Ti SDK 3.5.1.
  4. Shawn Lipscomb 2017-03-27

    Happy to see that this has finally been assigned to someone.

JSON Source