mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-19 03:42:52 +08:00
Android: return DATA_URL for ALLMEDIA if it's an image (#382)
This commit is contained in:
parent
ce77aab010
commit
60e779559e
@ -691,15 +691,15 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
String fileLocation = FileHelper.getRealPath(uri, this.cordova);
|
String fileLocation = FileHelper.getRealPath(uri, this.cordova);
|
||||||
LOG.d(LOG_TAG, "File locaton is: " + fileLocation);
|
LOG.d(LOG_TAG, "File locaton is: " + fileLocation);
|
||||||
|
|
||||||
// If you ask for video or all media type you will automatically get back a file URI
|
String uriString = uri.toString();
|
||||||
// and there will be no attempt to resize any returned data
|
String mimeType = FileHelper.getMimeType(uriString, this.cordova);
|
||||||
if (this.mediaType != PICTURE) {
|
|
||||||
|
// If you ask for video or the selected file doesn't have JPEG or PNG mime type
|
||||||
|
// there will be no attempt to resize any returned data
|
||||||
|
if (this.mediaType == VIDEO || !(JPEG_MIME_TYPE.equalsIgnoreCase(mimeType) || PNG_MIME_TYPE.equalsIgnoreCase(mimeType))) {
|
||||||
this.callbackContext.success(fileLocation);
|
this.callbackContext.success(fileLocation);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String uriString = uri.toString();
|
|
||||||
// Get the path to the image. Makes loading so much easier.
|
|
||||||
String mimeType = FileHelper.getMimeType(uriString, this.cordova);
|
|
||||||
|
|
||||||
// This is a special case to just return the path as no scaling,
|
// This is a special case to just return the path as no scaling,
|
||||||
// rotating, nor compressing needs to be done
|
// rotating, nor compressing needs to be done
|
||||||
@ -709,12 +709,6 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
{
|
{
|
||||||
this.callbackContext.success(uriString);
|
this.callbackContext.success(uriString);
|
||||||
} else {
|
} else {
|
||||||
// If we don't have a valid image so quit.
|
|
||||||
if (!(JPEG_MIME_TYPE.equalsIgnoreCase(mimeType) || PNG_MIME_TYPE.equalsIgnoreCase(mimeType))) {
|
|
||||||
LOG.d(LOG_TAG, "I either have a null image path or bitmap");
|
|
||||||
this.failPicture("Unable to retrieve path to picture!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bitmap bitmap = null;
|
Bitmap bitmap = null;
|
||||||
try {
|
try {
|
||||||
bitmap = getScaledAndRotatedBitmap(uriString);
|
bitmap = getScaledAndRotatedBitmap(uriString);
|
||||||
|
Loading…
Reference in New Issue
Block a user