From bab07b0643929f7d7f1bdc44c40774fe2a3c2dca Mon Sep 17 00:00:00 2001 From: pavelsof Date: Thu, 14 May 2020 22:54:22 +0200 Subject: [PATCH 1/3] Added the --content-providers option to the common build.py. --- doc/source/buildoptions.rst | 2 ++ pythonforandroid/bootstraps/common/build/build.py | 10 ++++++++++ .../sdl2/build/templates/AndroidManifest.tmpl.xml | 11 ++++++++--- .../build/templates/AndroidManifest.tmpl.xml | 4 ++++ .../webview/build/templates/AndroidManifest.tmpl.xml | 4 ++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/source/buildoptions.rst b/doc/source/buildoptions.rst index 19360ff2fa..ae7241eb65 100644 --- a/doc/source/buildoptions.rst +++ b/doc/source/buildoptions.rst @@ -86,6 +86,8 @@ options (this list may not be exhaustive): include multiple jar files, pass this argument multiple times. - ``--intent-filters``: A file path containing intent filter xml to be included in AndroidManifest.xml. +- ``--content-providers``: A file path containing provider xml to be + included in AndroidManifest.xml. - ``--service``: A service name and the Python script it should run. See :ref:`arbitrary_scripts_services`. - ``--add-source``: Add a source directory to the app's Java code. diff --git a/pythonforandroid/bootstraps/common/build/build.py b/pythonforandroid/bootstraps/common/build/build.py index 8d3bee6ea6..73229a9550 100644 --- a/pythonforandroid/bootstraps/common/build/build.py +++ b/pythonforandroid/bootstraps/common/build/build.py @@ -372,6 +372,10 @@ def make_package(args): with open(args.intent_filters) as fd: args.intent_filters = fd.read() + if args.content_providers: + with open(args.content_providers) as f: + args.content_providers = f.read() + if not args.add_activity: args.add_activity = [] @@ -707,6 +711,12 @@ def parse_args_and_make_package(args=None): 'filename containing xml. The filename should be ' 'located relative to the python-for-android ' 'directory')) + ap.add_argument('--content-providers', dest='content_providers', + help=('Add providers xml rules to the ' + 'AndroidManifest.xml file. The argument is a ' + 'filename containing xml. The filename should be ' + 'located relative to the python-for-android ' + 'directory')) 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', diff --git a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml index a37e720753..5a156d53db 100644 --- a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml +++ b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml @@ -129,9 +129,14 @@ {% endif %} - {% for a in args.add_activity %} - - {% endfor %} + + {% for a in args.add_activity %} + + {% endfor %} + + {%- if args.content_providers -%} + {{- args.content_providers -}} + {%- endif -%} diff --git a/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml index f3eb3befcf..6f2982bb4b 100644 --- a/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml +++ b/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml @@ -92,6 +92,10 @@ {% endif %} + + {%- if args.content_providers -%} + {{- args.content_providers -}} + {%- endif -%} diff --git a/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml index 8b6b4ca923..ceef024234 100644 --- a/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml +++ b/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml @@ -94,6 +94,10 @@ {% endif %} + + {%- if args.content_providers -%} + {{- args.content_providers -}} + {%- endif -%} From ba045b65b61e9c1bc1e7e27f77b181cbcb1d3e1e Mon Sep 17 00:00:00 2001 From: pavelsof Date: Thu, 14 May 2020 23:16:15 +0200 Subject: [PATCH 2/3] Added the --add-resource option to the common build.py. --- pythonforandroid/bootstraps/common/build/build.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pythonforandroid/bootstraps/common/build/build.py b/pythonforandroid/bootstraps/common/build/build.py index 73229a9550..d5b447173d 100644 --- a/pythonforandroid/bootstraps/common/build/build.py +++ b/pythonforandroid/bootstraps/common/build/build.py @@ -511,6 +511,11 @@ def make_package(args): join(res_dir, 'values/strings.xml'), **render_args) + # extra resources + if args.add_resource: + for file_path in args.add_resource: + shutil.copy(file_path, join(res_dir, basename(file_path))) + if exists(join("templates", "custom_rules.tmpl.xml")): render( 'custom_rules.tmpl.xml', @@ -717,6 +722,9 @@ def parse_args_and_make_package(args=None): 'filename containing xml. The filename should be ' 'located relative to the python-for-android ' 'directory')) + ap.add_argument('--add-resource', dest='add_resource', action='append', + help=('Copy this file at this path to the src/main/res ' + 'subdirectory of the build.')) 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', From bae2f5bbf6f7bf3e4954ea25a29790815223149e Mon Sep 17 00:00:00 2001 From: pavelsof Date: Thu, 14 May 2020 23:39:17 +0200 Subject: [PATCH 3/3] Replaced --add-resource with --add-xml-resource in the common build.py. --- .../bootstraps/common/build/build.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pythonforandroid/bootstraps/common/build/build.py b/pythonforandroid/bootstraps/common/build/build.py index d5b447173d..28c5483621 100644 --- a/pythonforandroid/bootstraps/common/build/build.py +++ b/pythonforandroid/bootstraps/common/build/build.py @@ -511,10 +511,13 @@ def make_package(args): join(res_dir, 'values/strings.xml'), **render_args) - # extra resources - if args.add_resource: - for file_path in args.add_resource: - shutil.copy(file_path, join(res_dir, basename(file_path))) + # extra xml resources + if args.add_xml_resource: + xml_res_dir = join(res_dir, 'xml') + if not exists(xml_res_dir): + os.mkdir(xml_res_dir) + for file_path in args.add_xml_resource: + shutil.copy(file_path, join(xml_res_dir, basename(file_path))) if exists(join("templates", "custom_rules.tmpl.xml")): render( @@ -722,8 +725,9 @@ def parse_args_and_make_package(args=None): 'filename containing xml. The filename should be ' 'located relative to the python-for-android ' 'directory')) - ap.add_argument('--add-resource', dest='add_resource', action='append', - help=('Copy this file at this path to the src/main/res ' + ap.add_argument('--add-xml-resource', dest='add_xml_resource', + action='append', + help=('Copy this file to the src/main/res/xml ' 'subdirectory of the build.')) ap.add_argument('--with-billing', dest='billing_pubkey', help='If set, the billing service will be added (not implemented)')