{ "id": "139162", "key": "TIMOB-18305", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2014-11-06T15:37:19.000+0000", "priority": null, "labels": [ "Android", "dafaultunit" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-02-28T19:54:48.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "Hi there.\r\n\r\n\r\nWhen setting default value in tiapp.xml to density independent units (which you want to use because it makes calculations easier):\r\n\r\n{code}\r\ndip\r\n{code}\r\n\r\nTitanium doesn't respect that value in all cases. I've noticed 2 cases, but there may be more:\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow();\r\n\r\nTi.API.info('Platform width & height');\r\nTi.API.info(Ti.Platform.displayCaps.platformWidth);\r\nTi.API.info(Ti.Platform.displayCaps.platformWidth / Ti.Platform.displayCaps.logicalDensityFactor);\r\nTi.API.info(Ti.Platform.displayCaps.platformHeight);\r\nTi.API.info(Ti.Platform.displayCaps.platformHeight / Ti.Platform.displayCaps.logicalDensityFactor);\r\n\r\nvar view = Ti.UI.createView({\r\n\theight: Ti.UI.SIZE,\r\n\tlayout: \"vertical\"\r\n});\r\n\r\nview.add(Ti.UI.createView({ height: 50, backgroundColor: \"#f00\" }));\r\nview.add(Ti.UI.createView({ height: 50, backgroundColor: \"#0f0\" }));\r\nview.add(Ti.UI.createView({ height: 50, backgroundColor: \"#00f\" }));\r\n\r\nview.addEventListener(\"click\", function(e) {\r\n\tTi.API.info(\"on click\");\r\n\tTi.API.info(e.y);\r\n\tTi.API.info(Math.round(e.y / Ti.Platform.displayCaps.logicalDensityFactor));\r\n});\r\n\r\nwin.add(view);\r\n\r\nwin.open();\r\n{code}\r\n\r\n\r\nRun this code after you've set default unit in tiapp.xml. Firstly, you'll see that to get correct platform width and height, you need to divide values with \"logicalDensityFactor\". Same thing happens if you want to get coordinates in \"click\" event. For example, if you click on bottom of red view, you'll see that you'll get x values greater than 50, which is obviously wrong (please note that value should be rounded with 1 decimal point to make this identical to iOS).\r\n\r\n\r\nI'm not sure are there more cases, so please update test case if there are.", "attachment": [], "flagged": false, "summary": "Android: Default unit not respected in all cases", "creator": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "* Ti SDK 3.4.0.GA\r\n* Ti CLI 3.4.0\r\n* Android 4.4.4\r\n* Nexus 5", "comment": { "comments": [ { "id": "337809", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Any progress on fixing the last few API's not respecting the default unit? Apart from this case I know the same is at least true for events passing x/y coordinates.", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-01-05T16:04:54.000+0000", "updated": "2015-01-05T16:04:54.000+0000" }, { "id": "337826", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "I covered events too :)", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-01-05T16:59:26.000+0000", "updated": "2015-01-05T16:59:26.000+0000" }, { "id": "337833", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "I should read better, sorry :)", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2015-01-05T17:46:03.000+0000", "updated": "2015-01-05T17:46:15.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }