[Android] Prevent displaying progress/played in the file browser when history is off

Nicolas Pomepuy git at videolan.org
Wed Mar 20 14:10:02 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Mar 11 14:20:29 2024 +0100| [fa358c9dfe23b2f29ff2d937c98d18e10c0cbea2] | committer: Duncan McNamara

Prevent displaying progress/played in the file browser when history is off

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

 .../src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt     |  4 ++--
 .../videolan/vlc/gui/browser/BrowserItemBindingContainer.kt    | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt
index 4e833be64f..e585d0f9b6 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt
@@ -159,8 +159,8 @@ open class BaseBrowserAdapter(val browserContainer: BrowserContainer<MediaLibrar
         val isFavorite = media.hasStateFlags(MediaLibraryItem.FLAG_FAVORITE)
         val max = (media.length / 1000).toInt()
         val progress = (media.displayTime / 1000).toInt()
-        vh.bindingContainer.setProgress(progress, max)
-        vh.bindingContainer.setIsPlayed(media.playCount > 0)
+        vh.bindingContainer.setProgress(vh.bindingContainer.container.context, progress, max)
+        vh.bindingContainer.setIsPlayed(vh.bindingContainer.container.context, media.playCount > 0)
         vh.bindingContainer.setItem(media)
         vh.bindingContainer.setIsFavorite(isFavorite)
         val scheme = media.uri?.scheme ?: ""
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserItemBindingContainer.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserItemBindingContainer.kt
index e5a45b3702..d2ebd30390 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserItemBindingContainer.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserItemBindingContainer.kt
@@ -24,12 +24,15 @@
 
 package org.videolan.vlc.gui.browser
 
+import android.content.Context
 import android.graphics.drawable.BitmapDrawable
 import android.view.View
 import android.widget.ImageView
 import android.widget.TextView
 import androidx.databinding.ViewDataBinding
 import org.videolan.medialibrary.media.MediaLibraryItem
+import org.videolan.tools.PLAYBACK_HISTORY
+import org.videolan.tools.Settings
 import org.videolan.vlc.databinding.BrowserItemBinding
 import org.videolan.vlc.databinding.CardBrowserItemBinding
 import org.videolan.vlc.gui.helpers.ThreeStatesCheckbox
@@ -106,20 +109,23 @@ class BrowserItemBindingContainer(val binding: ViewDataBinding) {
         }
     }
 
-    fun setIsPlayed(played:Boolean) {
+    fun setIsPlayed(context: Context, played:Boolean) {
+        if (!Settings.getInstance(context).getBoolean(PLAYBACK_HISTORY, true)) return
         when (binding) {
             is CardBrowserItemBinding -> {}
             is BrowserItemBinding -> binding.played = played
             else -> throw IllegalStateException("Binding should be either a CardBrowserItemBinding or BrowserItemBinding")
         }
     }
-    fun setProgress(progress:Int, max: Int) {
+    fun setProgress(context: Context, progress: Int, max: Int) {
+        if (!Settings.getInstance(context).getBoolean(PLAYBACK_HISTORY, true)) return
         when (binding) {
             is CardBrowserItemBinding -> {}
             is BrowserItemBinding -> {
                 binding.progress = progress
                 binding.max = max
             }
+
             else -> throw IllegalStateException("Binding should be either a CardBrowserItemBinding or BrowserItemBinding")
         }
     }



More information about the Android mailing list