[Android] Add "Append to playlist" feature for file browsers

Geoffrey Métais git at videolan.org
Tue Mar 15 15:48:21 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar 15 15:47:45 2016 +0100| [f9bef600ecc1de26ff75120f59df0182d20d13ca] | committer: Geoffrey Métais

Add "Append to playlist" feature for file browsers

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

 vlc-android/res/menu/directory_view_file.xml             |  3 +++
 .../videolan/vlc/gui/browser/BaseBrowserFragment.java    | 16 ++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/vlc-android/res/menu/directory_view_file.xml b/vlc-android/res/menu/directory_view_file.xml
index da61406..5161174 100644
--- a/vlc-android/res/menu/directory_view_file.xml
+++ b/vlc-android/res/menu/directory_view_file.xml
@@ -15,4 +15,7 @@
     <item
         android:id="@+id/directory_view_info"
         android:title="@string/info" />
+    <item
+        android:id="@+id/directory_view_add_playlist"
+        android:title="@string/add_to_playlist" />
 </menu>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index d4ac339..a51bd5d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -30,6 +30,7 @@ import android.os.Bundle;
 import android.os.Message;
 import android.support.design.widget.FloatingActionButton;
 import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentTransaction;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
@@ -51,6 +52,7 @@ import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.MainActivity;
 import org.videolan.vlc.gui.SecondaryActivity;
+import org.videolan.vlc.gui.dialogs.SavePlaylistDialog;
 import org.videolan.vlc.gui.helpers.UiTools;
 import org.videolan.vlc.gui.view.ContextMenuRecyclerView;
 import org.videolan.vlc.gui.view.DividerItemDecoration;
@@ -424,6 +426,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
             menu.findItem(R.id.directory_view_delete).setVisible(canWrite);
             menu.findItem(R.id.directory_view_info).setVisible(type == MediaWrapper.TYPE_VIDEO || type == MediaWrapper.TYPE_AUDIO);
             menu.findItem(R.id.directory_view_play_audio).setVisible(type != MediaWrapper.TYPE_AUDIO);
+            menu.findItem(R.id.directory_view_add_playlist).setVisible(type == MediaWrapper.TYPE_AUDIO);
         }
     }
 
@@ -476,13 +479,12 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
                 i.putExtra("param", mw.getUri().toString());
                 getActivity().startActivityForResult(i, MainActivity.ACTIVITY_RESULT_SECONDARY);
                 return true;
-            case R.id.directory_view_play_audio: {
+            case R.id.directory_view_play_audio:
                 if (mService != null) {
                     mw.addFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
                     mService.load(mw);
                 }
                 return true;
-            }
             case R.id.directory_view_play_folder:
                 ArrayList<MediaWrapper> mediaList = new ArrayList<MediaWrapper>();
                 boolean videoPlaylist = AndroidUtil.isHoneycombOrLater();
@@ -492,6 +494,16 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
                 }
                 MediaUtils.openList(getActivity(), mediaList, 0);
                 return true;
+            case R.id.directory_view_add_playlist:
+                ArrayList<MediaWrapper> medias = new ArrayList<>();
+                medias.add(mw);
+                FragmentManager fm = getActivity().getSupportFragmentManager();
+                SavePlaylistDialog savePlaylistDialog = new SavePlaylistDialog();
+                Bundle args = new Bundle();
+                args.putParcelableArrayList(SavePlaylistDialog.KEY_NEW_TRACKS, medias);
+                savePlaylistDialog.setArguments(args);
+                savePlaylistDialog.show(fm, "fragment_add_to_playlist");
+                return true;
 //            case R.id.directory_view_hide_media:
 //                try {
 //                    if (new File(mw.getLocation()+"/.nomedia").createNewFile())



More information about the Android mailing list