Handle file paths and URIs for internal and external storage across Android versions #404
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses an issue with the
getOrientationMatrix
method in theImageResizer
class, which did not handle file paths and URIs correctly for both internal app storage and external storage across different Android versions, especially after the introduction of Scoped Storage changes in Android 10 (API level 29).The existing implementation had the following limitations:
MediaStore
API to retrieve content URIs for external storage file paths/URIs on Android 10 and above, as required by the Scoped Storage changes.This PR updates the
getOrientationMatrix
method to handle the following scenarios:For internal app storage file paths (starting with
/data/
), it directly creates aFile
object from the file path and uses it to create theExifInterface
instance.For external storage file paths/URIs:
MediaStore
API to retrieve the content URI for the file path/URI and creates theExifInterface
instance from the content URI, adhering to the Scoped Storage changes.File
object and then creates theExifInterface
instance from the file path.The changes ensure that the
getOrientationMatrix
method works correctly for various file path/URI scenarios, taking into account the Scoped Storage changes introduced in Android 10.