[gradle] Generate method to create drawable or font resource accessors by a file path. #4909
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now we can get resource accessors by the path.
The new API doesn't work with qualifiers and environment. It associates a concrete file with a new resource instance.
If there are two icons:
drawable-night/my_icon.xml
anddrawable-light/my_icon.xml
, users are supposed to select a right icon by their own.It doesn't work for strings resources. There is no a such thing as a full qualified key for the string in a text representation. (as path for other resource types) We need to combine an xml file path + key inside. It is not what we want.
I understand that someone would like to have something like a runtime search in their string resources based on a string key and a current environment but it is a huge performance problem. That's why we converted XML files to the internal format and use generated classes instead. To iterate by files in the runtime is not possible.
Note: there is a way to generate a special map:
key -> value
and use for the search but it requires more resources to maintain it then brings a profit.So, for the case it's possible to save strings to the regular txt file and read it as string on app's side.
Fixes #4880
Release Notes
Features - Resources