Mark as watched action

This commit is contained in:
Kelvin 2024-07-17 21:12:24 +02:00
parent aa8790ebdb
commit 72efb21439
3 changed files with 18 additions and 1 deletions

View file

@ -34,6 +34,7 @@ import com.futo.platformplayer.models.SubscriptionGroup
import com.futo.platformplayer.parsers.HLS
import com.futo.platformplayer.states.StateApp
import com.futo.platformplayer.states.StateDownloads
import com.futo.platformplayer.states.StateHistory
import com.futo.platformplayer.states.StateMeta
import com.futo.platformplayer.states.StatePlatform
import com.futo.platformplayer.states.StatePlayer
@ -710,7 +711,9 @@ class UISlideOverlays {
SlideUpMenuItem(container.context, R.drawable.ic_queue_add, container.context.getString(R.string.add_to_queue), "${queue.size} " + container.context.getString(R.string.videos), "queue",
{ StatePlayer.instance.addToQueue(video); }),
SlideUpMenuItem(container.context, R.drawable.ic_watchlist_add, "${container.context.getString(R.string.add_to)} " + StatePlayer.TYPE_WATCHLATER + "", "${watchLater.size} " + container.context.getString(R.string.videos), "watch later",
{ StatePlaylists.instance.addToWatchLater(SerializedPlatformVideo.fromVideo(video)); })
{ StatePlaylists.instance.addToWatchLater(SerializedPlatformVideo.fromVideo(video)); }),
SlideUpMenuItem(container.context, R.drawable.ic_history, container.context.getString(R.string.add_to_history), "Mark as watched", "history",
{ StateHistory.instance.markAsWatched(video); }),
));
val playlistItems = arrayListOf<SlideUpMenuItem>();

View file

@ -115,6 +115,19 @@ class StateHistory {
return result;
}
fun markAsWatched(video: IPlatformVideo) {
try {
val history = getHistoryByVideo(video, true, OffsetDateTime.now());
if (history != null) {
updateHistoryPosition(video, history, true, Math.max(1, video.duration - 1));
}
}
catch(ex: Throwable) {
Logger.e(TAG, "Failed to mark as watched", ex);
UIDialogs.toast("Failed to mark as watched\n" + ex.message);
}
}
fun removeHistory(url: String) {
val hist = getHistoryIndexByUrl(url);
if(hist != null)

View file

@ -7,6 +7,7 @@
<string name="add_to">Add to</string>
<string name="lorem_ipsum" translatable="false">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</string>
<string name="add_to_queue">Add to queue</string>
<string name="add_to_history">Add to history</string>
<string name="general">General</string>
<string name="channel">Channel</string>
<string name="home">Home</string>