[android] Fix saving to Google Drive #8817
1 changed files with 7 additions and 4 deletions
|
@ -19,6 +19,8 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.organicmaps.Framework;
|
||||
import app.organicmaps.R;
|
||||
|
@ -212,7 +214,7 @@ public class SharingUtils
|
|||
|
||||
public static void shareFile(Context context, ActivityResultLauncher<SharingIntent> launcher, ShareInfo info)
|
||||
{
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
|
||||
|
||||
if (!info.mSubject.isEmpty())
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, info.mSubject);
|
||||
|
@ -228,15 +230,16 @@ public class SharingUtils
|
|||
{
|
||||
final Uri fileUri = StorageUtils.getUriForFilePath(context, info.mFileName);
|
||||
Logger.i(TAG, "Sharing file " + info.mMimeType + " " + info.mFileName + " with URI " + fileUri);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, fileUri);
|
||||
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<>(List.of(fileUri)));
|
||||
![]() In this case context is Activity. In this case context is Activity.
![]() Does it allow to come back into Organic Maps after the file is exported? Does it allow to come back into Organic Maps after the file is exported?
![]() Yes. After exporting we return to Organic Maps (checked it for exporting to Google Drive and local deevice) Yes. After exporting we return to Organic Maps (checked it for exporting to Google Drive and local deevice)
![]() There are several more places in the code where this function is called. Did you test it on different Android versions too? Does it work on Android 5? There are several more places in the code where this function is called. Did you test it on different Android versions too? Does it work on Android 5?
![]() i tested it in send bug report functionality. i tested it in send bug report functionality.
It works correcctly on Android 10
On Android 5 send e-mail and savind to documents work too. Saving to Google Drive i can't check
![]() Should FLAG_ACTIVITY_NEW_TASK be used when a single bookmark or POI is shared from the Place Page? Should FLAG_ACTIVITY_NEW_TASK be used when a single bookmark or POI is shared from the Place Page?
![]()
```suggestion
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
```
![]() On current version works correctly On current version works correctly
|
||||
intent.setDataAndType(fileUri, info.mMimeType);
|
||||
|
||||
// Properly set permissions for intent, see
|
||||
// https://developer.android.com/reference/androidx/core/content/FileProvider#include-the-permission-in-an-intent
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
intent.setClipData(ClipData.newRawUri("", fileUri));
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
}
|
||||
|
||||
Intent saveIntent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||
|
|
Reference in a new issue
Should it be inside
if (context instanceof Application)
, as it is done in other apps?