mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
feat: option to hide upcoming videos from feed
This commit is contained in:
parent
6c0ac68e92
commit
8925d8aa8b
@ -58,4 +58,5 @@ object IntentData {
|
|||||||
const val chapters = "chapters"
|
const val chapters = "chapters"
|
||||||
const val segments = "segments"
|
const val segments = "segments"
|
||||||
const val alreadyStarted = "alreadyStarted"
|
const val alreadyStarted = "alreadyStarted"
|
||||||
|
const val showUpcoming = "showUpcoming"
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,7 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
// Subscriptions
|
// Subscriptions
|
||||||
const val HIDE_WATCHED_FROM_FEED = "hide_watched_from_feed"
|
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 SELECTED_FEED_FILTERS = "filter_feed"
|
||||||
const val FEED_SORT_ORDER = "sort_oder_feed"
|
const val FEED_SORT_ORDER = "sort_oder_feed"
|
||||||
const val LOCAL_FEED_EXTRACTION = "local_feed_extraction"
|
const val LOCAL_FEED_EXTRACTION = "local_feed_extraction"
|
||||||
|
@ -80,6 +80,13 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
|
|||||||
field = value
|
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 subChannelsRecyclerViewState: Parcelable? = null
|
||||||
private var subFeedRecyclerViewState: Parcelable? = null
|
private var subFeedRecyclerViewState: Parcelable? = null
|
||||||
|
|
||||||
@ -256,6 +263,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
|
|||||||
) { _, resultBundle ->
|
) { _, resultBundle ->
|
||||||
selectedSortOrder = resultBundle.getInt(IntentData.sortOptions)
|
selectedSortOrder = resultBundle.getInt(IntentData.sortOptions)
|
||||||
hideWatched = resultBundle.getBoolean(IntentData.hideWatched)
|
hideWatched = resultBundle.getBoolean(IntentData.hideWatched)
|
||||||
|
showUpcoming = resultBundle.getBoolean(IntentData.showUpcoming)
|
||||||
showFeed()
|
showFeed()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +271,8 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
|
|||||||
.apply {
|
.apply {
|
||||||
arguments = bundleOf(
|
arguments = bundleOf(
|
||||||
IntentData.sortOptions to fetchSortOptions(),
|
IntentData.sortOptions to fetchSortOptions(),
|
||||||
IntentData.hideWatched to hideWatched
|
IntentData.hideWatched to hideWatched,
|
||||||
|
IntentData.showUpcoming to showUpcoming,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.show(childFragmentManager)
|
.show(childFragmentManager)
|
||||||
@ -366,6 +375,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
|
|||||||
binding.subRefresh.isRefreshing = false
|
binding.subRefresh.isRefreshing = false
|
||||||
val feed = videoFeed
|
val feed = videoFeed
|
||||||
.filterByGroup(selectedFilterGroup)
|
.filterByGroup(selectedFilterGroup)
|
||||||
|
.filter { showUpcoming || !it.isUpcoming }
|
||||||
.let {
|
.let {
|
||||||
DatabaseHelper.filterByStatusAndWatchPosition(it, hideWatched)
|
DatabaseHelper.filterByStatusAndWatchPosition(it, hideWatched)
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,13 @@ class FilterSortBottomSheet : ExpandedBottomSheet(R.layout.filter_sort_sheet) {
|
|||||||
|
|
||||||
private var selectedIndex = 0
|
private var selectedIndex = 0
|
||||||
private var hideWatched = false
|
private var hideWatched = false
|
||||||
|
private var showUpcoming = true
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
val arguments = requireArguments()
|
val arguments = requireArguments()
|
||||||
sortOptions = arguments.parcelableArrayList(IntentData.sortOptions)!!
|
sortOptions = arguments.parcelableArrayList(IntentData.sortOptions)!!
|
||||||
hideWatched = arguments.getBoolean(IntentData.hideWatched)
|
hideWatched = arguments.getBoolean(IntentData.hideWatched)
|
||||||
|
showUpcoming = arguments.getBoolean(IntentData.showUpcoming)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +36,7 @@ class FilterSortBottomSheet : ExpandedBottomSheet(R.layout.filter_sort_sheet) {
|
|||||||
setInitialFiltersState()
|
setInitialFiltersState()
|
||||||
|
|
||||||
observeSortChanges()
|
observeSortChanges()
|
||||||
observeHideWatchedChanges()
|
observeCheckboxFilters()
|
||||||
observeFiltersChanges()
|
observeFiltersChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,11 +75,16 @@ class FilterSortBottomSheet : ExpandedBottomSheet(R.layout.filter_sort_sheet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeHideWatchedChanges() {
|
private fun observeCheckboxFilters() {
|
||||||
binding.hideWatchedCheckbox.setOnCheckedChangeListener { _, checked ->
|
binding.hideWatchedCheckbox.setOnCheckedChangeListener { _, checked ->
|
||||||
hideWatched = checked
|
hideWatched = checked
|
||||||
notifyChange()
|
notifyChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.showUpcomingCheckbox.setOnCheckedChangeListener { _, checked ->
|
||||||
|
showUpcoming = checked
|
||||||
|
notifyChange()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeFiltersChanges() {
|
private fun observeFiltersChanges() {
|
||||||
@ -94,7 +101,8 @@ class FilterSortBottomSheet : ExpandedBottomSheet(R.layout.filter_sort_sheet) {
|
|||||||
requestKey = FILTER_SORT_REQUEST_KEY,
|
requestKey = FILTER_SORT_REQUEST_KEY,
|
||||||
result = bundleOf(
|
result = bundleOf(
|
||||||
IntentData.sortOptions to selectedIndex,
|
IntentData.sortOptions to selectedIndex,
|
||||||
IntentData.hideWatched to hideWatched
|
IntentData.hideWatched to hideWatched,
|
||||||
|
IntentData.showUpcoming to showUpcoming
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,13 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingHorizontal="16dp"/>
|
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
|
<CheckBox
|
||||||
android:id="@+id/hide_watched_checkbox"
|
android:id="@+id/hide_watched_checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -530,6 +530,7 @@
|
|||||||
<string name="delete_only_watched_videos">Only delete already watched videos</string>
|
<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">Local feed extraction</string>
|
||||||
<string name="local_feed_extraction_summary">Directly fetch the feed from YouTube. This may be significantly slower.</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 -->
|
<!-- Notification channel strings -->
|
||||||
<string name="download_channel_name">Download Service</string>
|
<string name="download_channel_name">Download Service</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user