mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-21 09:17:33 +01:00
feat(YouTube - Hide layout components): Add option to hide horizontal shelves (#598)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de> Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
This commit is contained in:
parent
bddcc97392
commit
fedace02fd
@ -1,29 +0,0 @@
|
|||||||
package app.revanced.integrations.youtube.patches;
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import app.revanced.integrations.youtube.patches.spoof.SpoofAppVersionPatch;
|
|
||||||
import app.revanced.integrations.youtube.settings.Settings;
|
|
||||||
import app.revanced.integrations.shared.Utils;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public class HideBreakingNewsPatch {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Injection point.
|
|
||||||
*/
|
|
||||||
public static void hideBreakingNews(View view) {
|
|
||||||
if (!Settings.HIDE_BREAKING_NEWS.get()
|
|
||||||
|| isSpoofingOldVersionWithHorizontalCardListWatchHistory) return;
|
|
||||||
Utils.hideViewByLayoutParams(view);
|
|
||||||
}
|
|
||||||
}
|
|
@ -35,6 +35,7 @@ public final class LayoutComponentsFilter extends Filter {
|
|||||||
private final StringFilterGroup compactChannelBarInner;
|
private final StringFilterGroup compactChannelBarInner;
|
||||||
private final StringFilterGroup compactChannelBarInnerButton;
|
private final StringFilterGroup compactChannelBarInnerButton;
|
||||||
private final ByteArrayFilterGroup joinMembershipButton;
|
private final ByteArrayFilterGroup joinMembershipButton;
|
||||||
|
private final StringFilterGroup horizontalShelves;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
mixPlaylistsExceptions.addPatterns(
|
mixPlaylistsExceptions.addPatterns(
|
||||||
@ -43,7 +44,6 @@ public final class LayoutComponentsFilter extends Filter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
public LayoutComponentsFilter() {
|
public LayoutComponentsFilter() {
|
||||||
exceptions.addPatterns(
|
exceptions.addPatterns(
|
||||||
@ -237,6 +237,12 @@ public final class LayoutComponentsFilter extends Filter {
|
|||||||
"endorsement_header_footer"
|
"endorsement_header_footer"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
horizontalShelves = new StringFilterGroup(
|
||||||
|
Settings.HIDE_HORIZONTAL_SHELVES,
|
||||||
|
"horizontal_video_shelf.eml",
|
||||||
|
"horizontal_shelf.eml"
|
||||||
|
);
|
||||||
|
|
||||||
addPathCallbacks(
|
addPathCallbacks(
|
||||||
expandableMetadata,
|
expandableMetadata,
|
||||||
inFeedSurvey,
|
inFeedSurvey,
|
||||||
@ -263,7 +269,8 @@ public final class LayoutComponentsFilter extends Filter {
|
|||||||
timedReactions,
|
timedReactions,
|
||||||
imageShelf,
|
imageShelf,
|
||||||
channelMemberShelf,
|
channelMemberShelf,
|
||||||
forYouShelf
|
forYouShelf,
|
||||||
|
horizontalShelves
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +286,9 @@ public final class LayoutComponentsFilter extends Filter {
|
|||||||
// The groups are excluded from the filter due to the exceptions list below.
|
// The groups are excluded from the filter due to the exceptions list below.
|
||||||
// Filter them separately here.
|
// Filter them separately here.
|
||||||
if (matchedGroup == notifyMe || matchedGroup == inFeedSurvey || matchedGroup == expandableMetadata)
|
if (matchedGroup == notifyMe || matchedGroup == inFeedSurvey || matchedGroup == expandableMetadata)
|
||||||
|
{
|
||||||
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
||||||
|
}
|
||||||
|
|
||||||
if (exceptions.matches(path)) return false; // Exceptions are not filtered.
|
if (exceptions.matches(path)) return false; // Exceptions are not filtered.
|
||||||
|
|
||||||
@ -298,6 +307,10 @@ public final class LayoutComponentsFilter extends Filter {
|
|||||||
// TODO: This also hides the feed Shorts shelf header
|
// TODO: This also hides the feed Shorts shelf header
|
||||||
if (matchedGroup == searchResultShelfHeader && contentIndex != 0) return false;
|
if (matchedGroup == searchResultShelfHeader && contentIndex != 0) return false;
|
||||||
|
|
||||||
|
if (contentIndex == 0 && matchedGroup == horizontalShelves && hideShelves()) {
|
||||||
|
return super.isFiltered(path, identifier, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
||||||
|
}
|
||||||
|
|
||||||
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,4 +359,15 @@ public final class LayoutComponentsFilter extends Filter {
|
|||||||
Utils.hideViewByLayoutParams(view);
|
Utils.hideViewByLayoutParams(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean hideShelves() {
|
||||||
|
// Only filter if the library tab is not selected.
|
||||||
|
// This check is important as the shelf layout is used for the library tab playlists.
|
||||||
|
return !NavigationBar.NavigationButton.libraryOrYouTabIsSelected()
|
||||||
|
// But if the player is opened while library is selected,
|
||||||
|
// then still filter any recommendations below the player.
|
||||||
|
|| PlayerType.getCurrent().isMaximizedOrFullscreen()
|
||||||
|
// Or if the search is active while library is selected, then also filter.
|
||||||
|
|| NavigationBar.isSearchBarActive();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ public class Settings extends BaseSettings {
|
|||||||
public static final BooleanSetting HIDE_SELF_SPONSOR = new BooleanSetting("revanced_hide_self_sponsor_ads", TRUE);
|
public static final BooleanSetting HIDE_SELF_SPONSOR = new BooleanSetting("revanced_hide_self_sponsor_ads", TRUE);
|
||||||
public static final BooleanSetting HIDE_VIDEO_ADS = new BooleanSetting("revanced_hide_video_ads", TRUE, true);
|
public static final BooleanSetting HIDE_VIDEO_ADS = new BooleanSetting("revanced_hide_video_ads", TRUE, true);
|
||||||
public static final BooleanSetting HIDE_WEB_SEARCH_RESULTS = new BooleanSetting("revanced_hide_web_search_results", TRUE);
|
public static final BooleanSetting HIDE_WEB_SEARCH_RESULTS = new BooleanSetting("revanced_hide_web_search_results", TRUE);
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
public static final EnumSetting<ThumbnailOption> ALT_THUMBNAIL_HOME = new EnumSetting<>("revanced_alt_thumbnail_home", ThumbnailOption.ORIGINAL);
|
public static final EnumSetting<ThumbnailOption> ALT_THUMBNAIL_HOME = new EnumSetting<>("revanced_alt_thumbnail_home", ThumbnailOption.ORIGINAL);
|
||||||
public static final EnumSetting<ThumbnailOption> ALT_THUMBNAIL_SUBSCRIPTIONS = new EnumSetting<>("revanced_alt_thumbnail_subscription", ThumbnailOption.ORIGINAL);
|
public static final EnumSetting<ThumbnailOption> ALT_THUMBNAIL_SUBSCRIPTIONS = new EnumSetting<>("revanced_alt_thumbnail_subscription", ThumbnailOption.ORIGINAL);
|
||||||
@ -76,7 +77,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_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_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_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_HORIZONTAL_SHELVES = new BooleanSetting("revanced_hide_horizontal_shelves", TRUE);
|
||||||
public static final BooleanSetting HIDE_CAPTIONS_BUTTON = new BooleanSetting("revanced_hide_captions_button", FALSE);
|
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_CAST_BUTTON = new BooleanSetting("revanced_hide_cast_button", TRUE, true);
|
||||||
public static final BooleanSetting HIDE_CHANNEL_BAR = new BooleanSetting("revanced_hide_channel_bar", FALSE);
|
public static final BooleanSetting HIDE_CHANNEL_BAR = new BooleanSetting("revanced_hide_channel_bar", FALSE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user