Skip to content

Commit a6b461a

Browse files
authored
Merge pull request #19 from endlessm/res-values
Support for resource value files
2 parents 304bf5c + d77af2e commit a6b461a

7 files changed

Lines changed: 29 additions & 13 deletions

File tree

doc/source/buildoptions.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ options (this list may not be exhaustive):
110110
- ``--enable-crashlytics-native-symbol-upload``: Enable processing and uploading
111111
of native symbols to Firebase servers. This flag must be enabled to see
112112
properly-symbolicated native stack traces in the Crashlytics dashboard.
113+
- ``--res-values``: Resource value files to include in the app such as
114+
``colors.xml`` and ``styles.xml``. This option can be specified multiple
115+
times.
113116

114117

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

194200

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

224233

225234
Requirements blacklist (APK size optimization)

pythonforandroid/bootstrap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class Bootstrap:
7070
'''An Android project template, containing recipe stuff for
7171
compilation and templated fields for APK info.
7272
'''
73-
name = ''
7473
jni_subdir = '/jni'
7574
ctx = None
7675

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,13 @@ def make_package(args):
522522
xmlpath = join(args.private, xmlpath)
523523
shutil.copy(xmlpath, res_xml_dir)
524524

525+
# Copy res_values files to src/main/res/values
526+
res_values_dir = join(res_dir, 'values')
527+
if args.res_values:
528+
ensure_dir(res_values_dir)
529+
for xmlpath in args.res_values:
530+
shutil.copy(xmlpath, res_values_dir)
531+
525532
# Render out android manifest:
526533
manifest_path = "src/main/AndroidManifest.xml"
527534
render_args = {
@@ -832,6 +839,8 @@ def parse_args_and_make_package(args=None):
832839
'directory'))
833840
ap.add_argument('--res_xml', dest='res_xmls', action='append', default=[],
834841
help='Add files to res/xml directory (for example device-filters)', nargs='+')
842+
ap.add_argument('--res-values', dest='res_values', action='append', default=[],
843+
help='Add files to res/values directory (for example styles.xml)')
835844
ap.add_argument('--with-billing', dest='billing_pubkey',
836845
help='If set, the billing service will be added (not implemented)')
837846
ap.add_argument('--add-source', dest='extra_source_dirs', action='append',

pythonforandroid/build.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ class Context:
7777
# the Android project folder where everything ends up
7878
dist_dir = None
7979

80-
# where Android libs are cached after build
81-
# but before being placed in dists
82-
libs_dir = None
83-
aars_dir = None
84-
8580
# Whether setup.py or similar should be used if present:
8681
use_setup_py = False
8782

@@ -109,6 +104,10 @@ def templates_dir(self):
109104

110105
@property
111106
def libs_dir(self):
107+
"""
108+
where Android libs are cached after build
109+
but before being placed in dists
110+
"""
112111
# Was previously hardcoded as self.build_dir/libs
113112
directory = join(self.build_dir, 'libs_collections',
114113
self.bootstrap.distribution.name)

pythonforandroid/graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_dependency_tuple_list_for_recipe(recipe, blacklist=None):
4545
"""
4646
if blacklist is None:
4747
blacklist = set()
48-
assert type(blacklist) == set
48+
assert type(blacklist) is set
4949
if recipe.depends is None:
5050
dependencies = []
5151
else:
@@ -160,7 +160,7 @@ def obvious_conflict_checker(ctx, name_tuples, blacklist=None):
160160
current_to_be_added = list(to_be_added)
161161
to_be_added = []
162162
for (added_tuple, adding_recipe) in current_to_be_added:
163-
assert type(added_tuple) == tuple
163+
assert type(added_tuple) is tuple
164164
if len(added_tuple) > 1:
165165
# No obvious commitment in what to add, don't check it itself
166166
# but throw it into deps for later comparing against

pythonforandroid/toolchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ def _fix_args(args):
997997
fix_args = ('--dir', '--private', '--add-jar', '--add-source',
998998
'--whitelist', '--blacklist', '--presplash', '--icon',
999999
'--icon-bg', '--icon-fg', '--fileprovider-paths',
1000-
'--google-services-json')
1000+
'--google-services-json', '--res-values')
10011001
unknown_args = args.unknown_args
10021002

10031003
for asset in args.assets:

tests/test_build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def test_strip_if_with_debug_symbols(self):
3636
modules = ["mymodule"]
3737
project_dir = None
3838
with mock.patch('pythonforandroid.build.info'), \
39-
mock.patch('sh.Command'),\
40-
mock.patch('pythonforandroid.build.open'),\
41-
mock.patch('pythonforandroid.build.shprint'),\
42-
mock.patch('pythonforandroid.build.current_directory'),\
39+
mock.patch('sh.Command'), \
40+
mock.patch('pythonforandroid.build.open'), \
41+
mock.patch('pythonforandroid.build.shprint'), \
42+
mock.patch('pythonforandroid.build.current_directory'), \
4343
mock.patch('pythonforandroid.build.CythonRecipe') as m_CythonRecipe, \
4444
mock.patch('pythonforandroid.build.project_has_setup_py') as m_project_has_setup_py, \
4545
mock.patch('pythonforandroid.build.run_setuppy_install'):

0 commit comments

Comments
 (0)