@@ -297,7 +297,7 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
297
297
if (matchedGroup == suggestedAction ) {
298
298
// Skip searching the buffer if all suggested actions are set to hidden.
299
299
// This has a secondary effect of hiding all new un-identified actions
300
- // under the assumption that the user wants all actions hidden.
300
+ // under the assumption that the user wants all suggestions hidden.
301
301
if (isEverySuggestedActionFilterEnabled ()) {
302
302
return super .isFiltered (path , identifier , protobufBufferArray , matchedGroup , contentType , contentIndex );
303
303
}
@@ -324,19 +324,22 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
324
324
}
325
325
326
326
private static boolean shouldHideShortsFeedItems () {
327
+ // Known issue if hide home is on but at least one other hide is off:
328
+ //
329
+ // Shorts suggestions will load in the background if a video is opened and
330
+ // immediately minimized before any suggestions are loaded.
331
+ // In this state the player type will show minimized, which cannot
332
+ // distinguish between Shorts suggestions loading in the player and between
333
+ // scrolling thru search/home/subscription tabs while a player is minimized.
327
334
final boolean hideHome = Settings .HIDE_SHORTS_HOME .get ();
328
335
final boolean hideSubscriptions = Settings .HIDE_SHORTS_SUBSCRIPTIONS .get ();
329
336
final boolean hideSearch = Settings .HIDE_SHORTS_SEARCH .get ();
337
+ final boolean hideHistory = Settings .HIDE_SHORTS_HISTORY .get ();
330
338
331
- if (hideHome && hideSubscriptions && hideSearch ) {
332
- // Shorts suggestions can load in the background if a video is opened and
333
- // then immediately minimized before any suggestions are loaded.
334
- // In this state the player type will show minimized, which makes it not possible to
335
- // distinguish between Shorts suggestions loading in the player and between
336
- // scrolling thru search/home/subscription tabs while a player is minimized.
337
- //
338
- // To avoid this situation for users that never want to show Shorts (all hide Shorts options are enabled)
339
- // then hide all Shorts everywhere including the Library history and Library playlists.
339
+ if (!hideHome && !hideSubscriptions && !hideSearch && !hideHistory ) {
340
+ return false ;
341
+ }
342
+ if (hideHome && hideSubscriptions && hideSearch && hideHistory ) {
340
343
return true ;
341
344
}
342
345
@@ -352,24 +355,29 @@ private static boolean shouldHideShortsFeedItems() {
352
355
}
353
356
354
357
// Avoid checking navigation button status if all other Shorts should show.
355
- if (!hideHome && !hideSubscriptions ) {
358
+ if (!hideHome && !hideSubscriptions && ! hideHistory ) {
356
359
return false ;
357
360
}
358
361
362
+ // Check navigation absolutely last since the check may block this thread.
359
363
NavigationButton selectedNavButton = NavigationButton .getSelectedNavigationButton ();
360
364
if (selectedNavButton == null ) {
361
365
return hideHome ; // Unknown tab, treat the same as home.
362
366
}
363
- if (selectedNavButton == NavigationButton .HOME ) {
364
- return hideHome ;
365
- }
366
- if (selectedNavButton == NavigationButton .SUBSCRIPTIONS ) {
367
- return hideSubscriptions ;
368
- }
369
- // User must be in the library tab. Don't hide the history or any playlists here.
370
- return false ;
367
+
368
+ return switch (selectedNavButton ) {
369
+ case HOME -> hideHome ;
370
+ case SUBSCRIPTIONS -> hideSubscriptions ;
371
+ case LIBRARY -> hideHistory ;
372
+ default -> false ;
373
+ };
371
374
}
372
375
376
+ /**
377
+ * Injection point. Only used if patching older than 19.03.
378
+ * This hook may be obsolete even for old versions
379
+ * as they now use a litho layout like newer versions.
380
+ */
373
381
public static void hideShortsShelf (final View shortsShelfView ) {
374
382
if (shouldHideShortsFeedItems ()) {
375
383
Utils .hideViewByLayoutParams (shortsShelfView );
0 commit comments