Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7259] Android: Gesture - orientation change fires on app start when initial orientation is landscape

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-05-02T10:22:03.000+0000
Affected Version/sn/a
Fix Version/sRelease 2.1.0, Sprint 2012-09 Core
ComponentsAndroid
Labelscore, module_gesture, parity, qe-testadded
ReporterPaul Dowsett
AssigneeMax Stepanov
Created2012-01-17T10:58:26.000+0000
Updated2012-07-06T16:37:12.000+0000

Description

Problem

If initial orientation of the emulator is landscape, two orientationchange events are fired when re-orienting to portrait. Thereafter, it works as expected. The same does not happen when initial orientation is portrait.

Test case

* set emulator to landscape (CTRL+F11) * launch app with code below
var win = Ti.UI.createWindow({
  title: 'Rotate device to test',
  backgroundColor: 'white',
  orientationModes: [ Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT, Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT ],
  fullscreen: false, // same results regardless of whether its a heavyweight window
  exitOnClose: true
});

Ti.Gesture.addEventListener('orientationchange',function(e){
  Titanium.API.info("orientation changed = " + Ti.Gesture.orientation + ", is portrait? " + e.source.isPortrait() + ", is landscape? " + e.source.isLandscape());
});
win.open();

Logs

  421          AndroidRuntime  D  >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
  421          AndroidRuntime  D  CheckJNI is ON
  422           TiApplication  I  (main) [0,0] checkpoint, app created.
  421          AndroidRuntime  D  --- registering native functions ---
  422           TiApplication  I  (main) [399,399] Titanium 2.0.0 (2012/03/01 14:01 0ccdf63)
  422               TiFastDev  D  (main) [276,675] Enabling Fastdev on port 46158
  422               TiFastDev  D  (main) [21,696] sent tokens successfully
  422               TiFastDev  D  (main) [1,697] Fastdev session handshake succesful.
  422           TiApplication  I  (main) [24,721] Titanium Javascript runtime: v8
  422          TiRootActivity  I  (main) [0,0] checkpoint, on root activity create, savedInstanceState: Bundle[mParcelledData.dataSize=204]
   61         ActivityManager  I  Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.appcelerator.testing10/.Testing10Activity }
  421          AndroidRuntime  D  Shutting down VM
  421          AndroidRuntime  I  NOTE: attach of thread 'Binder Thread #3' failed
  422           TiApplication  E  (KrollRuntimeThread) [1126,1126] APP PROXY: ti.modules.titanium.app.AppModule@44fc8058
  422           TiAssetHelper  D  Fetching "app.js" with Fastdev...
   61         ActivityManager  I  Starting activity: Intent { cmp=com.appcelerator.testing10/org.appcelerator.titanium.TiActivity (has extras) }
  422          TiRootActivity  I  (main) [0,0] checkpoint, on root activity resume. activity = com.appcelerator.testing10.Testing10Activity@44f60a88
  422                TiUIView  D  (main) [440,440] Nativeview is null
  422                TiUIView  D  (main) [44,484] Nativeview is null
   61     InputManagerService  W  Got RemoteException sending setActive(false) notification to pid 401 uid 10040
   61     NotificationService  W  Object died trying to hide notification android.app.ITransientNotification$Stub$Proxy@4509fef8 in package com.appcelerator.testing10
   61         ActivityManager  W  setProcessForeground called on unknown pid: 401
   61         ActivityManager  I  Displayed activity com.appcelerator.testing10/.Testing10Activity: 14070 ms (total 3531 ms)
   61         ActivityManager  I  Displayed activity com.appcelerator.testing10/org.appcelerator.titanium.TiActivity: 701 ms (total 701 ms)
   61         ActivityManager  I  Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=2 layout=34 uiMode=17 seq=27}
  422                   TiAPI  I  orientation changed = 2, is portrait? false, is landscape? true
   61           WindowManager  I  Setting rotation to 0, animFlags=0
   61         ActivityManager  I  Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=28}
  422                   TiAPI  I  orientation changed = 1, is portrait? true, is landscape? false

Comments

  1. Max Stepanov 2012-04-30

    PR pending https://github.com/appcelerator/titanium_mobile/pull/2105
  2. Max Stepanov 2012-05-01

    The primary cause of the issue is that Android OS reports onConfigurationChanged twice when activity starts in landscape mode. The solution is to remember correct current orientation on activity start.
  3. Olga Romero 2012-06-23

    Verified fix with Titanium Studio, build: 2.1.0.201206221045 Titanium SDK: 2.1.0.v20120622174154 Device: Nexus S 4.0.4

JSON Source