mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-22 16:10:31 +00:00
feat: filter fetched channel tabs
This commit is contained in:
parent
a2a717bd49
commit
28d952a643
@ -80,7 +80,9 @@ class FeedLoadManager(private val context: Context) {
|
|||||||
* subscriptions which have not been updated within the feed updated threshold
|
* subscriptions which have not been updated within the feed updated threshold
|
||||||
*/
|
*/
|
||||||
val outdatedSubscriptions = when (groupId) {
|
val outdatedSubscriptions = when (groupId) {
|
||||||
FeedGroupEntity.GROUP_ALL_ID -> feedDatabaseManager.outdatedSubscriptions(outdatedThreshold)
|
FeedGroupEntity.GROUP_ALL_ID -> feedDatabaseManager.outdatedSubscriptions(
|
||||||
|
outdatedThreshold
|
||||||
|
)
|
||||||
GROUP_NOTIFICATION_ENABLED -> feedDatabaseManager.outdatedSubscriptionsWithNotificationMode(
|
GROUP_NOTIFICATION_ENABLED -> feedDatabaseManager.outdatedSubscriptionsWithNotificationMode(
|
||||||
outdatedThreshold, NotificationMode.ENABLED
|
outdatedThreshold, NotificationMode.ENABLED
|
||||||
)
|
)
|
||||||
@ -146,7 +148,13 @@ class FeedLoadManager(private val context: Context) {
|
|||||||
originalInfo = channelInfo
|
originalInfo = channelInfo
|
||||||
|
|
||||||
streams = channelInfo.tabs
|
streams = channelInfo.tabs
|
||||||
.filter(ChannelTabHelper::isStreamsTab)
|
.filter { tab ->
|
||||||
|
ChannelTabHelper.fetchFeedChannelTab(
|
||||||
|
context,
|
||||||
|
defaultSharedPreferences,
|
||||||
|
tab
|
||||||
|
)
|
||||||
|
}
|
||||||
.map {
|
.map {
|
||||||
Pair(
|
Pair(
|
||||||
getChannelTab(subscriptionEntity.serviceId, it, true)
|
getChannelTab(subscriptionEntity.serviceId, it, true)
|
||||||
@ -208,7 +216,12 @@ class FeedLoadManager(private val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun broadcastProgress() {
|
private fun broadcastProgress() {
|
||||||
FeedEventManager.postEvent(FeedEventManager.Event.ProgressEvent(currentProgress.get(), maxProgress.get()))
|
FeedEventManager.postEvent(
|
||||||
|
FeedEventManager.Event.ProgressEvent(
|
||||||
|
currentProgress.get(),
|
||||||
|
maxProgress.get()
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,6 +67,22 @@ public final class ChannelTabHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@StringRes
|
||||||
|
private static int getFetchFeedTabKey(final String tab) {
|
||||||
|
switch (tab) {
|
||||||
|
case ChannelTabs.VIDEOS:
|
||||||
|
return R.string.fetch_channel_tabs_videos;
|
||||||
|
case ChannelTabs.TRACKS:
|
||||||
|
return R.string.fetch_channel_tabs_tracks;
|
||||||
|
case ChannelTabs.SHORTS:
|
||||||
|
return R.string.fetch_channel_tabs_shorts;
|
||||||
|
case ChannelTabs.LIVESTREAMS:
|
||||||
|
return R.string.fetch_channel_tabs_livestreams;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
public static int getTranslationKey(final String tab) {
|
public static int getTranslationKey(final String tab) {
|
||||||
switch (tab) {
|
switch (tab) {
|
||||||
@ -110,4 +126,26 @@ public final class ChannelTabHelper {
|
|||||||
}
|
}
|
||||||
return showChannelTab(context, sharedPreferences, key);
|
return showChannelTab(context, sharedPreferences, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean fetchFeedChannelTab(final Context context,
|
||||||
|
final SharedPreferences sharedPreferences,
|
||||||
|
final ListLinkHandler tab) {
|
||||||
|
final List<String> contentFilters = tab.getContentFilters();
|
||||||
|
if (contentFilters.isEmpty()) {
|
||||||
|
return false; // this should never happen, but check just to be sure
|
||||||
|
}
|
||||||
|
|
||||||
|
final int key = ChannelTabHelper.getFetchFeedTabKey(contentFilters.get(0));
|
||||||
|
if (key == -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Set<String> enabledTabs = sharedPreferences.getStringSet(
|
||||||
|
context.getString(R.string.feed_fetch_channel_tabs_key), null);
|
||||||
|
if (enabledTabs == null) {
|
||||||
|
return true; // default to true
|
||||||
|
} else {
|
||||||
|
return enabledTabs.contains(context.getString(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,6 +372,24 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
<string name="feed_use_dedicated_fetch_method_key">feed_use_dedicated_fetch_method</string>
|
<string name="feed_use_dedicated_fetch_method_key">feed_use_dedicated_fetch_method</string>
|
||||||
|
|
||||||
|
<string name="feed_fetch_channel_tabs_key">feed_fetch_channel_tabs</string>
|
||||||
|
<string name="fetch_channel_tabs_videos">fetch_channel_tabs_videos</string>
|
||||||
|
<string name="fetch_channel_tabs_tracks">fetch_channel_tabs_tracks</string>
|
||||||
|
<string name="fetch_channel_tabs_shorts">fetch_channel_tabs_shorts</string>
|
||||||
|
<string name="fetch_channel_tabs_livestreams">fetch_channel_tabs_live</string>
|
||||||
|
<string-array name="feed_fetch_channel_tabs_value_list">
|
||||||
|
<item>@string/fetch_channel_tabs_videos</item>
|
||||||
|
<item>@string/fetch_channel_tabs_tracks</item>
|
||||||
|
<item>@string/fetch_channel_tabs_shorts</item>
|
||||||
|
<item>@string/fetch_channel_tabs_livestreams</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="feed_fetch_channel_tabs_description_list">
|
||||||
|
<item>@string/channel_tab_videos</item>
|
||||||
|
<item>@string/channel_tab_tracks</item>
|
||||||
|
<item>@string/channel_tab_shorts</item>
|
||||||
|
<item>@string/channel_tab_livestreams</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string name="import_export_data_path">import_export_data_path</string>
|
<string name="import_export_data_path">import_export_data_path</string>
|
||||||
<string name="import_data">import_data</string>
|
<string name="import_data">import_data</string>
|
||||||
<string name="export_data">export_data</string>
|
<string name="export_data">export_data</string>
|
||||||
|
@ -714,6 +714,8 @@
|
|||||||
\nSo the choice boils down to what you prefer: speed or precise information.</string>
|
\nSo the choice boils down to what you prefer: speed or precise information.</string>
|
||||||
<string name="feed_hide_streams_title">Show the following streams</string>
|
<string name="feed_hide_streams_title">Show the following streams</string>
|
||||||
<string name="feed_show_hide_streams">Show/Hide streams</string>
|
<string name="feed_show_hide_streams">Show/Hide streams</string>
|
||||||
|
<string name="feed_fetch_channel_tabs">Fetch channel tabs</string>
|
||||||
|
<string name="feed_fetch_channel_tabs_summary">Tabs to fetch when updating the feed. This option has no effect if a channel is updated using fast mode.</string>
|
||||||
<string name="content_not_supported">This content is not yet supported by NewPipe.\n\nIt will hopefully be supported in a future version.</string>
|
<string name="content_not_supported">This content is not yet supported by NewPipe.\n\nIt will hopefully be supported in a future version.</string>
|
||||||
<string name="detail_sub_channel_thumbnail_view_description">Channel\'s avatar thumbnail</string>
|
<string name="detail_sub_channel_thumbnail_view_description">Channel\'s avatar thumbnail</string>
|
||||||
<string name="channel_created_by">Created by %s</string>
|
<string name="channel_created_by">Created by %s</string>
|
||||||
|
@ -162,5 +162,15 @@
|
|||||||
app:singleLineTitle="false"
|
app:singleLineTitle="false"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
|
<MultiSelectListPreference
|
||||||
|
android:key="@string/feed_fetch_channel_tabs_key"
|
||||||
|
android:summary="@string/feed_fetch_channel_tabs_summary"
|
||||||
|
android:title="@string/feed_fetch_channel_tabs"
|
||||||
|
android:entries="@array/feed_fetch_channel_tabs_description_list"
|
||||||
|
android:entryValues="@array/feed_fetch_channel_tabs_value_list"
|
||||||
|
android:defaultValue="@array/feed_fetch_channel_tabs_value_list"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:singleLineTitle="false" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
Loading…
Reference in New Issue
Block a user