summaryrefslogtreecommitdiffstats
path: root/src/android/templates
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2022-08-24 21:06:45 +0300
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2023-02-24 17:45:10 +0200
commit738c48244bb7fe2a29e5f8f537a6f6c2ebb33008 (patch)
tree40e170713bba44d9246de5f6f0274e32b25ea9b6 /src/android/templates
parentb8d51001f7d1c40cced642b4a1d990c90244706f (diff)
Android: use FileProvider with QDesktopServices::openUrl()
Allow openUrl() to use FileProvider for opening files that are located under app scoped paths and that use a file scheme for Android sdk 24 or above. [ChangeLog][Core][Android] Add FileProvider support for QDesktopServices::openUrl(). [ChangeLog][Core][Android] Add AndroidX dependency to Gradle builds by default since it's required by FileProvider. Fixes: QTBUG-85238 Change-Id: Ia7403f74f2a8fd4886f74dba72e42b318ef5d079 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/android/templates')
-rw-r--r--src/android/templates/AndroidManifest.xml10
-rw-r--r--src/android/templates/CMakeLists.txt1
-rw-r--r--src/android/templates/build.gradle1
-rw-r--r--src/android/templates/res/xml/qtprovider_paths.xml4
4 files changed, 16 insertions, 0 deletions
diff --git a/src/android/templates/AndroidManifest.xml b/src/android/templates/AndroidManifest.xml
index d7438317b8..8f91863719 100644
--- a/src/android/templates/AndroidManifest.xml
+++ b/src/android/templates/AndroidManifest.xml
@@ -43,5 +43,15 @@
android:name="android.app.extract_android_style"
android:value="minimal" />
</activity>
+
+ <provider
+ android:name="androidx.core.content.FileProvider"
+ android:authorities="${applicationId}.qtprovider"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="android.support.FILE_PROVIDER_PATHS"
+ android:resource="@xml/qtprovider_paths"/>
+ </provider>
</application>
</manifest>
diff --git a/src/android/templates/CMakeLists.txt b/src/android/templates/CMakeLists.txt
index 0d710f72f4..94f3243c22 100644
--- a/src/android/templates/CMakeLists.txt
+++ b/src/android/templates/CMakeLists.txt
@@ -14,6 +14,7 @@ add_custom_target(Qt${QtBase_VERSION_MAJOR}AndroidTemplates
SOURCES
${template_files}
"${CMAKE_CURRENT_SOURCE_DIR}/res/values/libs.xml"
+ "${CMAKE_CURRENT_SOURCE_DIR}/res/xml/qtprovider_paths.xml"
)
qt_path_join(destination ${QT_INSTALL_DIR} ${INSTALL_DATADIR} "src/android/templates")
diff --git a/src/android/templates/build.gradle b/src/android/templates/build.gradle
index f6c2f3d56d..33867903c2 100644
--- a/src/android/templates/build.gradle
+++ b/src/android/templates/build.gradle
@@ -18,6 +18,7 @@ apply plugin: 'com.android.application'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
+ implementation 'androidx.core:core:1.8.0'
}
android {
diff --git a/src/android/templates/res/xml/qtprovider_paths.xml b/src/android/templates/res/xml/qtprovider_paths.xml
new file mode 100644
index 0000000000..ae5b4b6074
--- /dev/null
+++ b/src/android/templates/res/xml/qtprovider_paths.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths xmlns:android="http://schemas.android.com/apk/res/android">
+ <files-path name="files_path" path="/"/>
+</paths>