Skip to content
This repository was archived by the owner on Oct 26, 2024. It is now read-only.

feat(YouTube - Hide layout components): Add option to hide horizontal shelves #598

Merged
merged 13 commits into from
Apr 6, 2024
Merged

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package app.revanced.integrations.youtube.patches.components;

import androidx.annotation.Nullable;

import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.youtube.shared.NavigationBar;
import app.revanced.integrations.youtube.shared.PlayerType;

@SuppressWarnings("unused")
public final class SuggestionsShelfFilter extends Filter {

public SuggestionsShelfFilter() {
addPathCallbacks(
new StringFilterGroup(
null, // Setting is based on navigation state.
"horizontal_video_shelf.eml",
"horizontal_shelf.eml"
)
);
}

@Override
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (shouldHideSuggestionsShelf() && contentIndex == 0)
return super.isFiltered(path, identifier, protobufBufferArray, matchedGroup, contentType, contentIndex);

return false;
}

private static boolean shouldHideSuggestionsShelf() {
return Settings.HIDE_SUGGESTIONS_SHELF.get()
&& NavigationBar.NavigationButton.HOME.isSelected() // Home tab is selected.
&& !PlayerType.getCurrent().isMaximizedOrFullscreen() // The player is not opened.
&& !NavigationBar.isSearchBarActive(); // Search is not active.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_ALBUM_CARDS = new BooleanSetting("revanced_hide_album_cards", FALSE, true);
public static final BooleanSetting HIDE_ARTIST_CARDS = new BooleanSetting("revanced_hide_artist_cards", FALSE);
public static final BooleanSetting HIDE_AUTOPLAY_BUTTON = new BooleanSetting("revanced_hide_autoplay_button", TRUE, true);
public static final BooleanSetting HIDE_BREAKING_NEWS = new BooleanSetting("revanced_hide_breaking_news", TRUE, true);
public static final BooleanSetting HIDE_SUGGESTIONS_SHELF = new BooleanSetting("revanced_hide_suggestions_shelf", TRUE);
public static final BooleanSetting HIDE_CAPTIONS_BUTTON = new BooleanSetting("revanced_hide_captions_button", FALSE);
public static final BooleanSetting HIDE_CAST_BUTTON = new BooleanSetting("revanced_hide_cast_button", TRUE, true);
public static final BooleanSetting HIDE_CHANNEL_BAR = new BooleanSetting("revanced_hide_channel_bar", FALSE);
Expand Down
Loading