Skip to content

Add optional android fileprovider. #1922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pythonforandroid/bootstraps/common/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ def make_package(args):
remove('AndroidManifest.xml')
shutil.copy(manifest_path, 'AndroidManifest.xml')

if args.fileprovider_paths:
shutil.copy(args.fileprovider_paths, join(res_dir, "xml/file_paths.xml"))

# gradle build templates
render(
'build.tmpl.gradle',
Expand Down Expand Up @@ -685,6 +688,8 @@ def parse_args(args=None):
ap.add_argument('--depend', dest='depends', action='append',
help=('Add a external dependency '
'(eg: com.android.support:appcompat-v7:19.0.1)'))
ap.add_argument('--fileprovider-paths', dest='fileprovider_paths',
help=('Add fileprovider paths xml file'))
# The --sdk option has been removed, it is ignored in favour of
# --android-api handled by toolchain.py
ap.add_argument('--sdk', dest='sdk_version', default=-1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ android {
targetSdkVersion {{ android_api }}
versionCode {{ args.numeric_version }}
versionName '{{ args.version }}'
multiDexEnabled true
}

{% if args.sign -%}
Expand Down Expand Up @@ -77,4 +78,6 @@ dependencies {
compile '{{ depend }}'
{%- endfor %}
{%- endif %}
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:multidex:1.0.3'
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@
{% for a in args.add_activity %}
<activity android:name="{{ a }}"></activity>
{% endfor %}

{% if args.fileprovider_paths %}
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="{{ args.package }}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
{% endif %}
</application>

</manifest>
3 changes: 2 additions & 1 deletion pythonforandroid/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,8 @@ def apk(self, args):
# we can't leave it until later as the build.py scripts assume
# they are in the current directory.
fix_args = ('--dir', '--private', '--add-jar', '--add-source',
'--whitelist', '--blacklist', '--presplash', '--icon')
'--whitelist', '--blacklist', '--presplash', '--icon',
'--fileprovider-paths')
unknown_args = args.unknown_args
for i, arg in enumerate(unknown_args):
argx = arg.split('=')
Expand Down