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

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


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

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

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

 vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt | 6 +++---
 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, 6 insertions(+), 10 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 a570a8ab6..ac556f9dd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -105,7 +105,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
@@ -259,9 +259,9 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
         args.putParcelable(KEY_MEDIA, media)
         next.arguments = args
         if (save) ft.addToBackStack(if (isRootDirectory) "root" else if (currentMedia != null) currentMedia?.uri.toString() else mrl!!)
-        if (BuildConfig.DEBUG) for (i in 0 until ctx.supportFragmentManager.backStackEntryCount)
+        if (BuildConfig.DEBUG) for (i in 0 until ctx.supportFragmentManager.backStackEntryCount) {
             Log.d(this::class.java.simpleName, "Adding to back stack from PathAdapter: ${ctx.supportFragmentManager.getBackStackEntryAt(i).name}")
-
+        }
         ft.replace(R.id.fragment_placeholder, next, media.title)
         ft.commit()
     }
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 706f78cb9..b76fec43d 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 753a2270f..42d308a6d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -1895,10 +1895,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