[Android] Add context menu option to get subtitles

Geoffrey Métais git at videolan.org
Fri Apr 15 12:01:10 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 14 12:51:49 2016 +0200| [7e84517507514a3289defff3d3cc9a88fd7c0196] | committer: Geoffrey Métais

Add context menu option to get subtitles

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

 vlc-android/res/menu/video_list.xml                            |  3 +++
 .../src/org/videolan/vlc/gui/video/VideoGridFragment.java      | 10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/vlc-android/res/menu/video_list.xml b/vlc-android/res/menu/video_list.xml
index ca9a159..b1586b8 100644
--- a/vlc-android/res/menu/video_list.xml
+++ b/vlc-android/res/menu/video_list.xml
@@ -19,4 +19,7 @@
     <item
         android:id="@+id/video_list_delete"
         android:title="@string/delete" />
+    <item
+        android:id="@+id/video_download_subtitles"
+        android:title="@string/download_subtitles" />
 </menu>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index 9cf6b83..6ece222 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -321,11 +321,16 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
                 return true;
             case R.id.video_group_play:
                 MediaUtils.openList(getActivity(), ((MediaGroup) media).getAll(), 0);
+                return true;
             case R.id.video_list_append:
                 if (media instanceof MediaGroup)
                     mService.append(((MediaGroup)media).getAll());
                 else
                     mService.append(media);
+                return true;
+            case R.id.video_download_subtitles:
+                MediaUtils.getSubs(getActivity(), media);
+                return true;
         }
         return false;
     }
@@ -358,12 +363,13 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
         boolean hasInfo = false;
         final Media media = new Media(VLCInstance.get(), mediaWrapper.getUri());
         media.parse();
+        boolean canWrite = FileUtils.canWrite(mediaWrapper.getLocation());
         if (media.getMeta(Media.Meta.Title) != null)
             hasInfo = true;
         media.release();
         menu.findItem(R.id.video_list_info).setVisible(hasInfo);
-        menu.findItem(R.id.video_list_delete).setVisible(
-                FileUtils.canWrite(mediaWrapper.getLocation()));
+        menu.findItem(R.id.video_list_delete).setVisible(canWrite);
+        menu.findItem(R.id.video_download_subtitles).setVisible(canWrite);
         if (!AndroidUtil.isHoneycombOrLater()) {
             menu.findItem(R.id.video_list_play_all).setVisible(false);
             menu.findItem(R.id.video_list_append).setVisible(false);



More information about the Android mailing list