[Android] Add subtitles sub folders in MediaInfo

Geoffrey Métais git at videolan.org
Mon Jan 12 12:27:42 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan 12 12:26:15 2015 +0100| [50690ffafd532f332ba045546c41e589874664f9] | committer: Geoffrey Métais

Add subtitles sub folders in MediaInfo

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=50690ffafd532f332ba045546c41e589874664f9
---

 .../src/org/videolan/vlc/gui/video/MediaInfoFragment.java |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
index d0b141f..f2d97ed 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -156,9 +156,20 @@ public class MediaInfoFragment extends ListFragment {
     };
 
     private void checkSubtitles(File itemFile) {
-        String extension, filename, videoName = Uri.decode(itemFile.getName());
+        String extension, filename, videoName = Uri.decode(itemFile.getName()), parentPath = Uri.decode(itemFile.getParent());
         videoName = videoName.substring(0, videoName.lastIndexOf('.'));
+        String[] subFolders = {"/Subtitles", "/subtitles", "/Subs", "/subs"};
         String[] files = itemFile.getParentFile().list();
+        for (int i = 0 ; i < subFolders.length ; ++i){
+            File subFolder = new File(parentPath+subFolders[i]);
+            if (!subFolder.exists())
+                continue;
+            String[] subFiles = subFolder.list();
+            String[] newFiles = new String[files.length+subFiles.length];
+            System.arraycopy(subFiles, 0, newFiles, 0, subFiles.length);
+            System.arraycopy(files, 0, newFiles, subFiles.length, files.length);
+            files = newFiles;
+        }
         for (int i = 0; i<files.length ; ++i){
             filename = Uri.decode(files[i]);
             extension = filename.substring(filename.lastIndexOf('.')+1);



More information about the Android mailing list