Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.schabi.newpipe.util.ChannelTabHelper
import org.schabi.newpipe.util.ExtractorHelper.getChannelInfo
import org.schabi.newpipe.util.ExtractorHelper.getChannelTab
import org.schabi.newpipe.util.ExtractorHelper.getMoreChannelTabItems
import org.schabi.newpipe.util.StreamTypeUtil
import java.time.OffsetDateTime
import java.time.ZoneOffset
import java.util.concurrent.ConcurrentHashMap
Expand Down Expand Up @@ -82,6 +83,11 @@ class FeedLoadManager(private val context: Context) {
true
)

val filterLivestreams = defaultSharedPreferences.getBoolean(
context.getString(R.string.filter_livestreams_key),
false
)

val outdatedThreshold = if (ignoreOutdatedThreshold) {
OffsetDateTime.now(ZoneOffset.UTC)
} else {
Expand Down Expand Up @@ -214,7 +220,7 @@ class FeedLoadManager(private val context: Context) {
}
.filterIsInstance<StreamInfoItem>()
}
streams = streams?.filterNot { it.isRoundPlayStream || (filterFutureItems && it.uploadDate != null && it.uploadDate!!.offsetDateTime().isAfter(OffsetDateTime.now())) }
streams = streams?.filterNot { it.isRoundPlayStream || (filterFutureItems && it.uploadDate != null && it.uploadDate!!.offsetDateTime().isAfter(OffsetDateTime.now())) || (filterLivestreams && StreamTypeUtil.isLiveStream(it.streamType)) }

return@defer Flowable.just(
FeedUpdateInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S
Preference filter_shorts = findPreference(getString(R.string.filter_shorts_key));
Preference filter_paid_contents = findPreference(getString(R.string.filter_paid_contents_key));
Preference filter_future_items = findPreference(getString(R.string.filter_future_items_key));
Preference filter_livestreams = findPreference(getString(R.string.filter_livestreams_key));
Preference filter_type = findPreference(getString(R.string.filter_type_key));

filter_by_keyword.setOnPreferenceClickListener(preference -> {
Expand Down Expand Up @@ -53,6 +54,13 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S
return true;
});

filter_livestreams.setOnPreferenceChangeListener((preference, newValue) -> {
new Handler().postDelayed(() -> {
ServiceHelper.initServices(getContext());
}, 100);
return true;
});

filter_type.setOnPreferenceChangeListener((preference, newValue) -> {
new Handler().postDelayed(() -> {
ServiceHelper.initServices(getContext());
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,7 @@
<item>@string/description_tab_description</item>
</string-array>
<string name="filter_future_items_key">filter_future_items_key</string>
<string name="filter_livestreams_key">filter_livestreams_key</string>
<string name="use_experimental_new_ui_key">use_experimental_new_ui</string>
<string name="force_end_on_overtime_key">force_end_on_overtime</string>
<string name="use_old_search_filter_key">use_old_search_filter</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,8 @@
<string name="video_tabs_summary">Configure which tabs to show on video detail screen</string>
<string name="filter_future_items_title">Filter future items</string>
<string name="filter_future_items_summary">Remove items scheduled for a future release</string>
<string name="filter_livestreams_title">Filter livestreams</string>
<string name="filter_livestreams_summary">Remove livestreams from the feed</string>
<string name="pin_video_to_top_title">Pin video to top</string>
<string name="pin_video_to_top_summary">Keep the video pinned to the top while scrolling the video detail page</string>
<string name="settings_category_behavior_title">Behavior</string>
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/filter_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
android:title="@string/filter_future_items_title"
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/filter_livestreams_key"
android:summary="@string/filter_livestreams_summary"
android:title="@string/filter_livestreams_title"
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
<MultiSelectListPreference
android:key="@string/filter_type_key"
android:title="@string/filter_field_summary"
Expand Down