forked from organicmaps/organicmaps
[android] Support ACTION_SEND_MULTIPLE
Tested with Google Drive. GPS Logger and Samsung Files are not supported because they don't set mime-type. Changing mimtType to "*/*" fixes the issue, but makes the app default handler for any files, which is annoying. ``` <intent-filter> <action android:name="android.intent.action.SEND_MULTIPLE"/> <category android:name="android.intent.category.DEFAULT"/> <data android:mimeType="*/*"/> </intent-filter> `` Closes #5402 Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
parent
5cb759e20a
commit
f9746cf30c
3 changed files with 18 additions and 6 deletions
|
@ -155,6 +155,7 @@
|
|||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
<action android:name="android.intent.action.SEND_MULTIPLE"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="application/vnd.google-earth.kml+xml"/>
|
||||
<data android:mimeType="application/vnd.google-earth.kmz"/>
|
||||
|
|
|
@ -494,6 +494,13 @@ public enum BookmarkManager
|
|||
return true;
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public void importBookmarksFiles(@NonNull ContentResolver resolver, @NonNull List<Uri> uris, @NonNull File tempDir)
|
||||
{
|
||||
for (Uri uri: uris)
|
||||
importBookmarksFile(resolver, uri, tempDir);
|
||||
}
|
||||
|
||||
public boolean isAsyncBookmarksLoadingInProgress()
|
||||
{
|
||||
return nativeIsAsyncBookmarksLoadingInProgress();
|
||||
|
|
|
@ -25,6 +25,8 @@ import app.organicmaps.util.StorageUtils;
|
|||
import app.organicmaps.util.concurrency.ThreadPool;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Factory
|
||||
{
|
||||
|
@ -39,20 +41,22 @@ public class Factory
|
|||
public boolean process(@NonNull Intent intent, @NonNull MwmActivity activity)
|
||||
{
|
||||
// See KML/KMZ/KMB intent filters in manifest.
|
||||
final Uri uri;
|
||||
final List<Uri> uris;
|
||||
if (Intent.ACTION_VIEW.equals(intent.getAction()))
|
||||
uri = intent.getData();
|
||||
uris = Collections.singletonList(intent.getData());
|
||||
else if (Intent.ACTION_SEND.equals(intent.getAction()))
|
||||
uri = IntentCompat.getParcelableExtra(intent, Intent.EXTRA_STREAM, Uri.class);
|
||||
uris = Collections.singletonList(IntentCompat.getParcelableExtra(intent, Intent.EXTRA_STREAM, Uri.class));
|
||||
else if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction()))
|
||||
uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
|
||||
else
|
||||
uri = null;
|
||||
if (uri == null)
|
||||
uris = null;
|
||||
if (uris == null)
|
||||
return false;
|
||||
|
||||
MwmApplication app = MwmApplication.from(activity);
|
||||
final File tempDir = new File(StorageUtils.getTempPath(app));
|
||||
final ContentResolver resolver = activity.getContentResolver();
|
||||
ThreadPool.getStorage().execute(() -> BookmarkManager.INSTANCE.importBookmarksFile(resolver, uri, tempDir));
|
||||
ThreadPool.getStorage().execute(() -> BookmarkManager.INSTANCE.importBookmarksFiles(resolver, uris, tempDir));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue