[Android] Fix Play / Play all ctx actions on videos and groups

Nicolas Pomepuy git at videolan.org
Mon Nov 23 13:32:28 CET 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Nov 16 14:10:23 2020 +0100| [2d80384984b0289e823c8d02a1b051b019e38183] | committer: Nicolas Pomepuy

Fix Play / Play all ctx actions on videos and groups

Fixes #1537

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

 .../resources/src/main/java/org/videolan/resources/Constants.kt   | 2 +-
 .../src/org/videolan/vlc/gui/video/VideoGridFragment.kt           | 8 +++++---
 .../src/org/videolan/vlc/viewmodels/mobile/VideosViewModel.kt     | 4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/application/resources/src/main/java/org/videolan/resources/Constants.kt b/application/resources/src/main/java/org/videolan/resources/Constants.kt
index 65f2a8d7c..1c4aa7d1c 100644
--- a/application/resources/src/main/java/org/videolan/resources/Constants.kt
+++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt
@@ -209,7 +209,7 @@ const val CTX_GROUP_SIMILAR = 1L shl 35
 const val CTX_MARK_AS_PLAYED = 1L shl 36
 const val CTX_MARK_ALL_AS_PLAYED = 1L shl 37
 
-const val CTX_VIDEO_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_DELETE or CTX_DOWNLOAD_SUBTITLES or CTX_INFORMATION or CTX_PLAY_ALL or CTX_PLAY_AS_AUDIO or CTX_ADD_TO_PLAYLIST or CTX_SHARE or CTX_MARK_AS_PLAYED
+const val CTX_VIDEO_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_DELETE or CTX_DOWNLOAD_SUBTITLES or CTX_INFORMATION or CTX_PLAY or CTX_PLAY_ALL or CTX_PLAY_AS_AUDIO or CTX_ADD_TO_PLAYLIST or CTX_SHARE or CTX_MARK_AS_PLAYED
 const val CTX_TRACK_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_DELETE or CTX_INFORMATION or CTX_PLAY_ALL or CTX_ADD_TO_PLAYLIST or CTX_SET_RINGTONE or CTX_SHARE
 const val CTX_AUDIO_FLAGS = CTX_PLAY or CTX_APPEND or CTX_PLAY_NEXT or CTX_ADD_TO_PLAYLIST or CTX_INFORMATION
 const val CTX_PLAYLIST_ALBUM_FLAGS = CTX_AUDIO_FLAGS or CTX_DELETE
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index 272082ffd..54100f619 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -60,6 +60,7 @@ import org.videolan.vlc.gui.view.EmptyLoadingState
 import org.videolan.vlc.media.MediaUtils
 import org.videolan.vlc.media.PlaylistManager
 import org.videolan.vlc.media.getAll
+import org.videolan.vlc.providers.medialibrary.MedialibraryProvider
 import org.videolan.vlc.providers.medialibrary.VideosProvider
 import org.videolan.vlc.reloadLibrary
 import org.videolan.vlc.util.launchWhenStarted
@@ -421,9 +422,10 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
         val activity = activity ?: return
         when (val media = videoListAdapter.getItem(position)) {
             is MediaWrapper -> when (option) {
-                CTX_PLAY_FROM_START -> viewModel.playVideo(activity, media, position, true)
+                CTX_PLAY_FROM_START -> viewModel.playVideo(activity, media, position, fromStart = true)
                 CTX_PLAY_AS_AUDIO -> viewModel.playAudio(activity, media)
-                CTX_PLAY_ALL -> viewModel.play(position)
+                CTX_PLAY_ALL -> viewModel.playVideo(activity, media, position, forceAll = true)
+                CTX_PLAY -> viewModel.play(position)
                 CTX_INFORMATION -> showInfoDialog(media)
                 CTX_DELETE -> removeItem(media)
                 CTX_APPEND -> MediaUtils.appendMedia(activity, media)
@@ -493,7 +495,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
             is VideoCtxClick -> {
                 when (item) {
                     is Folder -> showContext(requireActivity(), this at VideoGridFragment, position, item.title, CTX_FOLDER_FLAGS)
-                    is VideoGroup -> showContext(requireActivity(), this at VideoGridFragment, position, item.title, CTX_FOLDER_FLAGS or CTX_RENAME_GROUP or CTX_UNGROUP or CTX_PLAY_ALL)
+                    is VideoGroup -> showContext(requireActivity(), this at VideoGridFragment, position, item.title, CTX_FOLDER_FLAGS or CTX_RENAME_GROUP or CTX_UNGROUP or CTX_PLAY_ALL and CTX_PLAY.inv())
                     is MediaWrapper -> {
                         val group = item.type == MediaWrapper.TYPE_GROUP
                         var flags = if (group) CTX_VIDEO_GROUP_FLAGS else CTX_VIDEO_FLAGS
diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/mobile/VideosViewModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/mobile/VideosViewModel.kt
index e8bb570fa..7923c4c7a 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/mobile/VideosViewModel.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/mobile/VideosViewModel.kt
@@ -127,11 +127,11 @@ class VideosViewModel(context: Context, type: VideoGroupingType, val folder: Fol
         MediaUtils.appendMedia(context, list)
     }
 
-    internal fun playVideo(context: Activity?, mw: MediaWrapper, position: Int, fromStart: Boolean = false) {
+    internal fun playVideo(context: Activity?, mw: MediaWrapper, position: Int, fromStart: Boolean = false, forceAll:Boolean = false) {
         if (context === null) return
         mw.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO)
         val settings = Settings.getInstance(context)
-        if (settings.getBoolean(FORCE_PLAY_ALL, false)) {
+        if (!fromStart && (settings.getBoolean(FORCE_PLAY_ALL, false) || forceAll)) {
             when(val prov = provider) {
                 is VideosProvider -> MediaUtils.playAll(context, prov, position, false)
                 is FoldersProvider -> MediaUtils.playAllTracks(context, prov, position, false)



More information about the Android mailing list