mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-12 18:56:11 +08:00
Merging in use of uri variable between Simon and my changes.
This commit is contained in:
parent
9d1edc4554
commit
f3f2ad9144
@ -333,9 +333,10 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
|||||||
|
|
||||||
// If sending filename back
|
// If sending filename back
|
||||||
else if (destType == FILE_URI) {
|
else if (destType == FILE_URI) {
|
||||||
|
Uri uri;
|
||||||
if (!this.saveToPhotoAlbum) {
|
if (!this.saveToPhotoAlbum) {
|
||||||
File tempFile = new File(this.imageUri.toString());
|
File tempFile = new File(this.imageUri.toString());
|
||||||
Uri jailURI = Uri.fromFile(new File("/data/data/" + this.cordova.getActivity().getPackageName() + "/", tempFile.getName()));
|
uri = Uri.fromFile(new File("/data/data/" + this.cordova.getActivity().getPackageName() + "/", tempFile.getName()));
|
||||||
|
|
||||||
// Clean up initial URI before writing out safe URI.
|
// 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...
|
// First try File-based approach to delete. Then use the media delete method. Neither seem to work on ICS right now...
|
||||||
@ -347,7 +348,6 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
|||||||
new String[] { this.imageUri.toString() }
|
new String[] { this.imageUri.toString() }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.imageUri = jailURI;
|
|
||||||
} else {
|
} else {
|
||||||
// Create entry in media store for image
|
// Create entry in media store for image
|
||||||
// (Don't use insertImage() because it uses default compression setting of 50 - no way to change it)
|
// (Don't use insertImage() because it uses default compression setting of 50 - no way to change it)
|
||||||
@ -355,11 +355,11 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
|||||||
values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
|
values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.imageUri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
LOG.d(LOG_TAG, "Can't write to external media storage.");
|
LOG.d(LOG_TAG, "Can't write to external media storage.");
|
||||||
try {
|
try {
|
||||||
this.imageUri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
|
uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
|
||||||
} catch (UnsupportedOperationException ex) {
|
} catch (UnsupportedOperationException ex) {
|
||||||
LOG.d(LOG_TAG, "Can't write to internal media storage.");
|
LOG.d(LOG_TAG, "Can't write to internal media storage.");
|
||||||
this.failPicture("Error capturing image - no media storage found.");
|
this.failPicture("Error capturing image - no media storage found.");
|
||||||
@ -390,7 +390,7 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
|||||||
bitmap = scaleBitmap(getBitmapFromResult(intent));
|
bitmap = scaleBitmap(getBitmapFromResult(intent));
|
||||||
|
|
||||||
// Add compressed version of captured image to returned media store Uri
|
// Add compressed version of captured image to returned media store Uri
|
||||||
OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(this.imageUri);
|
OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
|
||||||
bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
|
bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
|
||||||
os.close();
|
os.close();
|
||||||
|
|
||||||
@ -399,9 +399,9 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
|||||||
if (this.encodingType == JPEG) {
|
if (this.encodingType == JPEG) {
|
||||||
String exifPath;
|
String exifPath;
|
||||||
if (this.saveToPhotoAlbum) {
|
if (this.saveToPhotoAlbum) {
|
||||||
exifPath = FileUtils.getRealPathFromURI(this.imageUri, this.cordova);
|
exifPath = FileUtils.getRealPathFromURI(uri, this.cordova);
|
||||||
} else {
|
} else {
|
||||||
exifPath = this.imageUri.getPath();
|
exifPath = uri.getPath();
|
||||||
}
|
}
|
||||||
exif.createOutFile(exifPath);
|
exif.createOutFile(exifPath);
|
||||||
exif.writeExifData();
|
exif.writeExifData();
|
||||||
@ -412,7 +412,7 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie
|
|||||||
this.scanForGallery();
|
this.scanForGallery();
|
||||||
|
|
||||||
// Send Uri back to JavaScript for viewing image
|
// Send Uri back to JavaScript for viewing image
|
||||||
this.success(new PluginResult(PluginResult.Status.OK, this.imageUri.toString()), this.callbackId);
|
this.success(new PluginResult(PluginResult.Status.OK, uri.toString()), this.callbackId);
|
||||||
}
|
}
|
||||||
bitmap.recycle();
|
bitmap.recycle();
|
||||||
bitmap = null;
|
bitmap = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user