[Android] Allow clearing history in HistoryFragment

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:22:15 2021 +0200| [9f2131bca224982334cecb10e1d6d358f009ce51] | committer: Nicolas Pomepuy

Allow clearing history in HistoryFragment

Fixes #1787

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

 .../vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt   | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
index c75119e98..d439f1d82 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
@@ -35,10 +35,7 @@ import kotlinx.coroutines.ObsoleteCoroutinesApi
 import kotlinx.coroutines.flow.onEach
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.media.MediaLibraryItem
-import org.videolan.tools.KeyHelper
-import org.videolan.tools.MultiSelectHelper
-import org.videolan.tools.isStarted
-import org.videolan.tools.retrieveParent
+import org.videolan.tools.*
 import org.videolan.vlc.R
 import org.videolan.vlc.gui.browser.MediaBrowserFragment
 import org.videolan.vlc.gui.helpers.*
@@ -118,10 +115,16 @@ class HistoryFragment : MediaBrowserFragment<HistoryModel>(), IRefreshable, IHis
         cleanMenuItem.isVisible = !isEmpty()
     }
 
+    override fun onPrepareOptionsMenu(menu: Menu) {
+        menu.findItem(R.id.ml_menu_clean).isVisible = Settings.getInstance(requireActivity()).getBoolean(PLAYBACK_HISTORY, true)
+        super.onPrepareOptionsMenu(menu)
+    }
+
     override fun onOptionsItemSelected(item: MenuItem): Boolean {
         return when (item.itemId) {
             R.id.ml_menu_clean -> {
                 clearHistory()
+                requireActivity().finish()
                 true
             }
             else -> super.onOptionsItemSelected(item)



More information about the Android mailing list