[Android] Add the favorite emoji to the audio items

Nicolas Pomepuy git at videolan.org
Fri Nov 18 12:29:45 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Nov  2 08:55:44 2022 +0100| [16a89d1b34c3b98f05e79af491f2bc70539e5af3] | committer: Nicolas Pomepuy

Add the favorite emoji to the audio items

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

 .../res/layout/audio_browser_card_item.xml         | 25 +++++++++++++---
 .../vlc-android/res/layout/audio_browser_item.xml  | 33 +++++++++++++++++++++-
 .../videolan/vlc/gui/audio/AudioBrowserAdapter.kt  |  7 +++++
 3 files changed, 60 insertions(+), 5 deletions(-)

diff --git a/application/vlc-android/res/layout/audio_browser_card_item.xml b/application/vlc-android/res/layout/audio_browser_card_item.xml
index 58d70d38ad..694eccf58c 100644
--- a/application/vlc-android/res/layout/audio_browser_card_item.xml
+++ b/application/vlc-android/res/layout/audio_browser_card_item.xml
@@ -52,6 +52,10 @@
                 name="isPresent"
                 type="boolean" />
 
+        <variable
+                name="isFavorite"
+                type="boolean" />
+
         <variable
                 name="inSelection"
                 type="boolean" />
@@ -156,7 +160,7 @@
                         android:padding="3dp"
                         android:visibility="@{isSD ? View.VISIBLE : View.GONE}"
                         vlc:layout_constraintBottom_toBottomOf="parent"
-                        vlc:layout_constraintStart_toStartOf="parent"
+                        vlc:layout_constraintStart_toEndOf="@+id/media_favorite"
                         vlc:srcCompat="@drawable/ic_emoji_sd" />
                 <ImageView
                         android:id="@+id/otg_media"
@@ -168,7 +172,7 @@
                         android:padding="3dp"
                         android:visibility="@{isOTG ? View.VISIBLE : View.GONE}"
                         vlc:layout_constraintBottom_toBottomOf="parent"
-                        vlc:layout_constraintStart_toStartOf="parent"
+                        vlc:layout_constraintStart_toEndOf="@+id/media_favorite"
                         vlc:srcCompat="@drawable/ic_emoji_otg" />
 
                 <ImageView
@@ -181,7 +185,7 @@
                         android:padding="3dp"
                         android:visibility="@{isNetwork ? View.VISIBLE : View.GONE}"
                         vlc:layout_constraintBottom_toBottomOf="parent"
-                        vlc:layout_constraintStart_toStartOf="parent"
+                        vlc:layout_constraintStart_toEndOf="@+id/media_favorite"
                         vlc:srcCompat="@drawable/ic_emoji_network" />
 
                 <ImageView
@@ -194,9 +198,22 @@
                         android:padding="3dp"
                         android:visibility="@{!isPresent ? View.VISIBLE : View.GONE}"
                         vlc:layout_constraintBottom_toBottomOf="parent"
-                        vlc:layout_constraintStart_toStartOf="parent"
+                        vlc:layout_constraintStart_toEndOf="@+id/media_favorite"
                         vlc:srcCompat="@drawable/ic_emoji_absent" />
 
+                <ImageView
+                        android:id="@+id/media_favorite"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginStart="8dp"
+                        android:layout_marginBottom="8dp"
+                        android:background="@drawable/rounded_corners_black_more_transparent"
+                        android:padding="3dp"
+                        android:visibility="@{isFavorite ? View.VISIBLE : View.GONE}"
+                        vlc:layout_constraintBottom_toBottomOf="parent"
+                        vlc:layout_constraintStart_toStartOf="parent"
+                        vlc:srcCompat="@drawable/ic_emoji_favorite" />
+
             </androidx.constraintlayout.widget.ConstraintLayout>
 
 
diff --git a/application/vlc-android/res/layout/audio_browser_item.xml b/application/vlc-android/res/layout/audio_browser_item.xml
index e408d9d59d..131cc63415 100644
--- a/application/vlc-android/res/layout/audio_browser_item.xml
+++ b/application/vlc-android/res/layout/audio_browser_item.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:tools="http://schemas.android.com/tools"
         xmlns:vlc="http://schemas.android.com/apk/res-auto">
 
     <data>
@@ -43,6 +44,10 @@
                 name="isPresent"
                 type="boolean" />
 
+        <variable
+                name="isFavorite"
+                type="boolean" />
+
         <variable
                 name="inSelection"
                 type="boolean" />
@@ -174,6 +179,30 @@
                 vlc:layout_constraintEnd_toEndOf="@+id/selector_image"
                 vlc:layout_constraintTop_toTopOf="@+id/selector_image"
                 vlc:srcCompat="@drawable/ic_emoji_absent" />
+        <ImageView
+                android:id="@+id/media_favorite"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:padding="3dp"
+                vlc:tint="@color/list_subtitle"
+                android:visibility="@{isFavorite ? View.VISIBLE : View.GONE}"
+                vlc:layout_constraintBottom_toBottomOf="parent"
+                vlc:layout_constraintEnd_toStartOf="@id/item_more"
+                vlc:layout_constraintTop_toTopOf="parent"
+                vlc:srcCompat="@drawable/ic_emoji_favorite" />
+
+<!--        <ImageView-->
+<!--                android:id="@+id/favorite"-->
+<!--                android:layout_width="wrap_content"-->
+<!--                android:layout_height="wrap_content"-->
+<!--                android:layout_marginStart="4dp"-->
+<!--                android:layout_marginTop="4dp"-->
+<!--                android:background="@drawable/rounded_corners_black_more_transparent"-->
+<!--                android:padding="3dp"-->
+<!--                android:visibility="@{isFavorite ? View.VISIBLE : View.GONE}"-->
+<!--                vlc:layout_constraintStart_toStartOf="@+id/media_cover"-->
+<!--                vlc:layout_constraintTop_toTopOf="@+id/selector_image"-->
+<!--                vlc:srcCompat="@drawable/ic_emoji_favorite" />-->
 
         <ImageView
                 android:id="@+id/selector_image"
@@ -197,13 +226,14 @@
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"
                 android:layout_marginStart="@dimen/default_margin"
+                android:layout_marginEnd="16dp"
                 android:ellipsize="end"
                 android:gravity="center_vertical"
                 android:maxLines="2"
                 android:singleLine="false"
                 vlc:asyncText="@{item.title}"
                 vlc:layout_constraintBottom_toTopOf="@+id/subtitle"
-                vlc:layout_constraintEnd_toStartOf="@+id/item_more"
+                vlc:layout_constraintEnd_toStartOf="@+id/media_favorite"
                 vlc:layout_constraintStart_toEndOf="@+id/media_cover"
                 vlc:layout_constraintTop_toTopOf="parent"
                 vlc:layout_constraintVertical_chainStyle="packed"
@@ -244,6 +274,7 @@
                 android:layout_height="wrap_content"
                 android:layout_marginEnd="4dp"
                 android:visibility="@{selected ? View.VISIBLE : View.GONE}"
+                tools:visibility="visible"
                 vlc:layout_constraintBottom_toBottomOf="parent"
                 vlc:layout_constraintEnd_toEndOf="parent"
                 vlc:layout_constraintTop_toTopOf="parent"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt
index ab2c8ec4ce..c032410eef 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt
@@ -43,6 +43,7 @@ import androidx.paging.PagedListAdapter
 import androidx.recyclerview.widget.DiffUtil
 import androidx.recyclerview.widget.RecyclerView
 import org.videolan.libvlc.util.AndroidUtil
+import org.videolan.medialibrary.interfaces.media.Album
 import org.videolan.medialibrary.interfaces.media.Artist
 import org.videolan.medialibrary.interfaces.media.Genre
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
@@ -149,6 +150,12 @@ open class AudioBrowserAdapter @JvmOverloads constructor(
             holder.binding.setVariable(BR.isSD, item.uri.isSD())
             holder.binding.setVariable(BR.isPresent, item.isPresent)
         } else holder.binding.setVariable(BR.isPresent, true)
+        when (item) {
+            is MediaWrapper -> holder.binding.setVariable(BR.isFavorite, item.isFavorite)
+            is Album -> holder.binding.setVariable(BR.isFavorite, item.isFavorite)
+            is Artist -> holder.binding.setVariable(BR.isFavorite, item.isFavorite)
+            is Genre -> holder.binding.setVariable(BR.isFavorite, item.isFavorite)
+        }
         holder.binding.setVariable(BR.inSelection,multiSelectHelper.inActionMode)
         holder.binding.invalidateAll()
         holder.binding.executePendingBindings()



More information about the Android mailing list