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

Add resources #1513

Merged
merged 5 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions buildozer/default.spec
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ fullscreen = 0
# 2) android.add_assets = source_asset_path:destination_asset_relative_path
#android.add_assets =

# (list) Put these files or directories in the apk res directory.
# The option may be used in three ways, the value may contain one or zero ':'
# Some examples:
# 1) A file to add to resources, legal resource names contain ['a-z','0-9','_']
# android.add_resources = my_icons/all-inclusive.png:drawable/all_inclusive.png
# 2) A directory, here 'legal_icons' must contain resources of one kind
# android.add_resources = legal_icons:drawable
# 3) A directory, here 'legal_resources' must contain one or more directories,
# each of a resource kind: drawable, xml, etc...
# android.add_resources = legal_resources
#android.add_resources =

# (list) Gradle dependencies to add
#android.gradle_dependencies =

Expand Down
11 changes: 11 additions & 0 deletions buildozer/targets/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,17 @@ def execute_build_package(self, build_cmd):
asset_dest = asset
cmd.append(realpath(expanduser(asset_src)) + ':' + asset_dest)

# support for res folder
resources = self.buildozer.config.getlist('app', 'android.add_resources', [])
for resource in resources:
cmd.append('--add-resource')
if ':' in resource:
resource_src, resource_dest = resource.split(":")
else:
resource_src = resource
resource_dest = ""
cmd.append(realpath(expanduser(resource_src)) + ':' + resource_dest)
Comment on lines +938 to +943
Copy link
Member

Choose a reason for hiding this comment

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

Ouch, duplicating such logic on buildozer may lead to something unexpected (E.g: I needed to recall how the no : syntax worked on python-for-android side.)

This is bad, but I'm NOT blaming you, since we're expanding paths on buildozer side everywhere. ( Bad, and should be moved on python-for-android ? )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, absolutely, but as you point out this is consistent with for example https://github.com/kivy/buildozer/blob/master/buildozer/targets/android.py#L931L938

I choose to copy what is shown to work, it is the low risk implementation. And yes the whole interface needs a rewrite, and an automatic appclean, and the .spec reorganized into common and uncommon, and....


# support for uses-lib
uses_library = self.buildozer.config.getlist(
'app', 'android.uses_library', '')
Expand Down