-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 for problems with input and output File Uri with "content" schema and Android 10 SAF new requirements. #732
Conversation
Fix for using uCrop with SAF (Storage Access Framework) on Android 10 and newer. Sample app changed for context file testing. Added a "choose file destination" button and some other associated controls.
@warko-san You were the last one to commit a merge of a PR into the sources of this repository. Was this project abandoned by Yalantis folks? Should I wait for this PR to be properly reviewed by Yalantis folks? |
This is an important fix, please review and merge it. Gr8 work @fabio-blanco |
I have created a simple working example with your fix here: https://github.com/codespair/CameraImageUCropTutorial |
Good! |
ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java
Outdated
Show resolved
Hide resolved
ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java
Outdated
Show resolved
Hide resolved
There is an issue on pre-Lollipop devices, that needs some investigation. Currently in the sample app for random image used outdated url
, which leads to
to test this PR, and it led me to the next exception:
I need time to investigate this issue. UPD: seems it's ok, just typo in url. strange case. |
ucrop/src/main/java/com/yalantis/ucrop/task/BitmapCropTask.java
Outdated
Show resolved
Hide resolved
…against null pointer exceptions and minor performance improvements
…at an unsupported URI was used.
…-destination-file # Conflicts: # ucrop/src/main/java/com/yalantis/ucrop/task/BitmapLoadTask.java
@DeMoss15 I also have made the merge with branch 'master-non-native' to bring commits from fix/non_native_ssl_handshake_exception branch in order to easy regression tests and the merge of the PR |
@fabio-blanco of course, your changes will be available in next non-native release (we'll try to rollout it today). but about translation I'm not sure. Because of strange format and not full translation for brazil in the PR. |
Very good!
What is strange about the format? What is missing in the translation? If there is something missing I can fix it. I think you should not avoid to release a translation just because one or other key is missing. It won't break the application. If a key is not translated de default is selected. The more translations/languages the lib suports, more users it will have. |
List of changes:
Important note:
This is a fix for the non-native version since I don't even know if it is possible to deal with those things in native code.
Related and fixed issues:
This fix problems reported on issues #668, #718 and #666.
Explanation of the solution:
Basically I've adapted many of the existing code to rely more on the Uri whenever it is possible rather than using only the file paths.
The most significant changes were made on
BitmapCropTask
andImageHeaderParser
classes but that were made some minor changes onBitmapLoadTask
too.I had to change the way the exif info was been copied from the input file to the output file and because those were some delicate changes I tried to do this in a more conservative way allowing the behavior to change more for the newer Android versions were it was needed more and conserving the behavior where it wasn't necessary to change (e.g. when the output Uri hasn't the "content" schema).
How to test the changes:
In order to more easily be able to test those things I made some changes to the sample application by inserting in it some widgets to allow for easy testing of different types of output uri.
A destination Uri path can be easily selected by using the "Choose destination" controls:
A "Destination File" dialog was provided for Devices with Android versions that don't have the possibility to use a Document Provider file picker for choosing the destination file path:
To test Uri with "file" or "content" is pretty straightforward:
I've made my tests varying content and file schema booth for input Uri and output Uri on those Android api: 16, 19, 22, 28, 29 and 30.
Limitations of the solution:
For Android API lower than Lollipop (21) with a output Uri image with schema "content" it is not possible to preserve the exif info due to
ExifInterface
limitations explained more deeply on this StackOverflow question. The file is successfully croped but without any exif info.Pull request late fixes: