[Android] Fix mrl encoding passed to medialibrary
Geoffrey Métais
git at videolan.org
Wed Feb 21 16:25:35 CET 2018
vlc-android | branch: 3.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 21 16:02:29 2018 +0100| [55cfdfce1b19b0f94c4f032d5fc2c740bc077106] | committer: Geoffrey Métais
Fix mrl encoding passed to medialibrary
Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>
> https://code.videolan.org/videolan/vlc-android/commit/55cfdfce1b19b0f94c4f032d5fc2c740bc077106
---
medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 7 +++----
medialibrary/src/org/videolan/medialibrary/Tools.java | 5 ++---
.../src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java | 9 +++------
.../src/org/videolan/vlc/gui/helpers/MedialibraryUtils.java | 5 ++---
4 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index c2220cae2..937c36f21 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -117,8 +117,7 @@ public class Medialibrary {
}
public void discover(@NonNull String path) {
- if (mIsInitiated)
- nativeDiscover(Tools.encodeVLCMrl(path));
+ if (mIsInitiated) nativeDiscover(Tools.encodeVLCMrl(path));
}
public void removeFolder(@NonNull String mrl) {
@@ -274,13 +273,13 @@ public class Medialibrary {
@Nullable
public MediaWrapper getMedia(Uri uri) {
- final String vlcMrl = Tools.encodeVLCMrl(Uri.decode(uri.toString()));
+ final String vlcMrl = Tools.encodeVLCMrl(uri.toString());
return mIsInitiated && !TextUtils.isEmpty(vlcMrl) ? nativeGetMediaFromMrl(vlcMrl) : null;
}
@Nullable
public MediaWrapper getMedia(String mrl) {
- final String vlcMrl = Tools.encodeVLCMrl(Uri.decode(mrl));
+ final String vlcMrl = Tools.encodeVLCMrl(mrl);
return mIsInitiated && !TextUtils.isEmpty(vlcMrl) ? nativeGetMediaFromMrl(vlcMrl) : null;
}
diff --git a/medialibrary/src/org/videolan/medialibrary/Tools.java b/medialibrary/src/org/videolan/medialibrary/Tools.java
index 2a59ca6e8..a59031e4a 100644
--- a/medialibrary/src/org/videolan/medialibrary/Tools.java
+++ b/medialibrary/src/org/videolan/medialibrary/Tools.java
@@ -125,8 +125,7 @@ public class Tools {
}
static String encodeVLCMrl(String mrl) {
- if (mrl.startsWith("/"))
- mrl = "file://"+mrl;
- return VLCUtil.encodeVLCString(Uri.encode(mrl, ":/"));
+ if (mrl.startsWith("/")) mrl = "file://"+mrl;
+ return VLCUtil.encodeVLCString(Uri.encode(Uri.decode(mrl), ":/"));
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
index 0d02aac77..5c096e721 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
@@ -167,15 +167,12 @@ public class SavePlaylistDialog extends DialogFragment implements View.OnClickLi
long id = mw.getId();
if (id == 0) {
MediaWrapper media = mMedialibrary.getMedia(mw.getUri());
- if (media != null)
- ids.add(media.getId());
+ if (media != null) ids.add(media.getId());
else {
media = mMedialibrary.addMedia(mw.getLocation());
- if (media != null)
- ids.add(media.getId());
+ if (media != null) ids.add(media.getId());
}
- } else
- ids.add(id);
+ } else ids.add(id);
}
playlist.append(ids);
if (mCallBack != null) mCallBack.run();
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.java b/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.java
index 786a7d3b8..fe6fc5cbd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.java
@@ -2,7 +2,6 @@ package org.videolan.vlc.gui.helpers;
import android.content.Intent;
-import android.net.Uri;
import org.videolan.vlc.MediaParsingService;
import org.videolan.vlc.VLCApplication;
@@ -14,14 +13,14 @@ public class MedialibraryUtils {
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
- VLCApplication.getMLInstance().removeFolder(Uri.decode(path));
+ VLCApplication.getMLInstance().removeFolder(path);
}
});
}
public static void addDir(final String path) {
final Intent intent = new Intent(Constants.ACTION_DISCOVER, null, VLCApplication.getAppContext(), MediaParsingService.class);
- intent.putExtra(Constants.EXTRA_PATH, Uri.decode(path));
+ intent.putExtra(Constants.EXTRA_PATH, path);
VLCApplication.getAppContext().startService(intent);
}
}
More information about the Android
mailing list