[Android] Add support from dropped URLs

Geoffrey Métais git at videolan.org
Wed Jan 10 18:51:42 CET 2018


vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 10 18:50:14 2018 +0100| [d87e72d460eb8cec7aacdd12e7b11a037cc7300c] | committer: Geoffrey Métais

Add support from dropped URLs

(cherry picked from commit 6e64f80d5e5c69247c3cb996e6d4a4c55f898df6)

> https://code.videolan.org/videolan/vlc-android/commit/d87e72d460eb8cec7aacdd12e7b11a037cc7300c
---

 vlc-android/src/org/videolan/vlc/gui/ContentActivity.java | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java b/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java
index dfe1b2596..5f0e6eab8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java
@@ -27,6 +27,7 @@ package org.videolan.vlc.gui;
 import android.app.SearchManager;
 import android.content.ClipData;
 import android.content.Intent;
+import android.net.Uri;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.v4.app.Fragment;
@@ -39,6 +40,7 @@ import android.view.MenuItem;
 import android.view.View;
 
 import org.videolan.libvlc.util.AndroidUtil;
+import org.videolan.medialibrary.media.MediaWrapper;
 import org.videolan.vlc.R;
 import org.videolan.vlc.gui.audio.EqualizerFragment;
 import org.videolan.vlc.gui.browser.ExtensionBrowser;
@@ -68,7 +70,14 @@ public class ContentActivity extends AudioPlayerContainerActivity implements Sea
                         for (int i = 0; i < itemsCount; i++) {
                             final DragAndDropPermissions permissions = requestDragAndDropPermissions(event);
                             if (permissions != null)  {
-                                MediaUtils.openMediaNoUi(clipData.getItemAt(i).getUri());
+                                final ClipData.Item item = clipData.getItemAt(i);
+                                if (item.getUri() != null) MediaUtils.openUri(ContentActivity.this, item.getUri());
+                                else if (item.getText() != null) {
+                                    final Uri uri = Uri.parse(item.getText().toString());
+                                    final MediaWrapper media = new MediaWrapper(uri);
+                                    if (!"file".equals(uri.getScheme())) media.setType(MediaWrapper.TYPE_STREAM);
+                                    MediaUtils.openMedia(ContentActivity.this, media);
+                                }
                                 return true;
                             }
                         }



More information about the Android mailing list