Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7917] Android: Ti.Platform.displayCaps.platformWidth return value changes on Honeycomb tablet when app is run in "zoom" mode

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-03-14T14:22:21.000+0000
Affected Version/sRelease 1.8.2
Fix Version/sRelease 2.0.0, Sprint 2012-06
ComponentsAndroid
Labelsmodule_platform, qe-testadded
ReporterShawn Lipscomb
AssigneeOpie Cyrus
Created2012-03-05T12:11:54.000+0000
Updated2012-07-09T13:43:48.000+0000

Description

Problem

Note that the Environment (above) does not display all of the relevent information: - Titanium Mobile SDK 1.8.2 and 1.8.1 - Android 3.2 emulator (honeycomb), WXGA, app run in "zoom to fill screen" mode - Also seen on Acer Icona Tab A200 tablet (honeycomb) and Asus Transformer Prime tablet (ICS) - Windows 7 - Titanium Studio 1.0.9.201202141208 Ti.Platform.displayCaps.platformWidth, when called repeatedly with some calls to Ti.Platform.displayCaps.dpi mixed in, returns 2 different numbers. The first call to Ti.Platform.displayCaps.platformWidth seems to return the correct value (545 in my case, since the emulator starts off in landscape orientation). After calling Ti.Platform.displayCaps.dpi, the next call to Ti.Platform.displayCaps.platformWidth returns an incorrect value (1280 in my case). This incorrect value is the WXGA width (as if the app were not being run in "zoom mode"). Continuing this pattern of calls, eventually the result of Ti.Platform.displayCaps.platformWidth will start returning the correct value again (545). It is therefore impossible to reliably determine the dimensions of the screen.

Testcase

var LastPW=null;
var LastDPI,Result;
for (var c=0; (c < 12); c++)
{
  Result=Ti.Platform.displayCaps.platformWidth;
  LastDPI=Ti.Platform.displayCaps.dpi;
  Ti.API.info('*--> '+'platformWidth returning:'+Result);
  if ((LastPW != null) && (Result != LastPW))
    Ti.API.info('*--> '+'CHANGE IN platformWidth');
  LastPW=Result;  
}
Ti.API.info('*--> '+'Done');

Console output:

{noformat} >platformWidth returning:545 >platformWidth returning:1280 >CHANGE IN platformWidth >platformWidth returning:1280 >platformWidth returning:1280 >platformWidth returning:1280 >platformWidth returning:1280 >platformWidth returning:545 >CHANGE IN platformWidth >platformWidth returning:1280 >CHANGE IN platformWidth >platformWidth returning:1280 >platformWidth returning:1280 >platformWidth returning:1280 >platformWidth returning:1280 >Done {noformat}

Expected Result

Ti.Platform.displayCaps.platformWidth should consistently return 545 in this test case.

More Information

If you remove the call to Ti.Platform.displayCaps.dpi, the problem does not occur.

Comments

  1. Opie Cyrus 2012-03-13

    Suspect this is due to deprecation of the previous getWidth, etc method on the Android Display object that is updated with 3.2 (lvl 13)
  2. Opie Cyrus 2012-03-14

    PR https://github.com/appcelerator/titanium_mobile/pull/1669 opened
  3. Wilson Luu 2012-03-16

    Closing bug. Verified fix on: SDK build: 2.0.0.v20120316124800 Runtime: v8, rhino Titanium Studio, build: 2.0.0.201203152033 Device: Xoom (3.2.1)
  4. Shawn Lipscomb 2012-03-19

    Verified fix on SDK 2.0.0.v20120319003254. Thanks!

JSON Source