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

breaking(android): stop using CordovaUri helper class #617

Merged
merged 2 commits into from Jul 14, 2020

Conversation

jcesarmobile
Copy link
Member

Platforms affected

android

Motivation and Context

At the moment the plugin tries to guess (in a dirty way) the image path from the content url, but that's not really necessary since we know the path beforehand, and doesn't work at the moment since the path was changed in a previous PR causing #597

Description

probably breaking change since CordovaUri class says it's for Android 4.4.4 and lower support, but since cordova-android 9 won't support versions older than 5.1, I think we can remove the class and we also need to update the plugin to use Android X, which will require cordova-android 9.

What the PR does is to store the file path in a variable and use that variable to send the camera result instead of trying to guess the image path from the returned result from the camera intent, which was a dirty way of getting it (according to the method description) and which doesn't work since this was merged.

For that, it removes CordovaUri.java class and it's usages.
Saves image paths in a variable to return.
Changes the file_provider to use cache_files as the mentioned commit stores the images there.
Removes code used for Android 4.4 and older.

fixes #597

Testing

Tested on Android 5 and Android 9 devices with this code

navigator.camera.getPicture(onSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI });
    function onSuccess(imageURI) {
        alert(imageURI);
        document.getElementById("photoResult").src = imageURI;
    }
    function onFail(message) {
        alert('Failed because: ' + message);
    }

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

@timbru31 timbru31 added this to the 5.0.0 milestone Jun 26, 2020
src/android/CameraLauncher.java Outdated Show resolved Hide resolved
src/android/CameraLauncher.java Outdated Show resolved Hide resolved
@erisu
Copy link
Member

erisu commented Jul 14, 2020

Other then the comments, I think the rest is OK 👌

@erisu
Copy link
Member

erisu commented Jul 14, 2020

You might also be able to rebase with master to get the additional tests to pass.

@jcesarmobile jcesarmobile merged commit fd155d9 into apache:master Jul 14, 2020
@jcesarmobile jcesarmobile deleted the fix-IllegalArgumentException branch July 14, 2020 14:26
CarlsCorrea added a commit to OutSystems/cordova-plugin-camera that referenced this pull request Aug 20, 2020
IT-MikeS pushed a commit to OutSystems/cordova-plugin-camera that referenced this pull request Mar 18, 2024
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: Camera fails with an exception
3 participants