Skip to content

Commit 98d0036

Browse files
committed
[YouTube] Add support for"podcasts" and "courses" tabs
1 parent fb9a5cc commit 98d0036

4 files changed

Lines changed: 49 additions & 1 deletion

File tree

app/src/main/java/org/schabi/newpipe/settings/migration/SettingMigrations.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,25 @@ protected void migrate(@NonNull final Context context) {
221221
}
222222
};
223223

224+
private static final Migration MIGRATION_8_9 = new Migration(8, 9) {
225+
@Override
226+
protected void migrate(@NonNull final Context context) {
227+
// Support for courses and podcasts tabs were added.
228+
// If the user changed the displayed tabs the new ones need to be added to the list
229+
// of displayed tabs.
230+
final Set<String> enabledTabs = sp.getStringSet(context.getString(
231+
R.string.show_channel_tabs_key), null);
232+
if (enabledTabs != null) {
233+
enabledTabs.add(context.getString(R.string.show_channel_tabs_courses));
234+
enabledTabs.add(context.getString(R.string.show_channel_tabs_podcasts));
235+
sp.edit()
236+
.putStringSet(context.getString(R.string.show_channel_tabs_key),
237+
enabledTabs)
238+
.apply();
239+
}
240+
}
241+
};
242+
224243
/**
225244
* List of all implemented migrations.
226245
* <p>
@@ -236,12 +255,13 @@ protected void migrate(@NonNull final Context context) {
236255
MIGRATION_5_6,
237256
MIGRATION_6_7,
238257
MIGRATION_7_8,
258+
MIGRATION_8_9,
239259
};
240260

241261
/**
242262
* Version number for preferences. Must be incremented every time a migration is necessary.
243263
*/
244-
private static final int VERSION = 8;
264+
private static final int VERSION = 9;
245265

246266

247267
static void runMigrationsIfNeeded(@NonNull final Context context) {

app/src/main/java/org/schabi/newpipe/util/ChannelTabHelper.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public static boolean isStreamsTab(final String tab) {
2727
case ChannelTabs.LIKES:
2828
case ChannelTabs.SHORTS:
2929
case ChannelTabs.LIVESTREAMS:
30+
case ChannelTabs.PODCASTS:
31+
case ChannelTabs.COURSES:
3032
return true;
3133
default:
3234
return false;
@@ -65,6 +67,10 @@ private static int getShowTabKey(final String tab) {
6567
return R.string.show_channel_tabs_albums;
6668
case ChannelTabs.LIKES:
6769
return R.string.show_channel_tabs_likes;
70+
case ChannelTabs.PODCASTS:
71+
return R.string.show_channel_tabs_podcasts;
72+
case ChannelTabs.COURSES:
73+
return R.string.show_channel_tabs_courses;
6874
default:
6975
return -1;
7076
}
@@ -83,6 +89,10 @@ private static int getFetchFeedTabKey(final String tab) {
8389
return R.string.fetch_channel_tabs_livestreams;
8490
case ChannelTabs.LIKES:
8591
return R.string.fetch_channel_tabs_likes;
92+
case ChannelTabs.PODCASTS:
93+
return R.string.fetch_channel_tabs_podcasts;
94+
case ChannelTabs.COURSES:
95+
return R.string.fetch_channel_tabs_courses;
8696
default:
8797
return -1;
8898
}
@@ -107,6 +117,10 @@ public static int getTranslationKey(final String tab) {
107117
return R.string.channel_tab_albums;
108118
case ChannelTabs.LIKES:
109119
return R.string.channel_tab_likes;
120+
case ChannelTabs.PODCASTS:
121+
return R.string.channel_tab_podcasts;
122+
case ChannelTabs.COURSES:
123+
return R.string.channel_tab_courses;
110124
default:
111125
return R.string.unknown_content;
112126
}

app/src/main/res/values/settings_keys.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@
297297
<string name="show_channel_tabs_playlists">show_channel_tabs_playlists</string>
298298
<string name="show_channel_tabs_albums">show_channel_tabs_albums</string>
299299
<string name="show_channel_tabs_likes">show_channel_tabs_likes</string>
300+
<string name="show_channel_tabs_podcasts">show_channel_tabs_podcasts</string>
301+
<string name="show_channel_tabs_courses">show_channel_tabs_courses</string>
300302
<string name="show_channel_tabs_about">show_channel_tabs_about</string>
301303
<string-array name="show_channel_tabs_value_list">
302304
<item>@string/show_channel_tabs_videos</item>
@@ -307,6 +309,8 @@
307309
<item>@string/show_channel_tabs_playlists</item>
308310
<item>@string/show_channel_tabs_albums</item>
309311
<item>@string/show_channel_tabs_likes</item>
312+
<item>@string/show_channel_tabs_podcasts</item>
313+
<item>@string/show_channel_tabs_courses</item>
310314
<item>@string/show_channel_tabs_about</item>
311315
</string-array>
312316
<string-array name="show_channel_tabs_description_list">
@@ -318,6 +322,8 @@
318322
<item>@string/channel_tab_playlists</item>
319323
<item>@string/channel_tab_albums</item>
320324
<item>@string/channel_tab_likes</item>
325+
<item>@string/channel_tab_podcasts</item>
326+
<item>@string/channel_tab_courses</item>
321327
<item>@string/channel_tab_about</item>
322328
</string-array>
323329
<string name="show_search_suggestions_key">show_search_suggestions</string>
@@ -396,19 +402,25 @@
396402
<string name="fetch_channel_tabs_shorts">fetch_channel_tabs_shorts</string>
397403
<string name="fetch_channel_tabs_livestreams">fetch_channel_tabs_livestreams</string>
398404
<string name="fetch_channel_tabs_likes">fetch_channel_tabs_likes</string>
405+
<string name="fetch_channel_tabs_podcasts">fetch_channel_tabs_podcasts</string>
406+
<string name="fetch_channel_tabs_courses">fetch_channel_tabs_courses</string>
399407
<string-array name="feed_fetch_channel_tabs_value_list">
400408
<item>@string/fetch_channel_tabs_videos</item>
401409
<item>@string/fetch_channel_tabs_tracks</item>
402410
<item>@string/fetch_channel_tabs_shorts</item>
403411
<item>@string/fetch_channel_tabs_livestreams</item>
404412
<item>@string/fetch_channel_tabs_likes</item>
413+
<item>@string/fetch_channel_tabs_podcasts</item>
414+
<item>@string/fetch_channel_tabs_courses</item>
405415
</string-array>
406416
<string-array name="feed_fetch_channel_tabs_description_list">
407417
<item>@string/channel_tab_videos</item>
408418
<item>@string/channel_tab_tracks</item>
409419
<item>@string/channel_tab_shorts</item>
410420
<item>@string/channel_tab_livestreams</item>
411421
<item>@string/channel_tab_likes</item>
422+
<item>@string/channel_tab_podcasts</item>
423+
<item>@string/channel_tab_courses</item>
412424
</string-array>
413425

414426
<string name="import_export_data_path">import_export_data_path</string>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,8 @@
849849
<string name="channel_tab_playlists">Playlists</string>
850850
<string name="channel_tab_albums">Albums</string>
851851
<string name="channel_tab_likes">Likes</string>
852+
<string name="channel_tab_podcasts">Podcasts</string>
853+
<string name="channel_tab_courses">Courses</string>
852854
<string name="channel_tab_about">About</string>
853855
<string name="show_channel_tabs">Channel tabs</string>
854856
<string name="show_channel_tabs_summary">What tabs are shown on the channel pages</string>

0 commit comments

Comments
 (0)