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

Get resource files as URI #4576

Merged
merged 4 commits into from
Apr 5, 2024
Merged

Get resource files as URI #4576

merged 4 commits into from
Apr 5, 2024

Conversation

terrakok
Copy link
Collaborator

@terrakok terrakok commented Apr 4, 2024

Adds a public Res.getUri(path: String): String function.
It lets external libraries a way to read resource files by a platform dependent Uri.
E.g.: video players, image loaders or embedded web browsers.

val uri = Res.getUri("files/my_video.mp4")

fixes #4360

@terrakok terrakok requested a review from pjBooms April 4, 2024 17:03
* @param path The path of the file in the compose resource's directory.
* @return The URI string of the file.
*/
public fun getUri(path: String): String = getResourceUri("" + path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not we add test that calls getUri (we may check that resulting URI contains original path)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original path depends on a platform. so we need to call the same logic in the test, it means the test will do nothing

@terrakok terrakok merged commit d87aa7f into master Apr 5, 2024
3 of 12 checks passed
@terrakok terrakok deleted the k.tskh/resource-as-uri branch April 5, 2024 13:12
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.

Expose an API for converting DrawableResource -> ByteArray
2 participants