[Android] Use icons instead of gesture for audio play queue on large screens

Nicolas Pomepuy git at videolan.org
Thu Dec 23 09:45:07 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Dec  7 07:05:25 2021 +0100| [827271ce8f5b027e6a88b01160ef84117c21139a] | committer: Nicolas Pomepuy

Use icons instead of gesture for audio play queue on large screens

Relates to #2258

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

 .../src/main/res/drawable/ic_playlist_delete.xml   | 11 +++++
 .../src/main/res/drawable/ic_playlist_movedown.xml | 18 +++++++
 .../src/main/res/drawable/ic_playlist_moveup.xml   | 18 +++++++
 .../vlc-android/res/layout/playlist_item.xml       | 56 +++++++++++++++++++++-
 .../org/videolan/vlc/gui/audio/PlaylistAdapter.kt  | 25 ++++++++--
 5 files changed, 124 insertions(+), 4 deletions(-)

diff --git a/application/resources/src/main/res/drawable/ic_playlist_delete.xml b/application/resources/src/main/res/drawable/ic_playlist_delete.xml
new file mode 100644
index 000000000..87500942b
--- /dev/null
+++ b/application/resources/src/main/res/drawable/ic_playlist_delete.xml
@@ -0,0 +1,11 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:tools="http://schemas.android.com/tools"
+        android:width="32dp"
+        android:height="32dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+    <path
+            android:fillColor="?attr/colorControlNormal"
+            tools:fillColor="@color/white"
+            android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
+</vector>
diff --git a/application/resources/src/main/res/drawable/ic_playlist_movedown.xml b/application/resources/src/main/res/drawable/ic_playlist_movedown.xml
new file mode 100644
index 000000000..cea7e32ba
--- /dev/null
+++ b/application/resources/src/main/res/drawable/ic_playlist_movedown.xml
@@ -0,0 +1,18 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:tools="http://schemas.android.com/tools"
+        android:width="32dp"
+        android:height="32dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+    <path
+            tools:fillColor="@color/white"
+            android:fillAlpha="1"
+            android:fillColor="?attr/colorControlNormal"
+            android:fillType="nonZero"
+            android:pathData="m12,17a1,1 0,0 1,-0.707 -0.293l-6.9902,-6.9902 -0.01,-0.01a1,1 0,0 1,-0.293 -0.707,1 1,0 0,1 1,-1 1,1 0,0 1,0.707 0.293l6.293,6.2929 6.2832,-6.2832a1,1 0,0 1,0.7168 -0.3027,1 1,0 0,1 1,1 1,1 0,0 1,-0.293 0.707l-6.9902,6.9903A1,1 0,0 1,12 17Z"
+            android:strokeWidth="2"
+            android:strokeAlpha="1"
+            android:strokeColor="#00000000"
+            android:strokeLineCap="round"
+            android:strokeLineJoin="round" />
+</vector>
diff --git a/application/resources/src/main/res/drawable/ic_playlist_moveup.xml b/application/resources/src/main/res/drawable/ic_playlist_moveup.xml
new file mode 100644
index 000000000..4e371fe46
--- /dev/null
+++ b/application/resources/src/main/res/drawable/ic_playlist_moveup.xml
@@ -0,0 +1,18 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:tools="http://schemas.android.com/tools"
+        android:width="32dp"
+        android:height="32dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+    <path
+            tools:fillColor="@color/white"
+            android:fillAlpha="1"
+            android:fillColor="?attr/colorControlNormal"
+            android:fillType="nonZero"
+            android:pathData="m12,7a1,1 0,0 0,-0.707 0.293l-6.9902,6.9902 -0.01,0.01a1,1 0,0 0,-0.293 0.707,1 1,0 0,0 1,1 1,1 0,0 0,0.707 -0.293l6.293,-6.2929 6.2832,6.2832a1,1 0,0 0,0.7168 0.3027,1 1,0 0,0 1,-1 1,1 0,0 0,-0.293 -0.707l-6.9902,-6.9903A1,1 0,0 0,12 7Z"
+            android:strokeWidth="2"
+            android:strokeAlpha="1"
+            android:strokeColor="#00000000"
+            android:strokeLineCap="round"
+            android:strokeLineJoin="round" />
+</vector>
diff --git a/application/vlc-android/res/layout/playlist_item.xml b/application/vlc-android/res/layout/playlist_item.xml
index 82554ebca..1510f4812 100644
--- a/application/vlc-android/res/layout/playlist_item.xml
+++ b/application/vlc-android/res/layout/playlist_item.xml
@@ -60,7 +60,7 @@
                 android:paddingTop="4dp"
                 android:paddingBottom="4dp"
                 app:layout_constraintBottom_toBottomOf="parent"
-                app:layout_constraintEnd_toStartOf="@+id/item_more"
+                app:layout_constraintEnd_toStartOf="@+id/item_move_up"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toTopOf="parent" />
 
@@ -159,6 +159,60 @@
                 app:layout_constraintTop_toTopOf="parent"
                 app:srcCompat="@drawable/ic_more" />
 
+        <androidx.appcompat.widget.AppCompatImageView
+                android:id="@+id/item_delete"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentEnd="true"
+                android:layout_centerVertical="true"
+                android:layout_gravity="center"
+                android:layout_marginEnd="8dp"
+                android:background="?attr/selectableItemBackgroundBorderless"
+                android:clickable="true"
+                android:focusable="true"
+                android:onClick="@{holder::onDeleteClick}"
+                android:scaleType="center"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toStartOf="@+id/item_more"
+                app:layout_constraintTop_toTopOf="parent"
+                app:srcCompat="@drawable/ic_playlist_delete" />
+
+        <androidx.appcompat.widget.AppCompatImageView
+                android:id="@+id/item_move_down"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentEnd="true"
+                android:layout_centerVertical="true"
+                android:layout_gravity="center"
+                android:layout_marginEnd="8dp"
+                android:background="?attr/selectableItemBackgroundBorderless"
+                android:clickable="true"
+                android:focusable="true"
+                android:onClick="@{holder::onMoveDownClick}"
+                android:scaleType="center"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toStartOf="@+id/item_delete"
+                app:layout_constraintTop_toTopOf="parent"
+                app:srcCompat="@drawable/ic_playlist_movedown" />
+
+        <androidx.appcompat.widget.AppCompatImageView
+                android:id="@+id/item_move_up"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentEnd="true"
+                android:layout_centerVertical="true"
+                android:layout_gravity="center"
+                android:layout_marginEnd="8dp"
+                android:background="?attr/selectableItemBackgroundBorderless"
+                android:clickable="true"
+                android:focusable="true"
+                android:onClick="@{holder::onMoveUpClick}"
+                android:scaleType="center"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toStartOf="@+id/item_move_down"
+                app:layout_constraintTop_toTopOf="parent"
+                app:srcCompat="@drawable/ic_playlist_moveup" />
+
         <View
                 android:id="@+id/tips_overlay"
                 android:layout_width="0dp"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
index e66b21be7..5bdd10aec 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
@@ -47,11 +47,14 @@ import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.resources.AppContextProvider
 import org.videolan.tools.Settings
 import org.videolan.tools.WeakHandler
+import org.videolan.tools.setGone
+import org.videolan.tools.setVisible
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.PlaylistItemBinding
 import org.videolan.vlc.gui.DiffUtilAdapter
 import org.videolan.vlc.gui.helpers.MarqueeViewHolder
 import org.videolan.vlc.gui.helpers.UiTools
+import org.videolan.vlc.gui.helpers.UiTools.isTablet
 import org.videolan.vlc.gui.helpers.enableMarqueeEffect
 import org.videolan.vlc.gui.helpers.getBitmapFromDrawable
 import org.videolan.vlc.gui.view.MiniVisualizer
@@ -138,6 +141,11 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<MediaWrappe
             holder.binding.cover = defaultCoverAudio
         }
 
+        val tablet = holder.binding.itemDelete.context.isTablet()
+        if (tablet) holder.binding.itemDelete.setVisible() else holder.binding.itemDelete.setGone()
+        if (tablet) holder.binding.itemMoveDown.setVisible() else holder.binding.itemMoveDown.setGone()
+        if (tablet) holder.binding.itemMoveUp.setVisible() else holder.binding.itemMoveUp.setGone()
+
         holder.binding.executePendingBindings()
     }
 
@@ -214,12 +222,23 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<MediaWrappe
             val position = layoutPosition
             player.onPopupMenu(v, position, getItem(position))
         }
+
+        fun onDeleteClick(v: View) {
+            onItemDismiss(layoutPosition)
+        }
+        fun onMoveUpClick(v: View) {
+            if (layoutPosition != 0) onItemMove(layoutPosition, layoutPosition - 1)
+        }
+
+        fun onMoveDownClick(v: View) {
+            if (layoutPosition != itemCount - 1) onItemMove(layoutPosition, layoutPosition + 1)
+        }
     }
 
-    private class PlaylistHandler internal constructor(owner: PlaylistAdapter) : WeakHandler<PlaylistAdapter>(owner) {
+    private class PlaylistHandler(owner: PlaylistAdapter) : WeakHandler<PlaylistAdapter>(owner) {
 
-        internal var from = -1
-        internal var to = -1
+        var from = -1
+        var to = -1
 
         override fun handleMessage(msg: Message) {
             when (msg.what) {



More information about the Android mailing list