diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/SubscriptionsFeedFragment.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/SubscriptionsFeedFragment.kt index 76c60e1ff33f64f244d837b25a37231723055b83..3099638f6fbbbb556bd97d4e5a936a445dfb440d 100644 --- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/SubscriptionsFeedFragment.kt +++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/SubscriptionsFeedFragment.kt @@ -25,6 +25,7 @@ import com.futo.platformplayer.models.SearchType import com.futo.platformplayer.models.SubscriptionGroup import com.futo.platformplayer.states.StateApp import com.futo.platformplayer.states.StateCache +import com.futo.platformplayer.states.StateHistory import com.futo.platformplayer.states.StatePlatform import com.futo.platformplayer.states.StateSubscriptions import com.futo.platformplayer.stores.FragmentedStorage @@ -197,6 +198,7 @@ class SubscriptionsFeedFragment : MainFragment() { val allowContentTypes: MutableList<ContentType> = mutableListOf(ContentType.MEDIA, ContentType.POST); var allowLive: Boolean = true; var allowPlanned: Boolean = false; + var allowWatched: Boolean = true; override fun encode(): String { return Json.encodeToString(this); } @@ -304,7 +306,8 @@ class SubscriptionsFeedFragment : MainFragment() { SubscriptionBar.Toggle(context.getString(R.string.videos), _filterSettings.allowContentTypes.contains(ContentType.MEDIA)) { toggleFilterContentTypes(listOf(ContentType.MEDIA, ContentType.NESTED_VIDEO), it); }, SubscriptionBar.Toggle(context.getString(R.string.posts), _filterSettings.allowContentTypes.contains(ContentType.POST)) { toggleFilterContentType(ContentType.POST, it); }, SubscriptionBar.Toggle(context.getString(R.string.live), _filterSettings.allowLive) { _filterSettings.allowLive = it; _filterSettings.save(); loadResults(false); }, - SubscriptionBar.Toggle(context.getString(R.string.planned), _filterSettings.allowPlanned) { _filterSettings.allowPlanned = it; _filterSettings.save(); loadResults(false); } + SubscriptionBar.Toggle(context.getString(R.string.planned), _filterSettings.allowPlanned) { _filterSettings.allowPlanned = it; _filterSettings.save(); loadResults(false); }, + SubscriptionBar.Toggle(context.getString(R.string.watched), _filterSettings.allowWatched) { _filterSettings.allowWatched = it; _filterSettings.save(); loadResults(false); } ); } @@ -336,6 +339,9 @@ class SubscriptionsFeedFragment : MainFragment() { return results.filter { val allowedContentType = _filterSettings.allowContentTypes.contains(if(it.contentType == ContentType.NESTED_VIDEO || it.contentType == ContentType.LOCKED) ContentType.MEDIA else it.contentType); + if(it is IPlatformVideo && it.duration > 0 && !_filterSettings.allowWatched && StateHistory.instance.isHistoryWatched(it.url, it.duration)) + return@filter false; + //TODO: Check against a sub cache if(filterGroup != null && !filterGroup.urls.contains(it.author.url)) return@filter false; diff --git a/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt b/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt index 9f9ef81ffcc86ff22be67f4b49ab50a78cefd5a4..d61b8ab303399e3ad5945ffebfcef08aaeaaf473 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StateHistory.kt @@ -50,6 +50,9 @@ class StateHistory { fun getHistoryPosition(url: String): Long { return historyIndex[url]?.position ?: 0; } + fun isHistoryWatched(url: String, duration: Long): Boolean { + return getHistoryPosition(url) > duration * 0.7; + } fun updateHistoryPosition(liveObj: IPlatformVideo, index: DBHistory.Index, updateExisting: Boolean, position: Long = -1L): Long { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 274feb828aa579d108d93f6fa1e046fae52aeded..5dc24aef67c2288a3fb7b602b832fb906f7faa99 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -625,6 +625,7 @@ <string name="you_have_too_many_subscriptions_for_the_following_plugins">\n\nYou have too many subscriptions for the following plugins:\n</string> <string name="posts">Posts</string> <string name="planned">Planned</string> + <string name="watched">Watched</string> <string name="no_results_found_swipe_down_to_refresh">No results found\nSwipe down to refresh</string> <string name="overlay">Overlay</string> <string name="reload">Reload</string> diff --git a/app/src/unstable/assets/sources/youtube b/app/src/unstable/assets/sources/youtube index c86c73db0cdde3371c7944dd82c34ea4e5c725d9..83cccf8ba5ae87d8a437775d9b341a9e3be07e74 160000 --- a/app/src/unstable/assets/sources/youtube +++ b/app/src/unstable/assets/sources/youtube @@ -1 +1 @@ -Subproject commit c86c73db0cdde3371c7944dd82c34ea4e5c725d9 +Subproject commit 83cccf8ba5ae87d8a437775d9b341a9e3be07e74