Skip to content

Commit de819ff

Browse files
Fak3dbnicholson
authored andcommitted
Add optional android fileprovider.
1 parent f8f181c commit de819ff

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@ def make_package(args):
545545
remove('AndroidManifest.xml')
546546
shutil.copy(manifest_path, 'AndroidManifest.xml')
547547

548+
if args.fileprovider_paths:
549+
shutil.copy(args.fileprovider_paths, join(res_dir, "xml/file_paths.xml"))
550+
548551
# gradle build templates
549552
render(
550553
'build.tmpl.gradle',
@@ -793,6 +796,8 @@ def parse_args_and_make_package(args=None):
793796
ap.add_argument('--depend', dest='depends', action='append',
794797
help=('Add a external dependency '
795798
'(eg: com.android.support:appcompat-v7:19.0.1)'))
799+
ap.add_argument('--fileprovider-paths', dest='fileprovider_paths',
800+
help=('Add fileprovider paths xml file'))
796801
# The --sdk option has been removed, it is ignored in favour of
797802
# --android-api handled by toolchain.py
798803
ap.add_argument('--sdk', dest='sdk_version', default=-1,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ android {
3737
versionCode {{ args.numeric_version }}
3838
versionName '{{ args.version }}'
3939
manifestPlaceholders = {{ args.manifest_placeholders}}
40+
multiDexEnabled true
4041
}
4142

4243

@@ -84,7 +85,7 @@ android {
8485
}
8586

8687
compileOptions {
87-
{% if args.enable_androidx %}
88+
{% if args.enable_androidx %}
8889
sourceCompatibility JavaVersion.VERSION_1_8
8990
targetCompatibility JavaVersion.VERSION_1_8
9091
{% else %}
@@ -130,5 +131,7 @@ dependencies {
130131
{% if args.presplash_lottie %}
131132
implementation 'com.airbnb.android:lottie:3.4.0'
132133
{%- endif %}
134+
implementation 'com.android.support:support-v4:26.1.0'
135+
implementation 'com.android.support:multidex:1.0.3'
133136
}
134137

pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@
141141
{% for a in args.add_activity %}
142142
<activity android:name="{{ a }}"></activity>
143143
{% endfor %}
144+
145+
{% if args.fileprovider_paths %}
146+
<provider
147+
android:name="android.support.v4.content.FileProvider"
148+
android:authorities="{{ args.package }}.fileprovider"
149+
android:exported="false"
150+
android:grantUriPermissions="true">
151+
<meta-data
152+
android:name="android.support.FILE_PROVIDER_PATHS"
153+
android:resource="@xml/file_paths"/>
154+
</provider>
155+
{% endif %}
144156
</application>
145157

146158
</manifest>

pythonforandroid/toolchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ def _fix_args(args):
990990

991991
fix_args = ('--dir', '--private', '--add-jar', '--add-source',
992992
'--whitelist', '--blacklist', '--presplash', '--icon',
993-
'--icon-bg', '--icon-fg')
993+
'--icon-bg', '--icon-fg', '--fileprovider-paths')
994994
unknown_args = args.unknown_args
995995

996996
for asset in args.assets:

0 commit comments

Comments
 (0)