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

Provide a prebuilt DocumentsProvider for a MuzeiArtProvider #672

Merged
merged 19 commits into from Jul 5, 2020

Conversation

ianhanniballake
Copy link
Collaborator

A DocumentsProvider is the standard mechanism for making private files (like the images provided by a MuzeiArtProvider) available to users via the default file picker and Files app.

The new MuzeiArtDocumentsProvider provides a prebuilt way of exposing the images from an existing MuzeiArtProvider via a DocumentsProvider. Developers using this API do not need to write any code themselves - instead, they can add the MuzeiArtDocumentsProvider to their manifest and connect it to an existing MuzeiArtProvider by using the appropriate authority (adding a suffix of .documents to the MuzeiArtProvider's authority).

Fixes #670

By defining a `MuzeiDocumentsProvider` in your manifest, you can make the artwork provided by one or more `MuzeiArtProvider` instances available to users via the Files app.

Adds "My Photos" as the sole users of this API in the `main` module.
Generate thumbnails for each image, ensuring that they are rotated correctly.
Make it more clear that the `MuzeiArtDocumentsProvider` is tied to the `MuzeiArtProvider`.
Implement `isChildDocument()` to support `OPEN_DOCUMENT_TREE` Intents.
Reverse the logic of `getDocumentType` so that `authority/id` documents are correctly listed as `image/png` and `authority` documents are considered directories.
Avoid generating dokka docs for methods that should not be overridden.
Ensure that we include the summary in the default projection for the roots so that the app name is shown as the summary when the app name and provider name don't match.
If a `MuzeiArtDocumentsProvider` exists for a given `MuzeiArtProvider`, changes to the `MuzeiArtProvider` should invalidate the `MuzeiArtDocumentsProvider` correctly, ensuring that users always see the most up to date information.
Ensure that `MuzeiArtDocumentsProvider` properly uses the application's icon or label if there isn't one present on the `MuzeiArtProvider`'s `<provider>` element itself.
`resolveContentProvider` does not throw a `NameNotFoundException`, it just returns null. Therefore we can simply remove the try/catch.
Instead of defining a separate variable in the `build.gradle`, use the `galleryArtAuthority` directly, suffixed with `.documents` in AndroidManifest.xml
Turns out that actually using multiple authorities in a `DocumentsProvider` doesn't work on the vast majority of API levels and devices. Update the guidance to make it more clear that subclassing `MuzeiArtDocumentsProvider` and using a single authority for each is the recommended path.
…dule

Follow best practices in using a subclass of `MuzeiArtDocumentsProvider` when building independent modules.
Add the single manifest entry needed to support selecting images via the default file picker / Files app from the Unsplash `MuzeiArtProvider`.
@ianhanniballake ianhanniballake merged commit a6fab27 into muzei:master Jul 5, 2020
@ianhanniballake ianhanniballake deleted the documents_provider branch July 5, 2020 23:10
hossain-khan added a commit to hossain-khan/android-hk-vision-muzei-plugin that referenced this pull request Jul 6, 2020
Updated project based on guidelines provided in the `MuzeiArtDocumentsProvider`
Also targeting API 30 as recommended by the release notes.

Also, refactored provider authority to reduce code duplication. (Used example from Unsplash plugin)

References:
* https://github.com/romannurik/muzei/releases/tag/api3.4.0-alpha3
* muzei/muzei#670
* muzei/muzei#672
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.

Allow exposing provider artwork via a DocumentsProvider
1 participant