Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13159] Android: Images are blank/ have an empty entry when saved to the photo gallery

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-04-18T20:35:19.000+0000
Affected Version/sRelease 3.0.0
Fix Version/s2013 Sprint 08 API, 2013 Sprint 08, Release 3.1.1, Release 3.2.0
ComponentsAndroid
Labelsmodule_imageview, qe-closed-3.1.0, qe-testadded, regression
ReporterAllen Yeung
AssigneePing Wang
Created2013-03-22T06:05:34.000+0000
Updated2013-10-03T10:29:23.000+0000

Description

Run the test case mentioned at https://gist.github.com/4527649 After taking the picture, and saving it, hit 'back' to close the app. Then navigate to the gallery app, and you will find the image you just took to be blank (it should be under ). NOTE if you push the 'home' button instead of 'back' it will save correctly. This is a regression and was working in 2.1.X

Comments

  1. Ping Wang 2013-04-10

    This regression is caused by [PR#2475](https://github.com/appcelerator/titanium_mobile/pull/2475).
  2. Ping Wang 2013-04-11

    This is a behavior change due to PR#2475. Before that commit, we did not delete the temporary image file so it always had a copy of the image in the gallery no matter saveToPhotoGallery was set to true or false. After that commit, we delete all the temporary files when the app exits so the image saved in the gallery is removed if saveToPhotoGallery is false. But since the gallery can not refresh automatically, we can still see a blank image in the gallery. [PR#4148](https://github.com/appcelerator/titanium_mobile/pull/4148) should resolve the blank image issue.
  3. Ping Wang 2013-04-11

    PR: https://github.com/appcelerator/titanium_mobile/pull/4148 For FR: 1. Please run the test case below. 2. Take a picture and click the "Save" button. 3. Click 'back' to close the app. 4. Check the photo gallery. The image you just took should *NOT* be there. 5. Change the test case line 48 to "saveToPhotoGallery: true". Then repeat 2-3. 6. Check the photo gallery. The image you just took should be there. Test case:
       var win = Titanium.UI.createWindow();
       var imageView = Ti.UI.createImageView({height: Ti.UI.FILL, width: Ti.UI.Fill});
       win.add(imageView);
       	Titanium.Media.showCamera({
        
       		success:function(event)
       		{
       			Ti.API.info('#### Camera Success');
       			var cropRect = event.cropRect;
       			var image = event.media;
       			Ti.API.info(image.length);
       			var filename = Titanium.Filesystem.tempDirectory + "/"+ 'camera_photo' + new Date().getTime() + ".png";
       			Ti.API.info(filename);
       			var f = Titanium.Filesystem.getFile(filename);
       			Ti.API.info(f.nativePath);
       			if (f.exists()) {
       				Ti.API.info('The file exist , trying to delete it before using it :' + f.deleteFile());
       				f = Titanium.Filesystem.getFile(filename);
       			}
       			f.write(image);
       			alert('Camera Success! The file size is '+f.size+' bytes.\n Now trying to assign it to an image on the screen (this may fail for hi res images)')
       			imageView.image = f.nativePath;
       		},
       		cancel:function()
       		
       		{
       			Ti.API.info('#### Camera Cancel');
       		},
       		error:function(error)
       		{
       			// create alert
       			Ti.API.info('#### Camera Error');
       			var a = Titanium.UI.createAlertDialog({title:'Camera'});
        
       			// set message
       			if (error.code == Titanium.Media.NO_CAMERA)
       			{
       				a.setMessage('Device does not have video recording capabilities');
       			}
       			else
       			{
       				a.setMessage('Unexpected error: ' + error.code);
       			}
        
       			// show alert
       			a.show();
       		},
       		saveToPhotoGallery: false
       	});
       win.open();
       
  4. Ping Wang 2013-04-22

    3_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/4196
  5. Eric Merriman 2013-05-08

    Verified fixed with: Mac OS 10.8.3 Safari: 6.0.4 Xcode 4.6 CLI: 3.1.0 titanium-code-processor: 1.0.1 Alloy: 1.1.2 Titanium SDK version 3.1.1.v20130508001914 Nexus 4 4.2.1 Images with saveToPhotoGallery: true are appearing in the gallery.

JSON Source