{ "id": "133173", "key": "TIMOB-17329", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "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": "15972", "description": "Release 3.4.0", "name": "Release 3.4.0", "archived": false, "released": true, "releaseDate": "2014-09-28" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-08-18T18:25:27.000+0000", "created": "2014-07-15T04:19:25.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "module_media", "qe-manualtest" ], "versions": [], "issuelinks": [ { "id": "39084", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "outwardIssue": { "id": "133172", "key": "TIMOB-17328", "fields": { "summary": "Android: Add support for file property to HTTPClient", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } }, { "id": "39085", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "132448", "key": "TIMOB-17252", "fields": { "summary": "OpenSky security concerns", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "6", "description": "gh.issue.epic.desc", "name": "Epic", "subtask": false } } } } ], "assignee": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2014-08-18T18:25:27.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": "In Titanium, we use temporary files when we are dealing with data that can not be kept in memory to avoid OOM errors. One case is in the Ti.Media module when the user takes pictures and the savetoPhotoGallery is set to false.\r\n\r\nThe blob representing the response (`media` property for the payload to the success callback) will clearly indicate if the blob represents a file (Titanium.Blob.file will return a valid Titanium.Filesystem.File object). Users are free to delete the file once they have processed the data.\r\n\r\nWe should refactor the API to not rely on the temporary file.", "attachment": [], "flagged": false, "summary": "Android: Refactor Camera API to not use a temporary file", "creator": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "closedSprints": [ { "id": 154, "state": "closed", "name": "2014 Sprint 15 SDK", "startDate": "2014-07-21T21:56:31.515Z", "endDate": "2014-08-02T00:00:00.000Z", "completeDate": "2014-08-04T21:03:51.067Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "314494", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-07-16T22:20:07.000+0000", "updated": "2014-07-22T20:43:41.000+0000" }, { "id": "315347", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Test case from TIMOB-1510\r\n{code}\r\nvar win1 = Titanium.UI.createWindow({\r\n backgroundColor : '#fff',\r\n exitOnClose:true\r\n});\r\n \r\nvar saveToGallery = false;\r\n \r\nvar hasCamera = Ti.Media.isCameraSupported;\r\n \r\nif(hasCamera) {\r\n var hasBackfacingCamera = hasCamera;\r\n var hasFrontfacingCamera = hasCamera;\r\n var front = false;\r\n var availableCameras = Ti.Media.availableCameras;\r\n \r\n hasBackfacingCamera = (availableCameras.indexOf(Ti.Media.CAMERA_REAR) >= 0);\r\n hasFrontfacingCamera = (availableCameras.indexOf(Ti.Media.CAMERA_FRONT) >= 0);\r\n \r\n var b1 = Ti.UI.createButton({\r\n title:'Save To Gallery',\r\n left:0,\r\n top:0,\r\n color:'red',\r\n width:'50%',\r\n height:'10%',\r\n backgroundColor:'black',\r\n }) ;\r\n \r\n var b2 = Ti.UI.createButton({\r\n title:'View Gallery',\r\n right:0,\r\n top:0,\r\n width:'50%',\r\n height:'10%',\r\n backgroundColor:'black',\r\n color:'white'\r\n });\r\n \r\n win1.add(b1);\r\n win1.add(b2);\r\n \r\n var container = Ti.UI.createView({\r\n top:'10%',\r\n height:'80%'\r\n });\r\n \r\n var img = Ti.UI.createImageView({\r\n });\r\n \r\n var saveButton = Ti.UI.createButton({\r\n title:'SAVE',\r\n backgroundColor:'black',\r\n color:'white',\r\n visible:false\r\n });\r\n \r\n container.add(img);\r\n container.add(saveButton);\r\n win1.add(container);\r\n \r\n \r\n var b3 = Ti.UI.createButton({\r\n title:'Native Camera',\r\n top:'90%',\r\n height:'10%',\r\n left:0,\r\n width:'50%',\r\n backgroundColor:'black',\r\n color:'white'\r\n });\r\n win1.add(b3);\r\n \r\n var b4 = Ti.UI.createButton({\r\n title:'Camera Overlay',\r\n top:'90%',\r\n height:'10%',\r\n right:0,\r\n width:'50%',\r\n backgroundColor:'black',\r\n color:'white'\r\n });\r\n \r\n win1.add(b4);\r\n \r\n var overlayObj = Ti.UI.createView({});\r\n var picBtn = Ti.UI.createButton({\r\n title:'Snap Picture',\r\n top:'90%',\r\n height:'10%',\r\n left:0,\r\n width:'50%',\r\n backgroundColor:'black',\r\n color:'white'\r\n });\r\n overlayObj.add(picBtn);\r\n picBtn.addEventListener('click',function(){\r\n Ti.Media.takePicture();\r\n });\r\n if(hasFrontfacingCamera && hasBackfacingCamera) {\r\n var swapBtn = Ti.UI.createButton({\r\n title:'Switch Camera',\r\n top:'90%',\r\n height:'10%',\r\n right:0,\r\n width:'50%',\r\n backgroundColor:'black',\r\n color:'white'\r\n });\r\n \r\n overlayObj.add(swapBtn);\r\n swapBtn.addEventListener('click',function(){\r\n if(front == true) {\r\n Ti.Media.switchCamera(Ti.Media.CAMERA_REAR);\r\n } else {\r\n Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);\r\n }\r\n front = !front; \r\n });\r\n } else {\r\n //Adjust Button\r\n picBtn.width = Ti.UI.FILL;\r\n }\r\n \r\n \r\n saveButton.addEventListener('click',function(e){\r\n if(img.image != undefined) {\r\n Ti.Media.saveToPhotoGallery(img.image,{\r\n success:function(){\r\n alert('Saved. Check In Gallery');\r\n },\r\n error:function(e){\r\n var msg = 'Code: '+e.code+' Msg: '+e.error;\r\n alert(msg);\r\n }\r\n });\r\n \r\n } else {\r\n Ti.API.info('NO IMAGE ON img to save to photo gallery');\r\n }\r\n });\r\n \r\n b1.addEventListener('click',function(){\r\n saveToGallery = !saveToGallery;\r\n if(saveToGallery == true) {\r\n b1.color = 'green';\r\n } else {\r\n b1.color = 'red';\r\n }\r\n });\r\n \r\n \r\n b2.addEventListener('click',function(){\r\n Ti.Media.openPhotoGallery({});\r\n });\r\n \r\n \r\n b3.addEventListener('click',function(){\r\n fireUpTheCamera(saveToGallery,false, false);\r\n });\r\n \r\n b4.addEventListener('click',function(){\r\n if(hasBackfacingCamera && hasFrontfacingCamera) {\r\n //Alwways start with back camera\r\n front = false;\r\n } else {\r\n //Start with what ever camera is available\r\n front = hasFrontfacingCamera;\r\n }\r\n fireUpTheCamera(saveToGallery,true, front);\r\n });\r\n \r\n function fireUpTheCamera(save, hasoverlay, front) {\r\n var options = {\r\n success : function(e) {\r\n Ti.API.info('GOT SUCCESS CALLBACK. File location = '+e.media.nativePath);\r\n var imgWid = e.media.width;\r\n var imgHeight = e.media.height;\r\n var mSize = container.size;\r\n var mW = mSize.width;\r\n var mH = mSize.height;\r\n \r\n var wS = imgWid/mW;\r\n var hS = imgHeight/mH;\r\n var tS = (wS < hS) ? wS : hS;\r\n \r\n var dstWid = imgWid/tS;\r\n var dstHeight = imgHeight/ tS;\r\n \r\n Ti.API.info(imgWid+' '+imgHeight+' '+mW+' '+mH+' '+wS+' '+hS+' '+tS+' '+dstWid+' '+dstHeight);\r\n var resize = e.media.imageAsResized(dstWid,dstHeight);\r\n img.image = resize;\r\n saveButton.visible = true;\r\n },\r\n cancel : function() {\r\n // create alert\r\n var a = Titanium.UI.createAlertDialog({\r\n title : 'Camera',\r\n message: 'Action cancelled by user'\r\n });\r\n a.show(); \r\n },\r\n error : function(error) {\r\n // create alert\r\n var a = Titanium.UI.createAlertDialog({\r\n title : 'Camera'\r\n });\r\n \r\n // set message\r\n var msg = 'Unexpected error: ' + error.code;\r\n if(error.error != undefined) {\r\n msg = msg + ' Message: '+error.error;\r\n }\r\n a.setMessage(msg);\r\n a.show();\r\n },\r\n saveToPhotoGallery : save,\r\n mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],\r\n autohide: true\r\n };\r\n if(hasoverlay) {\r\n options.overlay = overlayObj;\r\n }\r\n if(front) {\r\n options.whichCamera = Ti.Media.CAMERA_FRONT;\r\n }\r\n Titanium.Media.showCamera(options);\r\n }\r\n}else {\r\n var label = Ti.UI.createLabel({\r\n text:'NO CAMERAS ON DEVICE',\r\n color:'red'\r\n });\r\n win1.add(label);\r\n}\r\n \r\nwin1.open();\r\n{code}", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-07-22T21:12:40.000+0000", "updated": "2014-07-22T21:12:40.000+0000" }, { "id": "315348", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "CR + FR ok. Merged", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-07-22T21:13:11.000+0000", "updated": "2014-07-22T21:13:11.000+0000" }, { "id": "315853", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "body": "3_3_X PR: https://github.com/appcelerator/titanium_mobile/pull/5935", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-07-25T18:31:23.000+0000", "updated": "2014-07-25T18:31:23.000+0000" }, { "id": "319134", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the refactor. \r\nThe pics does not get saved as a temp file in the sdcard when \"save to gallery\" is false.\r\n\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 3.4.0.201408051600\r\nTi SDK : 3.4.0.v20140815142514\r\nMac OSX : 10.8.5\r\nAlloy : 1.4.1\r\nCLI - 3.3.0\r\nCode Processor: 1.1.1\r\nNexus 5 - android 4.4.4", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-08-18T18:24:36.000+0000", "updated": "2014-08-18T18:24:36.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }