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

Support Android resources similarly to assets #2299

Closed
wants to merge 1 commit into from

Conversation

lerela
Copy link
Contributor

@lerela lerela commented Aug 14, 2020

Fixes #2298

This PR allows adding a resource to the Android resources folder exactly as an asset. Difference with assets is that resources can subsequently be instantiated as Drawables:

Drawable = jnius.autoclass("{}.R$drawable".format(__pkg_name__)) # __pkg_name__ is tld.org.app
custom_icon = getattr(Drawable, "custom_icon")

This is especially useful to pick a notification icon that respect the new Android requirements (PNG with white shape on transparent background) instead of using the app icon, which gets rendered as a white square on many recent devices. I could not find an easy way to do so with an asset.

@lerela lerela force-pushed the support_resources branch from bcce4ba to 62452bb Compare August 14, 2020 21:13
@lerela lerela force-pushed the support_resources branch from 62452bb to 7e2eae1 Compare August 14, 2020 21:15
@lerela lerela changed the base branch from master to develop August 14, 2020 21:16
for res in args.resources:
res_src, res_dest = res.split(":")
if isfile(realpath(res_src)):
ensure_dir(dirname(join(res_dir, res_dest)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is obviously redundant with the assets copying logic just above, and could be factorized if needed

@robertpfeiffer
Copy link
Contributor

I think you forgot to expose this functionality in toolchain.py.

@misl6
Copy link
Member

misl6 commented Nov 5, 2022

Superseded by #2684

@misl6 misl6 closed this Nov 5, 2022
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.

Add support for custom resources
3 participants