mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
Removing images and saving images to jail if SaveToPhotoAlbum is set to true
This commit is contained in:
parent
9f66ccb5f3
commit
f6d4402fdc
@ -338,6 +338,7 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
||||
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) {
|
||||
@ -350,6 +351,22 @@ 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()));
|
||||
|
||||
// Clean up initial URI before writing out safe URI
|
||||
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() }
|
||||
);
|
||||
LOG.d("TAG!","result is " + result);
|
||||
}
|
||||
this.imageUri = jailURI;
|
||||
}
|
||||
|
||||
// If all this is true we shouldn't compress the image.
|
||||
if (this.targetHeight == -1 && this.targetWidth == -1 && this.mQuality == 100) {
|
||||
@ -378,10 +395,18 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
||||
os.close();
|
||||
|
||||
// Restore exif data to file
|
||||
|
||||
if (this.encodingType == JPEG) {
|
||||
exif.createOutFile(FileUtils.getRealPathFromURI(this.imageUri, this.cordova));
|
||||
String exifPath;
|
||||
if (this.saveToPhotoAlbum) {
|
||||
exifPath = FileUtils.getRealPathFromURI(this.imageUri, this.cordova);
|
||||
} else {
|
||||
exifPath = this.imageUri.toString();
|
||||
}
|
||||
exif.createOutFile(exifPath);
|
||||
exif.writeExifData();
|
||||
}
|
||||
|
||||
|
||||
// Scan for the gallery to update pic refs in gallery
|
||||
this.scanForGallery();
|
||||
|
Loading…
Reference in New Issue
Block a user