Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: return DATA_URL for ALLMEDIA if it's an image #382

Merged
merged 1 commit into from
Dec 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/android/CameraLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -691,15 +691,15 @@ private void processResultFromGallery(int destType, Intent intent) {
String fileLocation = FileHelper.getRealPath(uri, this.cordova);
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
// and there will be no attempt to resize any returned data
if (this.mediaType != PICTURE) {
String uriString = uri.toString();
String mimeType = FileHelper.getMimeType(uriString, this.cordova);

// 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);
}
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,
// rotating, nor compressing needs to be done
Expand All @@ -709,12 +709,6 @@ private void processResultFromGallery(int destType, Intent intent) {
{
this.callbackContext.success(uriString);
} 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;
try {
bitmap = getScaledAndRotatedBitmap(uriString);
Expand Down