Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1349] Titanium.Platform.displayCaps.dpi returns wrong value on iPhone 4

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:55:56.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0
ComponentsiOS
Labelsdensity, dpi, iphone4, patch, resolution
ReporterBrion Vibber
AssigneeReggie Seagraves
Created2011-04-15T02:50:07.000+0000
Updated2011-04-17T01:55:56.000+0000

Description

In StatusNet Mobile, I'm trying to check the display resolution to see whether higher-resolution avatar images should be fetched when running on an iPhone 4 or high-resolution Android device.

Expected behavior:

On iPhone 4 (or iPhone SDK 4 simulator with hardware set to iPhone 4), Titanium.Platform.displayCaps.dpi should return 320.

Actual behavior:

Titanium.Platform.displayCaps.dpi is currently hardcoded to return 160 for iPhoneOS/iOS unless on an iPad, in which case it's hardcoded to return 130; this leaves apps unable to distinguish between an iPhone 2g/3g/3gs and an iPhone 4.

Comments

  1. Brion Vibber 2011-04-15

    Fix calling the existing scale check helper functions on TiUtils:

    http://github.com/brion/titanium_mobile/commit/778cf65ca1aaa47d0e14fd62566d1450413d9e6b"> http://github.com/brion/titanium_mobile/commit/778cf65ca1aaa47d0e14...

    Note that this leaves the details of 160/320 as two hardcoded alternatives; also the existing code returns "high" density for iPad, which I did not change although it looks wrong -- iPad's density is around 130 dpi (which it does report correctly), the lowest of any iOS device.

  2. Brion Vibber 2011-04-15

    The above commit had a stray { sneak in which breaks building; corrected version here:
    http://github.com/brion/titanium_mobile/commit/2b279bf36d5086a10c7373d2a10f66cbce00a38a"> http://github.com/brion/titanium_mobile/commit/2b279bf36d5086a10c73...

  3. Brion Vibber 2011-04-15

    Adding "[PATCH]" to title.

  4. Luke Melia 2011-04-15

    +1 for this. I have the same need: deciding whether to fetch high-res resolution images from our servers.

  5. Brion Vibber 2011-04-15

    Assigning open patches from StatusNet to our support contact per request.

  6. James K 2011-04-15

    I've never heard of a 'dots per inch' measure in a context not involving printers or documents.

    Does 'dots per inch' mean the same thing as 'pixels per inch'?

    If so, values of 160 and 320 are both wrong -- they should be http://www.apple.com/iphone/iphone-3gs/specs.html">163 and http://www.apple.com/iphone/specs.html">326.

  7. Brion Vibber 2011-04-15

    'dpi' is very often used to describe logical on-screen pixel density in the fun world of software, as anybody who's done graphics programming on Windows or Mac OS in the last 25 years can assure you. :)

    163/326 are more correct for the hardware, but whatever the case currently rounded values are being returned. (On Android, the fixed values 120, 160, or 240 are returned, as these are what's defined as available on the platform, though honestly I'd be surprised if every phone has those EXACT resolutions in hardware. On regular computer screens, standard logical values like 72, 96 or 120 are usually returned for the logical screen "dpi" despite having only a very approximate correspondence with the actual screen's resolution.)

    I can't find an actual dpi/ppi/whatever check in iOS's available display caps checks (just the scale factor from the logical coordinate system to the framebuffer's pixel grid), so I don't know what Apple would like to "call" it in software, but returning 160 on iPhone 4 definitely is wrong -- it should be twice what we get back from an iPhone original/3G/3Gs.

    On Android we get the defined value for the framebuffer space (120, 160, 240) for dpi, while platformWidth and platformHeight give us logical coordinates. If that's the correct behavior there, then we should be getting 320 (or 326, or whatever) as dpi on iPhone 4. Main point is, we need to be able to distinguish between different screen resolutions so we can ensure we are working with images of the appropriate resolution.

  8. Brion Vibber 2011-04-15

    Any issues with this patch? Anyone whose attention I should bring it to specifically?

  9. Jeff Haynie 2011-04-15

    merged.

  10. Thomas Huelbert 2011-04-15

    iPad - 130 (160 in compatibility mode)
    3g/3gs/ipod touch (3rd) - 160
    4g/4th gen ipod touch - 320

    Closing as resolved.

JSON Source