Skip to content

Commit 7434c02

Browse files
Fak3rtibbles
authored andcommitted
Add optional android fileprovider.
1 parent 3bec69a commit 7434c02

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
@@ -558,6 +558,9 @@ def make_package(args):
558558
remove('AndroidManifest.xml')
559559
shutil.copy(manifest_path, 'AndroidManifest.xml')
560560

561+
if args.fileprovider_paths:
562+
shutil.copy(args.fileprovider_paths, join(res_dir, "xml/file_paths.xml"))
563+
561564
# gradle build templates
562565
render(
563566
'build.tmpl.gradle',
@@ -884,6 +887,8 @@ def create_argument_parser():
884887
ap.add_argument('--depend', dest='depends', action='append',
885888
help=('Add a external dependency '
886889
'(eg: com.android.support:appcompat-v7:19.0.1)'))
890+
ap.add_argument('--fileprovider-paths', dest='fileprovider_paths',
891+
help=('Add fileprovider paths xml file'))
887892
# The --sdk option has been removed, it is ignored in favour of
888893
# --android-api handled by toolchain.py
889894
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
@@ -136,6 +136,18 @@
136136
{% for a in args.add_activity %}
137137
<activity android:name="{{ a }}"></activity>
138138
{% endfor %}
139+
140+
{% if args.fileprovider_paths %}
141+
<provider
142+
android:name="android.support.v4.content.FileProvider"
143+
android:authorities="{{ args.package }}.fileprovider"
144+
android:exported="false"
145+
android:grantUriPermissions="true">
146+
<meta-data
147+
android:name="android.support.FILE_PROVIDER_PATHS"
148+
android:resource="@xml/file_paths"/>
149+
</provider>
150+
{% endif %}
139151
</application>
140152

141153
</manifest>

pythonforandroid/toolchain.py

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

995995
fix_args = ('--dir', '--private', '--add-jar', '--add-source',
996996
'--whitelist', '--blacklist', '--presplash', '--icon',
997-
'--icon-bg', '--icon-fg')
997+
'--icon-bg', '--icon-fg', '--fileprovider-paths')
998998
unknown_args = args.unknown_args
999999

10001000
for asset in args.assets:

0 commit comments

Comments
 (0)