{ "id": "62142", "key": "TIMOB-1510", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "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": "16092", "description": "2014 Sprint 08", "name": "2014 Sprint 08", "archived": true, "released": true, "releaseDate": "2014-04-24" }, { "id": "16093", "description": "2014 Sprint 08 SDK", "name": "2014 Sprint 08 SDK", "archived": true, "released": true, "releaseDate": "2014-04-24" }, { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-05-28T16:04:52.000+0000", "created": "2011-04-15T02:54:47.000+0000", "epic": { "id": 105183, "key": "TIMOB-11818", "name": "Android: Camera Bugs", "summary": "Android: Address deficiencies in the Camera implementation", "color": { "key": "color_1" }, "done": false }, "priority": { "name": "Medium", "id": "3" }, "labels": [ "module_media", "parity", "qe-testadded", "tbs-1.9.0" ], "versions": [ { "id": "11244", "name": "Release 1.7.0", "archived": true, "released": true, "releaseDate": "2011-06-13" } ], "issuelinks": [], "assignee": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2014-05-28T16:07:34.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": "Currently only a log warning that it's not supported.

{html}\r\n\r\nThe code sample below demonstrates the feature required. Works fine on iphone.\r\n{code:title=\"app.js\"}\r\n\r\n// this sets the background color of the master UIView (when there are no windows/tab groups on it)\r\nTitanium.UI.setBackgroundColor('#000');\r\n\r\nvar win1 = Titanium.UI.createWindow({ \r\n\r\n backgroundColor:'#fff'\r\n});\r\n\r\nvar image_view = Ti.UI.createImageView({\r\n\t\timage: 'appcelerator.png',\r\n\t\theight: 400,\r\n\t\twidth: 320\r\n\t});\r\n\r\n var button2 = Ti.UI.createButton({\r\n \ttop:90,\r\n \ttitle:'save to gallery',\r\n \theight:40\r\n \t\r\n });\t\r\n \r\n win1.add(button2);\r\n\tbutton2.addEventListener('click', function(e){\t\r\n\t\twin1.add(image_view);\r\n\t\tvar img = image_view.toBlob();\r\n\t\tTitanium.Media.saveToPhotoGallery(img,{\r\n\t\t\t\"success\": function(e){\r\n\t\t\t\talert('Saved to your camera roll.');\t\r\n\t\t\t},\r\n\t\t\t\"error\": function(e){\r\n\t\t\t\talert(e.error);\r\n\t\t\t}\r\n\t\t});\t\t\t\r\n\t});\r\n\t\r\nwin1.open();\r\n\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "Android: Add support for saveToPhotoGallery (Titanium.Media.saveToPhotoGallery)", "creator": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Ti SDK 1.7.0 and Android 2.2", "comment": { "comments": [ { "id": "158817", "author": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "h3.Associated helpdesk ticket:\r\n http://support-admin.appcelerator.com/display/APP-612766\r\n\r\nThe image is saved on the systems' gallery and not on the filesystem of the app.", "updateAuthor": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-07-06T14:58:42.000+0000", "updated": "2011-07-11T10:52:23.000+0000" }, { "id": "227296", "author": { "name": "spyromus", "key": "spyromus", "displayName": "Aleksey Gureiev", "active": true, "timeZone": "Europe/Helsinki" }, "body": "I will be backporting the fix that's on the 3_0_X branch for 2_1_X in some capacity. Anyone's interested in push request for this one?", "updateAuthor": { "name": "spyromus", "key": "spyromus", "displayName": "Aleksey Gureiev", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2012-11-14T12:30:19.000+0000", "updated": "2012-11-14T12:32:40.000+0000" }, { "id": "227444", "author": { "name": "spyromus", "key": "spyromus", "displayName": "Aleksey Gureiev", "active": true, "timeZone": "Europe/Helsinki" }, "body": "Here you go: https://github.com/appcelerator/titanium_mobile/pull/3427", "updateAuthor": { "name": "spyromus", "key": "spyromus", "displayName": "Aleksey Gureiev", "active": true, "timeZone": "Europe/Helsinki" }, "created": "2012-11-15T10:18:30.000+0000", "updated": "2012-11-15T10:18:30.000+0000" }, { "id": "270957", "author": { "name": "ygbr", "key": "ygbr", "displayName": "Ygor Lemos", "active": true, "timeZone": "America/Sao_Paulo" }, "body": "This is still happening on Ti SDK 3.1.2.GA\r\n\r\nTested on several devices (Android 4.0, 4.1, 4.2 and 4.3)\r\n\r\nPhoneGap solved this as per: http://simonmacdonald.blogspot.ca/2012/07/change-to-camera-code-in-phonegap-190.html\r\n\r\nI think this shouldn't be marked as trivial.", "updateAuthor": { "name": "ygbr", "key": "ygbr", "displayName": "Ygor Lemos", "active": true, "timeZone": "America/Sao_Paulo" }, "created": "2013-09-12T21:46:15.000+0000", "updated": "2013-09-12T21:46:15.000+0000" }, { "id": "273119", "author": { "name": "ygbr", "key": "ygbr", "displayName": "Ygor Lemos", "active": true, "timeZone": "America/Sao_Paulo" }, "body": "Any news on this one? Fix Version?", "updateAuthor": { "name": "ygbr", "key": "ygbr", "displayName": "Ygor Lemos", "active": true, "timeZone": "America/Sao_Paulo" }, "created": "2013-09-27T02:50:23.000+0000", "updated": "2013-09-27T02:50:23.000+0000" }, { "id": "300738", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Test Code\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');\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 \toptions.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-04-12T02:15:54.000+0000", "updated": "2014-04-15T17:54:13.000+0000" }, { "id": "300912", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Pull pending\nhttps://github.com/appcelerator/titanium_mobile/pull/5597", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-04-14T22:56:04.000+0000", "updated": "2014-04-14T22:56:04.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }