[Android] Add up and down action mode playlist actions

Alexandre Perraud git at videolan.org
Fri Jul 28 16:25:08 CEST 2017


vlc-android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Fri Jul 21 15:31:43 2017 +0200| [543efe4ee15ff4e42d3b0124e07c52b51e166e55] | committer: Alexandre Perraud

Add up and down action mode playlist actions

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

 vlc-android/res/menu/action_mode_audio_browser.xml       | 12 ++++++++++++
 .../src/org/videolan/vlc/gui/PlaylistActivity.java       | 16 +++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/vlc-android/res/menu/action_mode_audio_browser.xml b/vlc-android/res/menu/action_mode_audio_browser.xml
index d4b8b8f1e..100091cef 100644
--- a/vlc-android/res/menu/action_mode_audio_browser.xml
+++ b/vlc-android/res/menu/action_mode_audio_browser.xml
@@ -2,6 +2,18 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto">
     <item
+        android:id="@+id/action_mode_audio_playlist_up"
+        android:title="@string/info"
+        android:icon="@drawable/ic_am_playlist_up_w"
+        android:visible="false"
+        app:showAsAction="always"/>
+    <item
+        android:id="@+id/action_mode_audio_playlist_down"
+        android:title="@string/info"
+        android:icon="@drawable/ic_am_playlist_down_w"
+        android:visible="false"
+        app:showAsAction="always"/>
+    <item
         android:id="@+id/action_mode_audio_info"
         android:title="@string/info"
         android:icon="@drawable/ic_am_information_w"
diff --git a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
index 29f78789c..a77c141d6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
@@ -45,6 +45,7 @@ import android.view.Gravity;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
+import android.widget.Toast;
 
 import org.videolan.medialibrary.Medialibrary;
 import org.videolan.medialibrary.media.MediaLibraryItem;
@@ -243,7 +244,9 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
             return false;
         }
         boolean isSong = count == 1 && mAdapter.getSelection().get(0).getItemType() == MediaLibraryItem.TYPE_MEDIA;
-        menu.findItem(R.id.action_mode_audio_set_song).setVisible(isSong && AndroidDevices.isPhone());
+        menu.findItem(R.id.action_mode_audio_playlist_up).setVisible(isSong && mIsPlaylist);
+        menu.findItem(R.id.action_mode_audio_playlist_down).setVisible(isSong && mIsPlaylist);
+        menu.findItem(R.id.action_mode_audio_set_song).setVisible(isSong && AndroidDevices.isPhone() && !mIsPlaylist);
         menu.findItem(R.id.action_mode_audio_info).setVisible(isSong);
         menu.findItem(R.id.action_mode_audio_append).setVisible(mService.hasMedia());
         menu.findItem(R.id.action_mode_audio_delete).setVisible(mIsPlaylist);
@@ -256,6 +259,17 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
         ArrayList<MediaWrapper> tracks = new ArrayList<>();
         for (MediaLibraryItem mediaItem : list)
             tracks.addAll(Arrays.asList(mediaItem.getTracks()));
+
+        if (item.getItemId() == R.id.action_mode_audio_playlist_up) {
+            Toast.makeText(this, "UP !",
+                    Toast.LENGTH_SHORT).show();
+            return true;
+        }
+        if (item.getItemId() == R.id.action_mode_audio_playlist_down) {
+            Toast.makeText(this, "DOWN !",
+                    Toast.LENGTH_SHORT).show();
+            return true;
+        }
         stopActionMode();
         switch (item.getItemId()) {
             case R.id.action_mode_audio_play:



More information about the Android mailing list