Skip to content
Snippets Groups Projects
Commit 74d9fda9 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Implement mark as played

Fixes #1442
parent 19ac6127
No related branches found
No related tags found
1 merge request!712Implement mark as played
......@@ -196,14 +196,16 @@ const val CTX_REMOVE_GROUP = 1L shl 32
const val CTX_RENAME_GROUP = 1L shl 33
const val CTX_UNGROUP = 1L shl 34
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
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_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
const val CTX_PLAYLIST_ITEM_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_ADD_TO_PLAYLIST or CTX_INFORMATION or CTX_DELETE or CTX_SET_RINGTONE or CTX_SHARE
const val CTX_VIDEO_GROUP_FLAGS = CTX_APPEND or CTX_PLAY_GROUP
const val CTX_FOLDER_FLAGS = CTX_PLAY or CTX_APPEND or CTX_ADD_TO_PLAYLIST
const val CTX_VIDEO_GROUP_FLAGS = CTX_APPEND or CTX_PLAY_GROUP or CTX_MARK_ALL_AS_PLAYED
const val CTX_FOLDER_FLAGS = CTX_PLAY or CTX_APPEND or CTX_ADD_TO_PLAYLIST or CTX_MARK_ALL_AS_PLAYED
//Moviepedia
const val MOVIEPEDIA_MEDIA: String = "moviepedia_media"
......
<!--
~ *************************************************************************
~ ic_ctx_mark_all_as_played.xml
~ **************************************************************************
~ Copyright © 2020 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000000"
android:pathData="M18,7l-1.41,-1.41 -6.34,6.34 1.41,1.41L18,7zM22.24,5.59L11.66,16.17 7.48,12l-1.41,1.41L11.66,19l12,-12 -1.42,-1.41zM0.41,13.41L6,19l1.41,-1.41L1.83,12 0.41,13.41z" />
</vector>
<!--
~ *************************************************************************
~ ic_ctx_mark_as_played.xml
~ **************************************************************************
~ Copyright © 2020 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000000"
android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z" />
</vector>
......@@ -750,4 +750,8 @@
<string name="thank_you">Thank you</string>
<string name="thank_you_desc">Thank you for your sponsorship!\nIt will help us a lot improving VLC!</string>
<string name="donate_again">Sponsor the app again</string>
<string name="mark_as_played">Mark as played</string>
<string name="mark_all_as_played">Mark all as played</string>
</resources>
......@@ -120,6 +120,8 @@ class ContextSheet : VLCBottomSheetDialogFragment() {
if (flags and CTX_RENAME_GROUP != 0L) add(Simple(CTX_RENAME_GROUP, getString(R.string.rename_group), R.drawable.ic_ctx_edit))
if (flags and CTX_UNGROUP != 0L) add(Simple(CTX_UNGROUP, getString(R.string.ungroup), R.drawable.ic_ctx_delete))
if (flags and CTX_GROUP_SIMILAR != 0L) add(Simple(CTX_GROUP_SIMILAR, getString(R.string.group_similar), R.drawable.ic_ctx_group_auto))
if (flags and CTX_MARK_AS_PLAYED != 0L) add(Simple(CTX_MARK_AS_PLAYED, getString(R.string.mark_as_played), R.drawable.ic_ctx_mark_as_played))
if (flags and CTX_MARK_ALL_AS_PLAYED != 0L) add(Simple(CTX_MARK_ALL_AS_PLAYED, getString(R.string.mark_all_as_played), R.drawable.ic_ctx_mark_all_as_played))
}
inner class ContextAdapter : RecyclerView.Adapter<ContextAdapter.ViewHolder>() {
......
......@@ -433,12 +433,13 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
CTX_REMOVE_GROUP -> viewModel.removeFromGroup(media)
CTX_ADD_GROUP -> requireActivity().addToGroup(listOf(media))
CTX_GROUP_SIMILAR -> lifecycleScope.launch { viewModel.groupSimilar(media) }
CTX_MARK_AS_PLAYED -> lifecycleScope.launch { viewModel.markAsPlayed(media) }
}
is Folder -> when (option) {
CTX_PLAY -> viewModel.play(position)
CTX_APPEND -> viewModel.append(position)
CTX_ADD_TO_PLAYLIST -> viewModel.addItemToPlaylist(requireActivity(), position)
CTX_MARK_ALL_AS_PLAYED -> lifecycleScope.launch { viewModel.markAsPlayed(media) }
}
is VideoGroup -> when (option) {
CTX_PLAY_ALL -> viewModel.play(position)
......@@ -447,6 +448,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
CTX_ADD_TO_PLAYLIST -> viewModel.addItemToPlaylist(requireActivity(), position)
CTX_RENAME_GROUP -> renameGroup(media)
CTX_UNGROUP -> viewModel.ungroup(media)
CTX_MARK_ALL_AS_PLAYED -> lifecycleScope.launch { viewModel.markAsPlayed(media) }
}
}
}
......
......@@ -205,6 +205,19 @@ class VideosViewModel(context: Context, type: VideoGroupingType, val folder: Fol
suspend fun groupSimilar(media: MediaWrapper) = withContext(Dispatchers.IO) {
medialibrary.regroup(media.id)
}
suspend fun markAsPlayed(media: MediaLibraryItem) = withContext(Dispatchers.IO) {
when (media) {
is VideoGroup -> media.getAll().forEach {
it.setLongMeta(MediaWrapper.META_SEEN, it.seen + 1)
}
is Folder -> media.getAll().forEach {
it.setLongMeta(MediaWrapper.META_SEEN, it.seen + 1)
}
is MediaWrapper -> media.setLongMeta(MediaWrapper.META_SEEN, media.seen + 1)
else -> {}
}
}
}
enum class VideoGroupingType {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment