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.
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)
PR https://github.com/appcelerator/titanium_mobile/pull/1669 opened
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)
Verified fix on SDK 2.0.0.v20120319003254. Thanks!