From 6c1bd8fe5eca0d731ab596ef1256c788f8397403 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 21 Dec 2017 18:28:00 +0200 Subject: [PATCH] Fix sharing of multiple notes --- OsmAnd/res/xml/paths.xml | 5 ++++- .../net/osmand/plus/audionotes/NotesFragment.java | 15 ++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/OsmAnd/res/xml/paths.xml b/OsmAnd/res/xml/paths.xml index 78a4755a05..90217e4c1f 100644 --- a/OsmAnd/res/xml/paths.xml +++ b/OsmAnd/res/xml/paths.xml @@ -3,6 +3,9 @@ + path="share"/> + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java index a516fc0b20..b7091cba4f 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java @@ -10,6 +10,7 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; +import android.support.v4.content.FileProvider; import android.support.v7.app.AlertDialog; import android.support.v7.view.ActionMode; import android.view.LayoutInflater; @@ -453,16 +454,17 @@ public class NotesFragment extends OsmAndListFragment { } private void shareItems(Set selected) { - ArrayList files = new ArrayList<>(); + ArrayList uris = new ArrayList<>(); for (Recording rec : selected) { File file = rec == SHARE_LOCATION_FILE ? generateGPXForRecordings(selected) : rec.getFile(); if (file != null) { - files.add(Uri.parse(file.getAbsolutePath())); + uris.add(FileProvider.getUriForFile(getContext(), getActivity().getPackageName() + ".fileprovider", file)); } } + Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("*/*"); - intent.putExtra(Intent.EXTRA_STREAM, files); + intent.putExtra(Intent.EXTRA_STREAM, uris); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); if (Build.VERSION.SDK_INT > 18) { intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); @@ -477,13 +479,8 @@ public class NotesFragment extends OsmAndListFragment { return selected; } - @Nullable private File generateGPXForRecordings(Set selected) { - File externalCacheDir = getActivity().getExternalCacheDir(); - if (externalCacheDir == null) { - return null; - } - File tmpFile = new File(externalCacheDir, "share/noteLocations.gpx"); + File tmpFile = new File(getActivity().getCacheDir(), "share/noteLocations.gpx"); tmpFile.getParentFile().mkdirs(); GPXFile file = new GPXFile(); for (Recording r : getRecordingsForGpx(selected)) {