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: File is not a picture (on Android 10 or above) #27

Merged
merged 2 commits into from
Jan 12, 2021
Merged

Conversation

jmcrox
Copy link
Contributor

@jmcrox jmcrox commented Jan 11, 2021

  • Fix getCaptureImageOutputUri(Context): Uri to return same file in each call on Android 10 or above.

close #21

Bug

Cause:

On Android 10 or above there is a problem when ask Uri to dump camera image. The Uri passed to the camera intent via MediaStore.EXTRA_OUTPUT is different to the Uri when we are going to read the image. This is because the method was creating a temporary file in each call.

Reproduce

Run project test module on any Android 10 or above and select camere to obtain the image.

How the bug was solved:

The bug was solved changing the Uri returned when on Android 10 or above. Now, the Uri returned is build like Android 9 or lower. That is, the returned Uri is new File(getImage.getPath(), "pickImageResult.jpeg")

* Fix getCaptureImageOutputUri(Context): Uri to return same file in each call on Android 10 or above.
@Canato Canato self-requested a review January 11, 2021 10:51
@Canato Canato added the bug label Jan 11, 2021
@Canato Canato added this to the v_2.0.0 milestone Jan 11, 2021
@Canato
Copy link
Member

Canato commented Jan 11, 2021

@jmcrox Thanks for the fix!!!

Sadly I could not reproduce the bug to test the fix.
Device: Pixel 3, OS 11

  • Run test module
  • Click Start Activity
  • Choose from images and crop
  • Result: Image cropped, not issues.

Maybe someone else could take a look?
@VEIKKO99 @CanHub/imagecropcollaborators

Or maybe you can add a bug or specific emulator I can test =D

@jmcrox
Copy link
Contributor Author

jmcrox commented Jan 11, 2021

Sorry, I forgot to mention that the problem is when you use the camera option because getCaptureImageOutputUri(Context): Uri is called twice (before and after camera capture) with different result. I have edited my first post.

@VEIKKO99
Copy link

VEIKKO99 commented Jan 11, 2021

Maybe someone else could take a look?
@VEIKKO99 @CanHub/imagecropcollaborators

Made a quick test and this fix seems to correct the bug. Thanks @jmcrox

@Canato Please make a release with this fix included. I think there are lot of devs waiting for this. Thanks!

@Canato
Copy link
Member

Canato commented Jan 11, 2021

Maybe someone else could take a look?
@VEIKKO99 @CanHub/imagecropcollaborators

Made a quick test and this fix seems to correct the bug. Thanks @jmcrox

@Canato Please make a release with this fix included. I think there are lot of devs waiting for this. Thanks!

\o/

@jmcrox please add the fix to the changelog and we can merge for the release

@jmcrox
Copy link
Contributor Author

jmcrox commented Jan 12, 2021

Ok @Canato. CHANGELOG.md updated.

Thanks.

@Canato Canato merged commit f40a33f into CanHub:main Jan 12, 2021
@Canato Canato linked an issue Jan 14, 2021 that may be closed by this pull request
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.

[BUG] - No crop option after camera Failed to load sampled bitmap / File is not a picture error
3 participants