[ZP-6167] Support Android Scoped Storage #7
Merged
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.
Android 10 introduced a new permissioning model called Scoped Storage for accessing files. Apps targeting Android 10 (API 29) can keep legacy permissioning until targeting Android 11 (API 30).
This doesn't affect files selected using the OS's default image/video/file pickers like Zenput's video and document fields. The gallery picker supported by this plugin, however, does need to adhere to the guidelines of Scoped Storage.
There's a lot of documentation out there about what changes need to be made. The short of it is to access files by their content URIs rather than absolute file paths. (Still, file paths may continue to work in some cases.) In the context of this plugin, that meant:
ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, <file ID>)instead ofMediaStore.Images.Media.DATABitmapFactory.decodeFileDescriptor()andgetApplicationContext().getContentResolver().openFileDescriptor(<uri>)instead of justBitmapFactory.decodeFile(<absolute path>)getContentResolver().query()and mime type withgetContentResolver().getType(<uri>)instead of instantiating aFileand guessing based on extension.This was one of the blockers for targeting the Android 30 API level (required by Google in November), so this should relieve some headaches in the future when we make that change in Zenput.
This also adds NPM scripts for more easily publishing (draft) releases to NPM. (No CI automation yet!)
Resources on Android's Scoped Storage::