Fix sharing of multiple notes
This commit is contained in:
parent
d82e022750
commit
6c1bd8fe5e
2 changed files with 10 additions and 10 deletions
|
@ -3,6 +3,9 @@
|
|||
|
||||
<cache-path
|
||||
name="share"
|
||||
path="share" />
|
||||
path="share"/>
|
||||
|
||||
<external-files-path
|
||||
name="files"
|
||||
path="/"/>
|
||||
</paths>
|
|
@ -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<Recording> selected) {
|
||||
ArrayList<Uri> files = new ArrayList<>();
|
||||
ArrayList<Uri> 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<Recording> 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)) {
|
||||
|
|
Loading…
Reference in a new issue