[Android] Browser: Load network browser for network urls
Geoffrey Métais
git at videolan.org
Wed May 6 13:05:51 CEST 2020
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue May 5 15:39:21 2020 +0200| [84e5f03d7929822597687b799b1bd5f3b74aa7ad] | committer: Nicolas Pomepuy
Browser: Load network browser for network urls
Fix #1306,#1307
> https://code.videolan.org/videolan/vlc-android/commit/84e5f03d7929822597687b799b1bd5f3b74aa7ad
---
.../src/org/videolan/vlc/gui/SecondaryActivity.kt | 13 +++++++++++--
.../vlc-android/src/org/videolan/vlc/util/Browserutils.kt | 6 +++++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
index 29a925a93..3d7e85d4b 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
@@ -34,22 +34,28 @@ import com.google.android.material.appbar.AppBarLayout
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.medialibrary.interfaces.Medialibrary
+import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.resources.AndroidDevices
import org.videolan.resources.KEY_FOLDER
import org.videolan.resources.KEY_GROUP
import org.videolan.resources.util.applyOverscanMargin
import org.videolan.tools.RESULT_RESCAN
import org.videolan.tools.RESULT_RESTART
+import org.videolan.tools.isValidUrl
+import org.videolan.tools.removeFileProtocole
import org.videolan.vlc.R
import org.videolan.vlc.gui.audio.AudioAlbumsSongsFragment
import org.videolan.vlc.gui.audio.AudioBrowserFragment
import org.videolan.vlc.gui.browser.FileBrowserFragment
import org.videolan.vlc.gui.browser.KEY_MEDIA
+import org.videolan.vlc.gui.browser.NetworkBrowserFragment
import org.videolan.vlc.gui.browser.StorageBrowserFragment
import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.gui.network.MRLPanelFragment
import org.videolan.vlc.gui.video.VideoGridFragment
import org.videolan.vlc.reloadLibrary
+import org.videolan.vlc.util.isSchemeNetwork
+import org.videolan.vlc.util.validateLocation
@ExperimentalCoroutinesApi
@ObsoleteCoroutinesApi
@@ -155,9 +161,12 @@ class SecondaryActivity : ContentActivity() {
setResult(RESULT_RESTART)
}
FILE_BROWSER -> {
- fragment = FileBrowserFragment().apply {
+ val media = intent.getParcelableExtra(KEY_MEDIA) as MediaWrapper
+ fragment = if(media.uri.scheme.isSchemeNetwork()) NetworkBrowserFragment()
+ else FileBrowserFragment()
+ fragment?.apply {
arguments = Bundle(2).apply {
- putParcelable(KEY_MEDIA, intent.getParcelableExtra(KEY_MEDIA))
+ putParcelable(KEY_MEDIA, media)
}
}
}
diff --git a/application/vlc-android/src/org/videolan/vlc/util/Browserutils.kt b/application/vlc-android/src/org/videolan/vlc/util/Browserutils.kt
index 39f17aebd..5a45eaba2 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/Browserutils.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/Browserutils.kt
@@ -28,7 +28,11 @@ import org.videolan.vlc.mediadb.models.BrowserFav
import java.io.File
fun isSchemeSupported(scheme: String?) = when(scheme) {
- "file", "smb", "ssh", "nfs", "content" -> true
+ "file", "smb", "ssh", "nfs", "ftp", "ftps", "content" -> true
+ else -> false
+}
+fun String?.isSchemeNetwork() = when(this) {
+ "smb", "ssh", "nfs", "ftp", "ftps" -> true
else -> false
}
More information about the Android
mailing list