From c420891e3ef134f30af79cf2f30da3fa2fe5a455 Mon Sep 17 00:00:00 2001 From: nullptr <107796137+johnconner122@users.noreply.github.com> Date: Fri, 5 Apr 2024 00:09:42 +0300 Subject: [PATCH] fix(YouTube - Hide load more button): Include patch with `Hide layout components`, and hide button only in search feed (#600) --- .../patches/HideLoadMoreButtonPatch.java | 14 ------------- .../components/LayoutComponentsFilter.java | 21 +++++++++++++++++++ .../youtube/settings/Settings.java | 5 ++++- 3 files changed, 25 insertions(+), 15 deletions(-) delete mode 100644 app/src/main/java/app/revanced/integrations/youtube/patches/HideLoadMoreButtonPatch.java diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/HideLoadMoreButtonPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/HideLoadMoreButtonPatch.java deleted file mode 100644 index fa3a0e70..00000000 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/HideLoadMoreButtonPatch.java +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.integrations.youtube.patches; - -import android.view.View; - -import app.revanced.integrations.youtube.settings.Settings; -import app.revanced.integrations.shared.Utils; - -@SuppressWarnings("unused") -public class HideLoadMoreButtonPatch { - public static void hideLoadMoreButton(View view){ - if(!Settings.HIDE_LOAD_MORE_BUTTON.get()) return; - Utils.hideViewByLayoutParams(view); - } -} diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/LayoutComponentsFilter.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/LayoutComponentsFilter.java index f32ad545..8c52c2d8 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/LayoutComponentsFilter.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/LayoutComponentsFilter.java @@ -1,13 +1,17 @@ package app.revanced.integrations.youtube.patches.components; import android.os.Build; +import android.view.View; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; +import app.revanced.integrations.shared.Utils; import app.revanced.integrations.youtube.settings.Settings; import app.revanced.integrations.shared.Logger; import app.revanced.integrations.youtube.StringTrieSearch; +import app.revanced.integrations.youtube.shared.NavigationBar; +import app.revanced.integrations.youtube.shared.PlayerType; @SuppressWarnings("unused") public final class LayoutComponentsFilter extends Filter { @@ -322,7 +326,24 @@ public final class LayoutComponentsFilter extends Filter { return true; } + /** + * Injection point. + */ public static boolean showWatermark() { return !Settings.HIDE_VIDEO_CHANNEL_WATERMARK.get(); } + + private static final boolean HIDE_SHOW_MORE_BUTTON_ENABLED = Settings.HIDE_SHOW_MORE_BUTTON.get(); + + /** + * Injection point. + */ + public static void hideShowMoreButton(View view) { + if (HIDE_SHOW_MORE_BUTTON_ENABLED + && NavigationBar.isSearchBarActive() + // Search bar can be active but behind the player. + && !PlayerType.getCurrent().isMaximizedOrFullscreen()) { + Utils.hideViewByLayoutParams(view); + } + } } diff --git a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java index 75b03d51..714306f4 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java +++ b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java @@ -108,7 +108,8 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_KEYWORD_CONTENT_SEARCH = new BooleanSetting("revanced_hide_keyword_content_search", FALSE); public static final StringSetting HIDE_KEYWORD_CONTENT_PHRASES = new StringSetting("revanced_hide_keyword_content_phrases", "", parentsAny(HIDE_KEYWORD_CONTENT_HOME, HIDE_KEYWORD_CONTENT_SUBSCRIPTIONS, HIDE_KEYWORD_CONTENT_SEARCH)); - public static final BooleanSetting HIDE_LOAD_MORE_BUTTON = new BooleanSetting("revanced_hide_load_more_button", TRUE, true); + @Deprecated public static final BooleanSetting HIDE_LOAD_MORE_BUTTON = new BooleanSetting("revanced_hide_load_more_button", TRUE); + public static final BooleanSetting HIDE_SHOW_MORE_BUTTON = new BooleanSetting("revanced_hide_show_more_button", TRUE, true); public static final BooleanSetting HIDE_MEDICAL_PANELS = new BooleanSetting("revanced_hide_medical_panels", TRUE); public static final BooleanSetting HIDE_MIX_PLAYLISTS = new BooleanSetting("revanced_hide_mix_playlists", TRUE); public static final BooleanSetting HIDE_MOVIES_SECTION = new BooleanSetting("revanced_hide_movies_section", TRUE); @@ -384,6 +385,8 @@ public class Settings extends BaseSettings { HIDE_SHORTS_SEARCH.save(true); } + migrateOldSettingToNew(HIDE_LOAD_MORE_BUTTON, HIDE_SHOW_MORE_BUTTON); + // endregion } }