Skip to content

Commit

Permalink
fix(YouTube - Hide Shorts components): Do not show Shorts suggestions…
Browse files Browse the repository at this point in the history
… in video player, if all hide Shorts options are enabled (#613)
  • Loading branch information
LisoUseInAIKyrios authored Apr 12, 2024
1 parent 4fd3cc9 commit c132670
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,34 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
}

private static boolean shouldHideShortsFeedItems() {
final boolean hideHome = Settings.HIDE_SHORTS_HOME.get();
final boolean hideSubscriptions = Settings.HIDE_SHORTS_SUBSCRIPTIONS.get();
final boolean hideSearch = Settings.HIDE_SHORTS_SEARCH.get();

if (hideHome && hideSubscriptions && hideSearch) {
// Shorts suggestions can load in the background if a video is opened and
// then immediately minimized before any suggestions are loaded.
// In this state the player type will show minimized, which makes it not possible to
// distinguish between Shorts suggestions loading in the player and between
// scrolling thru search/home/subscription tabs while a player is minimized.
//
// To avoid this situation for users that never want to show Shorts (all hide Shorts options are enabled)
// then hide all Shorts everywhere including the Library history and Library playlists.
return true;
}

// Must check player type first, as search bar can be active behind the player.
if (PlayerType.getCurrent().isMaximizedOrFullscreen()) {
// For now, consider the under video results the same as the home feed.
return Settings.HIDE_SHORTS_HOME.get();
return hideHome;
}

// Must check second, as search can be from any tab.
if (NavigationBar.isSearchBarActive()) {
return Settings.HIDE_SHORTS_SEARCH.get();
return hideSearch;
}

// Avoid checking navigation button status if all other settings are off.
final boolean hideHome = Settings.HIDE_SHORTS_HOME.get();
final boolean hideSubscriptions = Settings.HIDE_SHORTS_SUBSCRIPTIONS.get();
// Avoid checking navigation button status if all other Shorts should show.
if (!hideHome && !hideSubscriptions) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ public static void navigationImageResourceTabLoaded(View view) {
*/
public static void navigationTabSelected(View navButtonImageView, boolean isSelected) {
try {
if (!isSelected) {
return;
}

NavigationButton button = viewToButtonMap.get(navButtonImageView);

if (button == null) { // An unknown tab was selected.
Expand All @@ -209,16 +213,11 @@ public static void navigationTabSelected(View navButtonImageView, boolean isSele
return;
}

if (isSelected) {
NavigationButton.selectedNavigationButton = button;
Logger.printDebug(() -> "Changed to navigation button: " + button);
NavigationButton.selectedNavigationButton = button;
Logger.printDebug(() -> "Changed to navigation button: " + button);

// Release any threads waiting for the selected nav button.
releaseNavButtonLatch();
} else if (NavigationButton.selectedNavigationButton == button) {
NavigationButton.selectedNavigationButton = null;
Logger.printDebug(() -> "Navigated away from button: " + button);
}
// Release any threads waiting for the selected nav button.
releaseNavButtonLatch();
} catch (Exception ex) {
Logger.printException(() -> "navigationTabSelected failure", ex);
}
Expand Down

0 comments on commit c132670

Please sign in to comment.