Skip to content

Commit

Permalink
Support for resource value files
Browse files Browse the repository at this point in the history
Add the --res-values options to specify resource value files to copy to
`src/main/res/values` in the dist directory. This allows customizing
`styles.xml` and `colors.xml`, for example.
  • Loading branch information
dbnicholson committed Aug 14, 2023
1 parent 304bf5c commit 8078f3c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions doc/source/buildoptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ options (this list may not be exhaustive):
- ``--enable-crashlytics-native-symbol-upload``: Enable processing and uploading
of native symbols to Firebase servers. This flag must be enabled to see
properly-symbolicated native stack traces in the Crashlytics dashboard.
- ``--res-values``: Resource value files to include in the app such as
``colors.xml`` and ``styles.xml``. This option can be specified multiple
times.


webview
Expand Down Expand Up @@ -190,6 +193,9 @@ ready.
- ``--enable-crashlytics-native-symbol-upload``: Enable processing and uploading
of native symbols to Firebase servers. This flag must be enabled to see
properly-symbolicated native stack traces in the Crashlytics dashboard.
- ``--res-values``: Resource value files to include in the app such as
``colors.xml`` and ``styles.xml``. This option can be specified multiple
times.


service_library
Expand Down Expand Up @@ -220,6 +226,9 @@ systems and frameworks.
project directory.
- ``--add-gradle-plugin``: Add a plugin for gradle. The format of the option
is ``<plugin-id>:<classpath>``. The option can be specified multiple times.
- ``--res-values``: Resource value files to include in the app such as
``colors.xml`` and ``styles.xml``. This option can be specified multiple
times.


Requirements blacklist (APK size optimization)
Expand Down
9 changes: 9 additions & 0 deletions pythonforandroid/bootstraps/common/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,13 @@ def make_package(args):
xmlpath = join(args.private, xmlpath)
shutil.copy(xmlpath, res_xml_dir)

# Copy res_values files to src/main/res/values
res_values_dir = join(res_dir, 'values')
if args.res_values:
ensure_dir(res_values_dir)
for xmlpath in args.res_values:
shutil.copy(xmlpath, res_values_dir)

# Render out android manifest:
manifest_path = "src/main/AndroidManifest.xml"
render_args = {
Expand Down Expand Up @@ -832,6 +839,8 @@ def parse_args_and_make_package(args=None):
'directory'))
ap.add_argument('--res_xml', dest='res_xmls', action='append', default=[],
help='Add files to res/xml directory (for example device-filters)', nargs='+')
ap.add_argument('--res-values', dest='res_values', action='append', default=[],
help='Add files to res/values directory (for example styles.xml)')
ap.add_argument('--with-billing', dest='billing_pubkey',
help='If set, the billing service will be added (not implemented)')
ap.add_argument('--add-source', dest='extra_source_dirs', action='append',
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ def _fix_args(args):
fix_args = ('--dir', '--private', '--add-jar', '--add-source',
'--whitelist', '--blacklist', '--presplash', '--icon',
'--icon-bg', '--icon-fg', '--fileprovider-paths',
'--google-services-json')
'--google-services-json', '--res-values')
unknown_args = args.unknown_args

for asset in args.assets:
Expand Down

0 comments on commit 8078f3c

Please sign in to comment.