Skip to content

Get resource files as URI#4576

Merged
terrakok merged 4 commits intomasterfrom
k.tskh/resource-as-uri
Apr 5, 2024
Merged

Get resource files as URI#4576
terrakok merged 4 commits intomasterfrom
k.tskh/resource-as-uri

Conversation

@terrakok
Copy link
Copy Markdown
Member

@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
Copy Markdown
Contributor

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
Copy Markdown
Member 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
@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