mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-18 19:22:51 +08:00
fix: return content uris when possible when selecting from gallery (#902)
This commit is contained in:
parent
a672c31efb
commit
2eaa9a3972
@ -728,20 +728,13 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
||||
}
|
||||
}
|
||||
|
||||
String fileLocation = FileHelper.getRealPath(uri, this.cordova);
|
||||
LOG.d(LOG_TAG, "File location is: " + fileLocation);
|
||||
|
||||
String uriString = uri.toString();
|
||||
String finalLocation = fileLocation != null ? fileLocation : uriString;
|
||||
String mimeTypeOfGalleryFile = FileHelper.getMimeType(uriString, this.cordova);
|
||||
|
||||
if (finalLocation == null) {
|
||||
this.failPicture("Error retrieving result.");
|
||||
} else {
|
||||
// If you ask for video or the selected file cannot be processed
|
||||
// there will be no attempt to resize any returned data.
|
||||
if (this.mediaType == VIDEO || !isImageMimeTypeProcessable(mimeTypeOfGalleryFile)) {
|
||||
this.callbackContext.success(finalLocation);
|
||||
this.callbackContext.success(uriString);
|
||||
} else {
|
||||
|
||||
// This is a special case to just return the path as no scaling,
|
||||
@ -750,7 +743,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
||||
destType == FILE_URI && !this.correctOrientation &&
|
||||
getMimetypeForEncodingType().equalsIgnoreCase(mimeTypeOfGalleryFile))
|
||||
{
|
||||
this.callbackContext.success(finalLocation);
|
||||
this.callbackContext.success(uriString);
|
||||
} else {
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
@ -787,7 +780,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
||||
this.failPicture("Error retrieving image: "+e.getLocalizedMessage());
|
||||
}
|
||||
} else {
|
||||
this.callbackContext.success(finalLocation);
|
||||
this.callbackContext.success(uriString);
|
||||
}
|
||||
}
|
||||
if (bitmap != null) {
|
||||
@ -799,8 +792,6 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* JPEG, PNG and HEIC mime types (images) can be scaled, decreased in quantity, corrected by orientation.
|
||||
* But f.e. an image/gif cannot be scaled, but is can be selected through the PHOTOLIBRARY.
|
||||
|
Loading…
Reference in New Issue
Block a user