[Android] History: add network icon to network media
Duncan McNamara
git at videolan.org
Mon Dec 20 07:33:43 UTC 2021
vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Thu Dec 16 18:25:39 2021 +0100| [255521f981ee01e0126ecc06edd5e4d82f245dd3] | committer: Nicolas Pomepuy
History: add network icon to network media
> https://code.videolan.org/videolan/vlc-android/commit/255521f981ee01e0126ecc06edd5e4d82f245dd3
---
.../vlc-android/res/layout/history_item.xml | 21 ++++++++++++++++++++-
.../vlc-android/res/layout/history_item_card.xml | 22 +++++++++++++++++++++-
.../src/org/videolan/vlc/gui/HistoryAdapter.kt | 4 ++++
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/application/vlc-android/res/layout/history_item.xml b/application/vlc-android/res/layout/history_item.xml
index ba37600ba..df10ad42b 100644
--- a/application/vlc-android/res/layout/history_item.xml
+++ b/application/vlc-android/res/layout/history_item.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:vlc="http://schemas.android.com/apk/res-auto">
<data>
@@ -18,6 +19,10 @@
name="media"
type="org.videolan.medialibrary.interfaces.media.MediaWrapper" />
+ <variable
+ name="isNetwork"
+ type="boolean" />
+
<variable
name="cover"
type="android.graphics.drawable.BitmapDrawable" />
@@ -74,6 +79,20 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:media="@{media}" />
+
+ <ImageView
+ android:id="@+id/network_media"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="4dp"
+ android:layout_marginBottom="4dp"
+ android:background="@drawable/rounded_corners_black_more_transparent"
+ android:padding="3dp"
+ android:visibility="@{isNetwork && media.isPresent ? View.VISIBLE : View.GONE}"
+ vlc:layout_constraintBottom_toBottomOf="@+id/song_marker"
+ vlc:layout_constraintStart_toStartOf="@+id/song_marker"
+ vlc:layout_goneMarginBottom="4dp"
+ vlc:srcCompat="@drawable/ic_network_media" />
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/application/vlc-android/res/layout/history_item_card.xml b/application/vlc-android/res/layout/history_item_card.xml
index a3885b7ee..fa1f7627f 100644
--- a/application/vlc-android/res/layout/history_item_card.xml
+++ b/application/vlc-android/res/layout/history_item_card.xml
@@ -23,7 +23,8 @@
-->
<layout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:vlc="http://schemas.android.com/apk/res-auto">
<data>
@@ -45,6 +46,10 @@
name="cover"
type="android.graphics.drawable.BitmapDrawable" />
+ <variable
+ name="isNetwork"
+ type="boolean" />
+
<variable
name="bgColor"
type="int" />
@@ -95,6 +100,21 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:media="@{media}" />
+
+ <ImageView
+ android:id="@+id/network_media"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="4dp"
+ android:layout_marginBottom="4dp"
+ android:background="@drawable/rounded_corners_black_more_transparent"
+ android:padding="3dp"
+ android:visibility="@{isNetwork && media.isPresent ? View.VISIBLE : View.GONE}"
+ vlc:layout_constraintBottom_toBottomOf="@+id/song_marker"
+ vlc:layout_constraintStart_toStartOf="@+id/song_marker"
+ vlc:layout_goneMarginBottom="4dp"
+ vlc:srcCompat="@drawable/ic_network_media" />
+
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.kt
index a2c3772ac..b473efa76 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.kt
@@ -37,11 +37,13 @@ import org.videolan.tools.MultiSelectAdapter
import org.videolan.tools.MultiSelectHelper
import org.videolan.tools.Settings
import org.videolan.tools.safeOffer
+import org.videolan.vlc.BR
import org.videolan.vlc.databinding.HistoryItemBinding
import org.videolan.vlc.databinding.HistoryItemCardBinding
import org.videolan.vlc.gui.helpers.*
import org.videolan.vlc.interfaces.IListEventsHandler
import org.videolan.vlc.interfaces.SwipeDragHelperAdapter
+import org.videolan.vlc.util.isSchemeFile
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
@@ -113,11 +115,13 @@ class HistoryAdapter(private val inCards: Boolean = false, private val listEvent
when (holder.binding) {
is HistoryItemBinding -> {
(holder.binding as HistoryItemBinding).media = media
+ holder.binding.setVariable(BR.isNetwork, !media.uri.scheme.isSchemeFile())
(holder.binding as HistoryItemBinding).cover = getMediaIconDrawable(holder.itemView.context, media.type)
((holder.binding as HistoryItemBinding).icon.layoutParams as ConstraintLayout.LayoutParams).dimensionRatio = if (media.type == MediaWrapper.TYPE_VIDEO) "16:10" else "1"
}
is HistoryItemCardBinding -> {
(holder.binding as HistoryItemCardBinding).media = media
+ holder.binding.setVariable(BR.isNetwork, !media.uri.scheme.isSchemeFile())
(holder.binding as HistoryItemCardBinding).cover = getMediaIconDrawable(holder.itemView.context, media.type)
((holder.binding as HistoryItemCardBinding).icon.layoutParams as ConstraintLayout.LayoutParams).dimensionRatio = if (media.type == MediaWrapper.TYPE_VIDEO) "16:10" else "1"
}
More information about the Android
mailing list