Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
531
Issue boards
Milestones
Wiki
Code
Merge requests
15
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
bb8e00de
Commit
bb8e00de
authored
5 years ago
by
Nicolas Pomepuy
Browse files
Options
Downloads
Patches
Plain Diff
Use media ctx for groups with only one video
parent
ed71b6cc
No related branches found
Branches containing commit
No related tags found
1 merge request
!355
Use media ctx for groups with only one video
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vlc-android/src/org/videolan/vlc/gui/videogroups/VideoGroupsFragment.kt
+40
-4
40 additions, 4 deletions
...c/org/videolan/vlc/gui/videogroups/VideoGroupsFragment.kt
vlc-android/src/org/videolan/vlc/util/Constants.kt
+2
-0
2 additions, 0 deletions
vlc-android/src/org/videolan/vlc/util/Constants.kt
with
42 additions
and
4 deletions
vlc-android/src/org/videolan/vlc/gui/videogroups/VideoGroupsFragment.kt
+
40
−
4
View file @
bb8e00de
...
...
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
import
kotlinx.android.synthetic.main.videogroups_fragment.*
import
kotlinx.coroutines.*
import
kotlinx.coroutines.channels.actor
import
org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper
import
org.videolan.medialibrary.interfaces.media.AbstractVideoGroup
import
org.videolan.tools.MultiSelectHelper
import
org.videolan.tools.isStarted
...
...
@@ -18,6 +19,7 @@ import org.videolan.vlc.databinding.VideogroupsFragmentBinding
import
org.videolan.vlc.gui.SecondaryActivity
import
org.videolan.vlc.gui.browser.MediaBrowserFragment
import
org.videolan.vlc.gui.dialogs.CtxActionReceiver
import
org.videolan.vlc.gui.dialogs.SavePlaylistDialog
import
org.videolan.vlc.gui.dialogs.showContext
import
org.videolan.vlc.gui.helpers.UiTools
import
org.videolan.vlc.media.MediaUtils
...
...
@@ -28,7 +30,6 @@ import org.videolan.vlc.util.*
import
org.videolan.vlc.viewmodels.mobile.VideogroupsViewModel
import
org.videolan.vlc.viewmodels.mobile.getViewModel
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
class
VideoGroupsFragment
:
MediaBrowserFragment
<
VideogroupsViewModel
>(),
CtxActionReceiver
{
...
...
@@ -37,7 +38,7 @@ class VideoGroupsFragment : MediaBrowserFragment<VideogroupsViewModel>(), CtxAct
private
lateinit
var
adapter
:
VideoGroupsAdapter
private
val
actor
=
actor
<
VideoGroupAction
>
{
for
(
action
in
channel
)
when
(
action
)
{
for
(
action
in
channel
)
when
(
action
)
{
is
VideoGroupClick
->
{
if
(
actionMode
!=
null
)
{
adapter
.
multiSelectHelper
.
toggleSelection
(
action
.
position
)
...
...
@@ -59,7 +60,12 @@ class VideoGroupsFragment : MediaBrowserFragment<VideogroupsViewModel>(), CtxAct
}
}
is
VideoGroupCtxClick
->
{
showContext
(
requireActivity
(),
this
@VideoGroupsFragment
,
action
.
position
,
action
.
group
.
title
,
CTX_FOLDER_FLAGS
)
if
(
action
.
group
.
mediaCount
()
==
1
)
{
context
?.
getFromMl
{
action
.
group
.
media
(
0
,
false
,
1
,
0
)
}
?.
get
(
0
)
?.
let
{
media
->
showContext
(
requireActivity
(),
this
@VideoGroupsFragment
,
action
.
position
,
media
.
title
,
CTX_VIDEO_GROUP_TEMP_FLAGS
)
}
}
else
showContext
(
requireActivity
(),
this
@VideoGroupsFragment
,
action
.
position
,
action
.
group
.
title
,
CTX_FOLDER_FLAGS
)
}
}
}
...
...
@@ -163,12 +169,42 @@ class VideoGroupsFragment : MediaBrowserFragment<VideogroupsViewModel>(), CtxAct
}
override
fun
onCtxAction
(
position
:
Int
,
option
:
Int
)
{
when
(
option
)
{
val
item
=
adapter
.
getItem
(
position
)
if
(
item
?.
mediaCount
()
==
1
)
{
launch
{
context
?.
getFromMl
{
item
.
media
(
0
,
false
,
1
,
0
)
}
?.
get
(
0
)
?.
let
{
media
->
when
(
option
)
{
CTX_PLAY_FROM_START
->
playVideo
(
media
,
true
)
CTX_PLAY_AS_AUDIO
->
playAudio
(
media
)
CTX_INFORMATION
->
showInfoDialog
(
media
)
CTX_DELETE
->
removeItem
(
media
)
CTX_APPEND
->
MediaUtils
.
appendMedia
(
activity
,
media
)
CTX_PLAY_NEXT
->
MediaUtils
.
insertNext
(
requireActivity
(),
media
.
tracks
)
CTX_DOWNLOAD_SUBTITLES
->
MediaUtils
.
getSubs
(
requireActivity
(),
media
)
CTX_ADD_TO_PLAYLIST
->
UiTools
.
addToPlaylist
(
requireActivity
(),
media
.
tracks
,
SavePlaylistDialog
.
KEY_NEW_TRACKS
)
else
->
{
}
}
}
}
}
else
when
(
option
)
{
CTX_PLAY
->
viewModel
.
play
(
position
)
CTX_APPEND
->
viewModel
.
append
(
position
)
CTX_ADD_TO_PLAYLIST
->
viewModel
.
addToPlaylist
(
requireActivity
(),
position
)
}
}
private
fun
playVideo
(
media
:
AbstractMediaWrapper
,
fromStart
:
Boolean
)
{
media
.
removeFlags
(
AbstractMediaWrapper
.
MEDIA_FORCE_AUDIO
)
if
(
fromStart
)
media
.
addFlags
(
AbstractMediaWrapper
.
MEDIA_FROM_START
)
MediaUtils
.
openMedia
(
requireContext
(),
media
)
}
private
fun
playAudio
(
media
:
AbstractMediaWrapper
)
{
media
.
addFlags
(
AbstractMediaWrapper
.
MEDIA_FORCE_AUDIO
)
MediaUtils
.
openMedia
(
activity
,
media
)
}
}
sealed
class
VideoGroupAction
...
...
This diff is collapsed.
Click to expand it.
vlc-android/src/org/videolan/vlc/util/Constants.kt
+
2
−
0
View file @
bb8e00de
...
...
@@ -167,6 +167,8 @@ const val CTX_DOWNLOAD_SUBTITLES_PLAYER = 1 shl 24
const
val
CTX_COPY
=
1
shl
25
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
//this is a temporary flag only used in 3.2
const
val
CTX_VIDEO_GROUP_TEMP_FLAGS
=
CTX_VIDEO_FLAGS
and
CTX_PLAY_ALL
.
inv
()
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
const
val
CTX_AUDIO_FLAGS
=
CTX_PLAY
or
CTX_APPEND
or
CTX_PLAY_NEXT
or
CTX_ADD_TO_PLAYLIST
const
val
CTX_PLAYLIST_FLAGS
=
CTX_AUDIO_FLAGS
or
CTX_DELETE
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment