{ "id": "89519", "key": "TIMOB-8546", "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": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-05-30T14:34:58.000+0000", "created": "2012-04-04T15:48:41.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "core", "module_media", "qe-testadded" ], "versions": [ { "id": "12593", "name": "Release 2.0.0", "archived": false, "released": true, "releaseDate": "2012-03-30" } ], "issuelinks": [], "assignee": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-07-13T16:28:10.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "when invalid values are set for width and height an exception occurs when trying to convert the values into TiDimension:\r\n\r\n{code}\r\n\t\t\tvar imageView = Ti.UI.createImageView({\r\n\t\t\t\twidth:win.width,\r\n\t\t\t\theight:win.height,\r\n\t\t\t\timage:event.media\r\n\t\t\t});\r\n\t\t\twin.add(imageView);\r\n{code}\r\n\r\n* this would be when win.width is undefined. This test case can be found in the KS camera test.\r\n\r\n\r\n\r\nResulting error:\r\n{code}\r\n04-04 16:26:45.345 21220 21220 E TiApplication: (main) [9299,18498] Sending event: exception on thread: main msg:java.lang.ClassCastException: org.appcelerator.kroll.KrollRuntime$1; Titanium 2.1.0,2012/04/04 15:16,161fb52\r\n04-04 16:26:45.345 21220 21220 E TiApplication: java.lang.ClassCastException: org.appcelerator.kroll.KrollRuntime$1\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat org.appcelerator.titanium.util.TiConvert.toTiDimension(TiConvert.java:550)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat org.appcelerator.titanium.util.TiConvert.toTiDimension(TiConvert.java:561)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat ti.modules.titanium.ui.widget.TiUIImageView.processProperties(TiUIImageView.java:806)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:737)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:530)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:522)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:500)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:616)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:307)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:110)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:93)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat android.os.Handler.dispatchMessage(Handler.java:95)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat android.os.Looper.loop(Looper.java:143)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat android.app.ActivityThread.main(ActivityThread.java:4701)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat java.lang.reflect.Method.invokeNative(Native Method)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat java.lang.reflect.Method.invoke(Method.java:521)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)\r\n04-04 16:26:45.345 21220 21220 E TiApplication: \tat dalvik.system.NativeStart.main(Native Method)\r\n04-04 16:26:45.353 1401 21298 I MediaScanner: process file: /sdcard/dcim/Camera/tia70621.jpg\r\n04-04 16:26:45.361 1401 21298 D DlnaMediaParser: getJPEGProfileName: 4\r\n04-04 16:26:45.494 1401 1428 D MediaProvider: current image thumbnail number created successfully is:2\r\n04-04 16:26:45.728 1238 1257 D BatteryTempPolicy: updateBatteryTemp temperature = 380, Threshhold = 3\r\n04-04 16:26:45.767 16521 16521 E GlobalUnplugService: plugged = true,mBatteryPlugged=true\r\n{code}\r\n\r\nWe should gracefully handle invalid values when they are set or processed either by throwing exceptions to let the developer know of the problem or defaulting to valid values. Requires parity discussion.\r\n\r\n", "attachment": [], "flagged": false, "summary": "Android: handle invalid values on width and height gracefully", "creator": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "subtasks": [], "reporter": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "environment": null, "comment": { "comments": [ { "id": "196562", "author": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Fixed by PR 2030", "updateAuthor": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-05-30T13:50:41.000+0000", "updated": "2012-05-30T13:50:41.000+0000" }, { "id": "199949", "author": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "body": "For QE\r\n{code}\r\n\r\nvar win = Titanium.UI.currentWindow;\r\nTitanium.Media.showCamera({\r\n\r\n\tsuccess:function(event)\r\n\t{\r\n\t\tvar cropRect = event.cropRect;\r\n\t\tvar image = event.media;\r\n\r\n\t\tTi.API.debug('Our type was: '+event.mediaType);\r\n\t\tif(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)\r\n\t\t{\r\n\t\t\tvar imageView = Ti.UI.createImageView({\r\n\t\t\t\twidth:win.size.width,\r\n\t\t\t\theight:win.size.height,\r\n\t\t\t\timage:event.media\r\n\t\t\t});\r\n\t\t\twin.add(imageView);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\talert(\"got the wrong type back =\"+event.mediaType);\r\n\t\t}\r\n\t},\r\n\tcancel:function()\r\n\t{\r\n\t},\r\n\terror:function(error)\r\n\t{\r\n\t\t// create alert\r\n\t\tvar a = Titanium.UI.createAlertDialog({title:'Camera'});\r\n\r\n\t\t// set message\r\n\t\tif (error.code == Titanium.Media.NO_CAMERA)\r\n\t\t{\r\n\t\t\ta.setMessage('Please run this test on device');\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\ta.setMessage('Unexpected error: ' + error.code);\r\n\t\t}\r\n\r\n\t\t// show alert\r\n\t\ta.show();\r\n\t},\r\n\tsaveToPhotoGallery:true,\r\n\tallowEditing:true,\r\n\tmediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]\r\n});\r\n{code}", "updateAuthor": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-06-23T15:30:32.000+0000", "updated": "2012-06-23T15:30:32.000+0000" }, { "id": "199950", "author": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified fix with\r\nTitanium Studio, build: 2.1.0.201206221045\r\nTitanium SDK: 2.1.0.v20120622174154\r\nDevice: Nexus S 4.0.4\r\n", "updateAuthor": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-06-23T15:33:24.000+0000", "updated": "2012-06-23T15:33:24.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }