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,58 @@
package app.revanced.integrations.youtube.patches.components;

import android.view.View;

import androidx.annotation.Nullable;

import app.revanced.integrations.shared.Utils;
import app.revanced.integrations.youtube.patches.spoof.SpoofAppVersionPatch;
import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.youtube.shared.NavigationBar;

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

/**
* When spoofing to app versions 17.31.00 and older, the watch history preview bar uses
* the same layout components as the breaking news shelf.
*
* Breaking news does not appear to be present in these older versions anyways.
*/
private static final boolean isSpoofingOldVersionWithHorizontalCardListWatchHistory =
SpoofAppVersionPatch.isSpoofingToLessThan("18.01.00");

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() {
if (NavigationBar.NavigationButton.HOME.isSelected())
return Settings.HIDE_SUGGESTIONS_SHELF.get();

return false;
}

/**
* Injection point.
*/
public static void hideBreakingNews(View view) {
if (!Settings.HIDE_SUGGESTIONS_SHELF.get()
|| isSpoofingOldVersionWithHorizontalCardListWatchHistory) return;

Utils.hideViewByLayoutParams(view);
}
}
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", FALSE, 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