fix(YouTube - Hide Shorts components): Do not show Shorts suggestions in video player, if all hide Shorts options are enabled (#613)

This commit is contained in:
LisoUseInAIKyrios 2024-04-12 20:55:57 +04:00 committed by GitHub
parent 4fd3cc906d
commit c132670400
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 14 deletions

View File

@ -220,20 +220,34 @@ public final class ShortsFilter extends Filter {
}
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;
}

View File

@ -197,6 +197,10 @@ public final class NavigationBar {
*/
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.
@ -209,16 +213,11 @@ public final class NavigationBar {
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);
}