[Android] Hide the history section if the playback history setting is unchecked

Nicolas Pomepuy git at videolan.org
Fri May 28 08:46:00 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu May 27 07:23:09 2021 +0200| [4f97794f1884857079b3bff436fa40bc470f234a] | committer: Nicolas Pomepuy

Hide the history section if the playback history setting is unchecked

Fixes #2035

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

 application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt       | 1 +
 .../vlc-android/src/org/videolan/vlc/viewmodels/HistoryModel.kt        | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt
index 34acc3081..26638729a 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/MoreFragment.kt
@@ -98,6 +98,7 @@ class MoreFragment : BaseFragment(), IRefreshable, IHistory, IDialogManager,
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
         super.onViewCreated(view, savedInstanceState)
         historyEntry = view.findViewById(R.id.history_entry)
+        if (!Settings.getInstance(requireActivity()).getBoolean(PLAYBACK_HISTORY, true)) historyEntry.setGone()
         viewModel = ViewModelProvider(requireActivity(), HistoryModel.Factory(requireContext())).get(HistoryModel::class.java)
         viewModel.dataset.observe(viewLifecycleOwner, { list ->
             list?.let {
diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/HistoryModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/HistoryModel.kt
index 3d49ea4e1..66627f266 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/HistoryModel.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/HistoryModel.kt
@@ -29,12 +29,15 @@ import kotlinx.coroutines.launch
 import kotlinx.coroutines.withContext
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.tools.CoroutineContextProvider
+import org.videolan.tools.PLAYBACK_HISTORY
+import org.videolan.tools.Settings
 
 class HistoryModel(context: Context, coroutineContextProvider: CoroutineContextProvider = CoroutineContextProvider()) : MedialibraryModel<MediaWrapper>(context, coroutineContextProvider) {
 
     override fun canSortByName() = false
 
     override suspend fun updateList() {
+        if (!Settings.getInstance(context).getBoolean(PLAYBACK_HISTORY, true)) return
         dataset.value = withContext(coroutineContextProvider.Default) { medialibrary.lastMediaPlayed().toMutableList() }
     }
 



More information about the Android mailing list