Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17718] iOS8: Ti.Platform.displayCaps.density - requires new value for iPhone 6+ specifically

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-10-07T16:23:43.000+0000
Affected Version/sRelease 3.4.0
Fix Version/sRelease 3.4.2, Release 3.5.0, Release 4.0.0
ComponentsiOS
Labels3.4.0-beta, TCSupport, ios, module_platform
ReporterMalcolm Hollingsworth
AssigneeJon Alter
Created2014-09-17T07:24:16.000+0000
Updated2016-02-08T20:34:35.000+0000

Description

When running the latest Ti SDK 3.4 16th Sep the app now starts up and correctly reports the display caps. The density value is "high" for the @2x devices; iPhone 4, iPhone 4s, iPhone 5, iPhone 5s & iPhone 6 - which is correct. However the iPhone 6+ which is a @3x should gain a new value for the density property to help distinguish it from the other devices. The dpi does change, but as that could be different for different families of iDevices it cannot be used without also checking other values to confirm - which will get ever more complicated. Android devices report back a different value for all of their densities, I think @3x on an iDevice should also be distinct from @1x & @2x devices. All other values appear correct, quick tests from the top three devices; iPhone 6+ Ti.Platform.displayCaps.density: high Ti.Platform.displayCaps.dpi: 480 Ti.Platform.displayCaps.platformHeight: 736 Ti.Platform.displayCaps.platformWidth: 414 Ti.Platform.model: Simulator Ti.Platform.name: iPhone OS Ti.Platform.osname: iphone Ti.Platform.ostype: 32bit iPhone 6 Ti.Platform.displayCaps.density: high Ti.Platform.displayCaps.dpi: 320 Ti.Platform.displayCaps.platformHeight: 667 Ti.Platform.displayCaps.platformWidth: 375 Ti.Platform.model: Simulator Ti.Platform.name: iPhone OS Ti.Platform.osname: iphone Ti.Platform.ostype: 32bit iPhone 5 Ti.Platform.displayCaps.density: high Ti.Platform.displayCaps.dpi: 320 Ti.Platform.displayCaps.platformHeight: 568 Ti.Platform.displayCaps.platformWidth: 320 Ti.Platform.model: Simulator Ti.Platform.name: iPhone OS Ti.Platform.osname: iphone Ti.Platform.ostype: 32bit

Comments

  1. Fokke Zandbergen 2014-09-17

    Why not just deprecate this and make Ti.Platform.displayCaps.logicalDensityFactor available under iOS as well and just return \[UIScreen mainScreen\].scale;?
  2. Malcolm Hollingsworth 2014-09-18

    Having reviewed some Ti code related to choosing the correct versions of things I have noted the occasional use of explicit statements noting actual device models. Given this I feel my own subject should be changed to all iOS @3x devices - not just the iPhone 6+ which is the only current one available today. I agree with Fokke that
    Ti.Platform.displayCaps.logicalDensityFactor
    should be enabled and used correctly to reflect the @1x - @3x densities. However I do suggest that
    Ti.Platform.displayCaps.density
    is updated as it is used by many, does no harm, is not an anti-pattern and is complementary to the Android values.
  3. Ingo Muschenetz 2014-09-18

    We do agree that logicalDensityFactor is a fine addition for iOS. However, in the meantime, why couldn't you use the DPI values? Related, what would we use after "high"? "higher"?
  4. Fokke Zandbergen 2014-09-19

    Yes, using the dpi is a good - temporary - workaround. I would *not* add a new value to Ti.Platform.displayCaps. That would only keep people from switching to using Ti.Platform.displayCaps.logicalDensityFactor which is more future proof. Just deprecate it and leave it returning high for iPhone 6+.
  5. Malcolm Hollingsworth 2014-09-19

    Vehemently against the removal of
    Ti.Platform.displayCaps.density
    I would have spent time writing a ticket about the importance of updating property in line with new ratios this without thinking this through. There are many things that offer more than one to achieve your goals and often like this one it is one way to determine things in combination with others. Unless this can be shown to be an anti-pattern removal is just stupid. The suggestion that
    Ti.Platform.displayCaps.logicalDensityFactor
    was a good one. But in doing so you are suggesting that iOS comes in line with Android and removing density takes away the universal nature of being able to call either property.
  6. Ingo Muschenetz 2014-09-19

    [~core13] If we do decide to add a new value, I'm not sure what to call it. And I can't imagine this is the last time the DPI changes. Since 480 matches the android value, we could use xhigh: http://developer.android.com/reference/android/util/DisplayMetrics.html#DENSITY_XHIGH
  7. Malcolm Hollingsworth 2014-09-19

    Ingo If we are trying to match the iOS version against the Android examples then the existing 320 dpi is matched incorrectly right now it should be xhdpi, where as it appears to match the hdpi. It is also worth noting that Androids information on 480dpi appears to contradict the link you provided. http://developer.android.com/guide/practices/screens_support.html#range - The original iPhone is @1x (Android mdpi) the medium density value matches - Retina iPhone is @2x (Android xxhpi) the high density value does not match - iPhone 6+ is @3x (Android xxhdpi) this is the problem - we would need either correct the @2x or go with it. I would recommend going with the existing density name for @2x as correcting this now is simply wrong, then use *xhigh* as the @3x value. Whilst this agrees with your choice it comes at it from another angle. In the future simply add another *x* as a prefix until the standard or logic changes down the road. This would give iOS its own sequence; medium, high, xhigh. This plus the use of *logicalDensityFactor* for @1x, @2x & @3x as; 1, 2 & 3 as Fokke suggested will really improve this section of the API.
  8. Jon Alter 2014-10-07

    PR master: https://github.com/appcelerator/titanium_mobile/pull/6202 PR 3_4_X: https://github.com/appcelerator/titanium_mobile/pull/6203
  9. Vishal Duggal 2014-10-07

    PR's merged. @3x scale factor now returns density "xhigh"
  10. Ewan Harris 2014-10-07

    Verified fix on: Mac OSX 10.9.5 Appcelerator Studio, build: 3.4.0.201409261245 Titanium SDK build: 3.4.1.v20141007092513, 3.5.0.v20141007092513 Titanium CLI, build: 3.5.0-dev Alloy: 1.5.1 Xcode: 6.1 GM Seed iPhone 6 Plus (8.0.2), iPhone 6 (8.0.2) Built to an iPhone 6 Plus and queried Ti.Platform.displayCaps.density in an alert, the value returned is 'xhigh' as expected and on an iPhone 6 the value returned is 'high' as expected. Closing ticket.

JSON Source