[Android] Handle external storages for subs picker

Geoffrey Métais git at videolan.org
Fri May 6 14:15:51 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri May  6 14:03:55 2016 +0200| [a1ebbf588dfbc556c8d941a6c6da4d2d23d3f363] | committer: Geoffrey Métais

Handle external storages for subs picker

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

 .../org/videolan/vlc/gui/browser/FilePickerFragment.java    | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
index 12a1596..dc1a5f9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
@@ -34,12 +34,15 @@ import android.view.View;
 import org.videolan.libvlc.util.MediaBrowser;
 import org.videolan.vlc.R;
 import org.videolan.vlc.media.MediaWrapper;
+import org.videolan.vlc.util.AndroidDevices;
 import org.videolan.vlc.util.FileUtils;
 import org.videolan.vlc.util.Strings;
 import org.videolan.vlc.util.VLCInstance;
 
 public class FilePickerFragment extends FileBrowserFragment {
 
+    private static String[] rootDirectories = AndroidDevices.getMediaDirectories();
+
     @Override
     protected Fragment createFragment() {
         return new FilePickerFragment();
@@ -51,6 +54,7 @@ public class FilePickerFragment extends FileBrowserFragment {
     public void onCreate(Bundle bundle) {
         super.onCreate(bundle);
         mAdapter = new FilePickerAdapter(this);
+        mRoot = defineIsRoot();
     }
 
     @Override
@@ -86,6 +90,15 @@ public class FilePickerFragment extends FileBrowserFragment {
         }
     }
 
+    public boolean defineIsRoot() {
+        String path = Strings.removeFileProtocole(mMrl);
+        for (int i = 0; i < rootDirectories.length; ++i) {
+            if (TextUtils.equals(path, rootDirectories[i]))
+                return true;
+        }
+        return false;
+    }
+
     @Override
     protected int getLayoutId(){
         return R.layout.file_picker_fragment;



More information about the Android mailing list