[Android] Fix root tap on the breadcrumb for sub picking and in browser

Nicolas Pomepuy git at videolan.org
Wed Jan 20 09:54:26 UTC 2021


vlc-android | branch: 3.3.x | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Dec 17 07:07:22 2020 +0100| [0d8a83d9075e5036aa1ad51119602d9fe01bb5e6] | committer: Nicolas Pomepuy

Fix root tap on the breadcrumb for sub picking and in browser

(cherry picked from commit ca5a4af91341db1828472c1df6bbe1468d713996)

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

 .../org/videolan/vlc/gui/browser/BaseBrowserFragment.kt   |  4 ++++
 .../org/videolan/vlc/gui/browser/FilePickerFragment.kt    | 15 ++++++++++++++-
 .../src/org/videolan/vlc/providers/FileBrowserProvider.kt |  1 +
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index a93a2d0e9..7e139256e 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -179,6 +179,10 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
     }
 
     override fun backTo(tag: String) {
+        if (tag == "root") {
+            requireActivity().finish()
+            return
+        }
         val supportFragmentManager = requireActivity().supportFragmentManager
         var poped = false
         for (i in 0 until supportFragmentManager.backStackEntryCount) {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.kt
index 336add175..ecdea3187 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.kt
@@ -30,6 +30,7 @@ import android.os.Bundle
 import android.view.View
 import androidx.core.net.toUri
 import androidx.fragment.app.Fragment
+import androidx.fragment.app.FragmentManager
 import androidx.lifecycle.ViewModelProviders
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -44,7 +45,6 @@ import org.videolan.vlc.R
 import org.videolan.vlc.gui.ContentActivity
 import org.videolan.vlc.repository.DirectoryRepository
 import org.videolan.vlc.util.FileUtils
-import org.videolan.vlc.util.isSchemeFile
 import org.videolan.vlc.viewmodels.browser.BrowserModel
 import org.videolan.vlc.viewmodels.browser.TYPE_PICKER
 
@@ -92,6 +92,19 @@ class FilePickerFragment : FileBrowserFragment(), BrowserContainer<MediaLibraryI
 
     }
 
+    override fun backTo(tag: String) {
+        if (tag == "root") {
+            val supportFragmentManager = requireActivity().supportFragmentManager
+            for (i in 0 until supportFragmentManager.backStackEntryCount) {
+                supportFragmentManager.popBackStack(tag, FragmentManager.POP_BACK_STACK_INCLUSIVE)
+            }
+            viewModel.setDestination(MLServiceLocator.getAbstractMediaWrapper(tag.toUri()))
+            supportFragmentManager.beginTransaction().detach(this).attach(this).commit()
+            return
+        }
+        super.backTo(tag)
+    }
+
     override fun onImageClick(v: View, position: Int, item: MediaLibraryItem) {}
 
     private fun pickFile(mw: MediaWrapper) {
diff --git a/application/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt b/application/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
index 89c454c09..62952f0a2 100644
--- a/application/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
@@ -126,6 +126,7 @@ open class FileBrowserProvider(
                 }
                 loading.postValue(false)
             }
+            url == "root" -> launch { browseRootImpl() }
             else -> super.browse(url)
         }
     }



More information about the Android mailing list