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 ability to override resources in application #1875

Open
Pairman opened this issue Jun 11, 2024 · 1 comment
Open

Add ability to override resources in application #1875

Pairman opened this issue Jun 11, 2024 · 1 comment
Labels
enhancement New features, or improvements to existing features. not quite right The idea or PR has been reviewed, but more work is needed.

Comments

@Pairman
Copy link
Contributor

Pairman commented Jun 11, 2024

What is the problem or limitation you are having?

Is there any way to add or override resource files?

This is extremely useful when managing resources. For example, I'd like my ic_launcher_background be defined in an xml, to support gradient colors.

Describe the solution you'd like

Either under the android specific section in pyproject.toml, or by modifying briefcase.toml.

For example, a project can store the overrides under a directory, with the exact same hierarchy.

And in pyproject.toml, user specifies this dir to override the resiurces under [tool.briefcase.app.xdcheckin.android].

The packaging process will first apply the common res dir in the project's src/<name>/app/res, then apply the overrides directly to the generated template's res dir.

Describe alternatives you've considered

Modifying res in the result .apk can also work, but it's not convenient and universal for every briefcase projects.

Additional context

Thanks.

@Pairman Pairman added the enhancement New features, or improvements to existing features. label Jun 11, 2024
@freakboy3742 freakboy3742 transferred this issue from beeware/briefcase-android-gradle-template Jun 11, 2024
@freakboy3742 freakboy3742 changed the title Resources override. Add ability to override resources in application Jun 11, 2024
@freakboy3742 freakboy3742 added the not quite right The idea or PR has been reviewed, but more work is needed. label Jun 11, 2024
@freakboy3742
Copy link
Member

Thanks for the suggestion. There's definitely an interesting idea contained in this suggestion - the catch is how we can implement it in a generic way that makes sense.

Broadly speaking, "here's a collection of files I want you to copy into the final project" makes sense as a use case. The question is the exact format for that file specification.

Your suggestion is specific to Android resources - which will definitely be a good use of this feature, but there are other files you might want to add to an Android project, and other platforms may have use for this feature.

We could possibly treat this as an analog of cleanup_paths - that is, require specifying paths relative to the root of the template folder. This could work, but it would require very deep, empty directory structures to inject a file into the resources folder.

The best idea I can think of right now it to treat this as specification of roots: so a configuration like:

additional_files."app/src/main/res" = [
   "foobar/resources/**"
]
additional_files."app/src/main/java/com/example" = [
   "whiz/bang/*.java",
   "whiz/bang/*.txt",
]

would copy all the files in the foobar/resources folder into the res folder for the project, and all the java and txt files in wiz/bang directory into the com.example code namespace.

There's some details to finesse about exactly how you'd copy in a full directory tree; but hopefully this gives the start of an idea that someone can turn into an implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features. not quite right The idea or PR has been reviewed, but more work is needed.
Projects
None yet
Development

No branches or pull requests

2 participants