[Android] Video player: Fix subs picker for content:// uris

Geoffrey Métais git at videolan.org
Wed Nov 13 17:16:55 CET 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 13 17:13:11 2019 +0100| [fb105f84ace8de92f71b2a30d83a252de8714663] | committer: Geoffrey Métais

Video player: Fix subs picker for content:// uris

Fix #1087
(cherry picked from commit a37a2740a0cddb22de21459f42780814fd95426c)

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

 vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt | 2 +-
 vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.kt  | 6 +-----
 vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt   | 4 ++--
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 53df744e5..553ee7b7e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -99,7 +99,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
         if (bundle == null) bundle = arguments
         if (bundle != null) {
             currentMedia = bundle.getParcelable(KEY_MEDIA)
-            mrl = if (currentMedia != null) currentMedia!!.location else bundle.getString(KEY_MRL)
+            mrl = currentMedia?.location ?: bundle.getString(KEY_MRL)
             savedPosition = bundle.getInt(KEY_POSITION)
         } else if (requireActivity().intent != null) {
             mrl = requireActivity().intent.dataString
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.kt
index 80f2d9ecc..ff0086bb1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.kt
@@ -47,17 +47,13 @@ import org.videolan.vlc.viewmodels.browser.TYPE_PICKER
 const val EXTRA_MRL = "sub_mrl"
 class FilePickerFragment : FileBrowserFragment() {
 
-    val isSortEnabled: Boolean
-        get() = false
-
-
     override fun createFragment(): Fragment {
         return FilePickerFragment()
     }
 
     override fun onCreate(bundle: Bundle?) {
         val uri = activity?.intent?.data
-        if (uri == null || TextUtils.equals(uri.scheme, "http")) {
+        if (uri == null || uri.scheme == "http" || uri.scheme == "content" || uri.scheme == "fd") {
             activity?.intent = null
         }
         super.onCreate(bundle)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index 72399cace..6c9ea9b68 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -1891,10 +1891,10 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
     }
 
     fun pickSubtitles() {
-        if (videoUri == null) return
+        val uri = videoUri?: return
         isShowingDialog = true
         val filePickerIntent = Intent(this, FilePickerActivity::class.java)
-        filePickerIntent.data = Uri.parse(FileUtils.getParent(videoUri!!.toString()))
+        filePickerIntent.data = Uri.parse(FileUtils.getParent(uri.toString()))
         startActivityForResult(filePickerIntent, 0)
     }
 



More information about the Android mailing list