mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 23:42:53 +08:00
Fixed the 0-byte files in gallery. Also fixed exif rewriter for saveToPhotoAlbum:false JPG files. Thanks for your help Simon!
This commit is contained in:
parent
ab3347d25d
commit
b22c0e5b6d
@ -333,12 +333,27 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
||||
|
||||
// If sending filename back
|
||||
else if (destType == FILE_URI) {
|
||||
if (!this.saveToPhotoAlbum) {
|
||||
File tempFile = new File(this.imageUri.toString());
|
||||
Uri jailURI = Uri.fromFile(new File("/data/data/" + this.cordova.getActivity().getPackageName() + "/", tempFile.getName()));
|
||||
|
||||
// Clean up initial URI before writing out safe URI.
|
||||
// First try File-based approach to delete. Then use the media delete method. Neither seem to work on ICS right now...
|
||||
boolean didWeDeleteIt = tempFile.delete();
|
||||
if (!didWeDeleteIt) {
|
||||
int result = this.cordova.getActivity().getContentResolver().delete(
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
MediaStore.Images.Media.DATA + " = ?",
|
||||
new String[] { this.imageUri.toString() }
|
||||
);
|
||||
}
|
||||
this.imageUri = jailURI;
|
||||
} else {
|
||||
// Create entry in media store for image
|
||||
// (Don't use insertImage() because it uses default compression setting of 50 - no way to change it)
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
|
||||
|
||||
|
||||
try {
|
||||
this.imageUri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
@ -351,21 +366,6 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!this.saveToPhotoAlbum) {
|
||||
File tempFile = new File(this.imageUri.toString());
|
||||
Uri jailURI = Uri.fromFile(new File("/data/data/" + this.cordova.getActivity().getPackageName() + "/", tempFile.getName() + "." + (this.encodingType == JPEG ? "jpg" : "png" )));
|
||||
|
||||
// Clean up initial URI before writing out safe URI.
|
||||
// First try File-based approach to delete. Then use the media delete method. Neither seem to work on ICS right now...
|
||||
boolean didWeDeleteIt = tempFile.delete();
|
||||
if (!didWeDeleteIt) {
|
||||
int result = this.cordova.getActivity().getContentResolver().delete(
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
MediaStore.Images.Media.DATA + " = ?",
|
||||
new String[] { this.imageUri.toString() }
|
||||
);
|
||||
}
|
||||
this.imageUri = jailURI;
|
||||
}
|
||||
|
||||
// If all this is true we shouldn't compress the image.
|
||||
@ -401,7 +401,7 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
||||
if (this.saveToPhotoAlbum) {
|
||||
exifPath = FileUtils.getRealPathFromURI(this.imageUri, this.cordova);
|
||||
} else {
|
||||
exifPath = this.imageUri.toString();
|
||||
exifPath = this.imageUri.getPath();
|
||||
}
|
||||
exif.createOutFile(exifPath);
|
||||
exif.writeExifData();
|
||||
|
Loading…
Reference in New Issue
Block a user