diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 990177c778..4470a4ad8b 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -553,5 +553,15 @@ + + + + diff --git a/android/build.gradle b/android/build.gradle index c7ac2b4481..54b005e863 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -513,3 +513,11 @@ task obbPush(dependsOn: ['obbGenerate', 'obbPushMain', 'obbPushPatch']) { commandLine android.getAdbExe(), 'push', propObbWorldsOutput, "${obbPath}worlds.obb" } } + +android.buildTypes.all { buildType -> + def suffix = applicationIdSuffix != null ? applicationIdSuffix : ""; + def authorityValue = android.defaultConfig.applicationId + suffix + ".provider" + def authority = "\"" + authorityValue + "\"" + buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', authority + manifestPlaceholders += ['FILE_PROVIDER_PLACEHOLDER' : authorityValue] +} diff --git a/android/res/xml/file_paths.xml b/android/res/xml/file_paths.xml new file mode 100644 index 0000000000..d670b038e2 --- /dev/null +++ b/android/res/xml/file_paths.xml @@ -0,0 +1,4 @@ + + + + diff --git a/android/src/com/mapswithme/util/sharing/LocalFileShareable.java b/android/src/com/mapswithme/util/sharing/LocalFileShareable.java index 596dc89151..891eea2a0a 100644 --- a/android/src/com/mapswithme/util/sharing/LocalFileShareable.java +++ b/android/src/com/mapswithme/util/sharing/LocalFileShareable.java @@ -4,6 +4,9 @@ import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.support.annotation.Nullable; +import android.support.v4.content.FileProvider; + +import com.mapswithme.maps.BuildConfig; import java.io.File; @@ -12,7 +15,7 @@ public class LocalFileShareable extends BaseShareable private final String mFileName; private final String mMimeType; - public LocalFileShareable(Activity context, String fileName, String mimeType) + LocalFileShareable(Activity context, String fileName, String mimeType) { super(context); mFileName = fileName; @@ -23,7 +26,9 @@ public class LocalFileShareable extends BaseShareable protected void modifyIntent(Intent intent, @Nullable SharingTarget target) { super.modifyIntent(intent, target); - intent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile(new File(mFileName))); + Uri fileUri = FileProvider.getUriForFile(getActivity(), BuildConfig.FILE_PROVIDER_AUTHORITY, + new File(mFileName)); + intent.putExtra(android.content.Intent.EXTRA_STREAM, fileUri); } @Override