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

fix(android): return error if file url is null #632

Merged
merged 1 commit into from
Jul 23, 2020

Conversation

jcesarmobile
Copy link
Member

@jcesarmobile jcesarmobile commented Jul 16, 2020

Platforms affected

android

Motivation and Context

When picking files from the gallery, sometimes it can return "null" as the path, but on the success callback.
This PR will call the error callback if the file path is null (might be breaking if people is expecting null result for some reason?)

The PR also unify the logic, since at the moment this code returns a file url

navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
     destinationType: Camera.DestinationType.FILE_URI,
     sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
     targetWidth: 1024,
     correctOrientation: true
});

but this code returns a content url

navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
     destinationType: Camera.DestinationType.FILE_URI,
     sourceType: Camera.PictureSourceType.PHOTOLIBRARY
});

The PR will try to return a file url if available, and if not available, the content url. (and the error if none is available)
So, some cases where the url was null, won't be anymore.

closes #368 as it will return a file url if available

Description

note: use the "Hide whitespace changes" github option for easier review, the code changes are very small

Testing

tested on real android devices with the code provided

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@jcesarmobile
Copy link
Member Author

I will merge on Thursday if nobody has reviewed by then

Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Changes LGTM 👍

@jcesarmobile jcesarmobile merged commit e2ecd7f into apache:master Jul 23, 2020
@jcesarmobile jcesarmobile deleted the return-error-null-url branch July 23, 2020 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android not respecting destType of FILE_URI
2 participants