feat: option to hide upcoming videos from feed

This commit is contained in:
Bnyro 2025-02-05 14:52:22 +01:00
parent 6c0ac68e92
commit 8925d8aa8b
6 changed files with 32 additions and 4 deletions

View File

@ -58,4 +58,5 @@ object IntentData {
const val chapters = "chapters"
const val segments = "segments"
const val alreadyStarted = "alreadyStarted"
const val showUpcoming = "showUpcoming"
}

View File

@ -112,6 +112,7 @@ object PreferenceKeys {
// Subscriptions
const val HIDE_WATCHED_FROM_FEED = "hide_watched_from_feed"
const val SHOW_UPCOMING_IN_FEED = "show_upcoming_in_feed"
const val SELECTED_FEED_FILTERS = "filter_feed"
const val FEED_SORT_ORDER = "sort_oder_feed"
const val LOCAL_FEED_EXTRACTION = "local_feed_extraction"

View File

@ -80,6 +80,13 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
field = value
}
private var showUpcoming =
PreferenceHelper.getBoolean(PreferenceKeys.SHOW_UPCOMING_IN_FEED, true)
set(value) {
PreferenceHelper.putBoolean(PreferenceKeys.SHOW_UPCOMING_IN_FEED, value)
field = value
}
private var subChannelsRecyclerViewState: Parcelable? = null
private var subFeedRecyclerViewState: Parcelable? = null
@ -256,6 +263,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
) { _, resultBundle ->
selectedSortOrder = resultBundle.getInt(IntentData.sortOptions)
hideWatched = resultBundle.getBoolean(IntentData.hideWatched)
showUpcoming = resultBundle.getBoolean(IntentData.showUpcoming)
showFeed()
}
@ -263,7 +271,8 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
.apply {
arguments = bundleOf(
IntentData.sortOptions to fetchSortOptions(),
IntentData.hideWatched to hideWatched
IntentData.hideWatched to hideWatched,
IntentData.showUpcoming to showUpcoming,
)
}
.show(childFragmentManager)
@ -366,6 +375,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
binding.subRefresh.isRefreshing = false
val feed = videoFeed
.filterByGroup(selectedFilterGroup)
.filter { showUpcoming || !it.isUpcoming }
.let {
DatabaseHelper.filterByStatusAndWatchPosition(it, hideWatched)
}

View File

@ -20,11 +20,13 @@ class FilterSortBottomSheet : ExpandedBottomSheet(R.layout.filter_sort_sheet) {
private var selectedIndex = 0
private var hideWatched = false
private var showUpcoming = true
override fun onCreate(savedInstanceState: Bundle?) {
val arguments = requireArguments()
sortOptions = arguments.parcelableArrayList(IntentData.sortOptions)!!
hideWatched = arguments.getBoolean(IntentData.hideWatched)
showUpcoming = arguments.getBoolean(IntentData.showUpcoming)
super.onCreate(savedInstanceState)
}
@ -34,7 +36,7 @@ class FilterSortBottomSheet : ExpandedBottomSheet(R.layout.filter_sort_sheet) {
setInitialFiltersState()
observeSortChanges()
observeHideWatchedChanges()
observeCheckboxFilters()
observeFiltersChanges()
}
@ -73,11 +75,16 @@ class FilterSortBottomSheet : ExpandedBottomSheet(R.layout.filter_sort_sheet) {
}
}
private fun observeHideWatchedChanges() {
private fun observeCheckboxFilters() {
binding.hideWatchedCheckbox.setOnCheckedChangeListener { _, checked ->
hideWatched = checked
notifyChange()
}
binding.showUpcomingCheckbox.setOnCheckedChangeListener { _, checked ->
showUpcoming = checked
notifyChange()
}
}
private fun observeFiltersChanges() {
@ -94,7 +101,8 @@ class FilterSortBottomSheet : ExpandedBottomSheet(R.layout.filter_sort_sheet) {
requestKey = FILTER_SORT_REQUEST_KEY,
result = bundleOf(
IntentData.sortOptions to selectedIndex,
IntentData.hideWatched to hideWatched
IntentData.hideWatched to hideWatched,
IntentData.showUpcoming to showUpcoming
)
)
}

View File

@ -89,6 +89,13 @@
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"/>
<CheckBox
android:id="@+id/show_upcoming_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/show_upcoming_videos"
android:layout_marginStart="16dp"/>
<CheckBox
android:id="@+id/hide_watched_checkbox"
android:layout_width="wrap_content"

View File

@ -530,6 +530,7 @@
<string name="delete_only_watched_videos">Only delete already watched videos</string>
<string name="local_feed_extraction">Local feed extraction</string>
<string name="local_feed_extraction_summary">Directly fetch the feed from YouTube. This may be significantly slower.</string>
<string name="show_upcoming_videos">Show upcoming videos</string>
<!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string>