From da09b5b018be66a42b36fa9ff570ad1eceab506a Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Wed, 28 Aug 2024 17:00:56 +0900 Subject: [PATCH] fix(YouTube/Navigation bar components): navigation buttons are not hidden when `Cairo navigation bar` is applied (A/B tests) https://github.com/inotia00/ReVanced_Extended/issues/2169 --- .../AlternativeThumbnailsPatch.java | 4 ++-- .../components/KeywordContentFilter.java | 4 ++-- .../youtube/patches/general/GeneralPatch.java | 4 ++++ .../youtube/shared/NavigationBar.java | 20 +++++++++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/alternativethumbnails/AlternativeThumbnailsPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/alternativethumbnails/AlternativeThumbnailsPatch.java index 772b978134..1686169cbe 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/alternativethumbnails/AlternativeThumbnailsPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/alternativethumbnails/AlternativeThumbnailsPatch.java @@ -188,10 +188,10 @@ private static ThumbnailOption optionSettingForCurrentNavigation() { // Unknown tab, treat as the home tab; return homeOption; } - if (selectedNavButton == NavigationButton.HOME) { + if (selectedNavButton.isHomeTab()) { return homeOption; } - if (selectedNavButton == NavigationButton.SUBSCRIPTIONS || selectedNavButton == NavigationButton.NOTIFICATIONS) { + if (selectedNavButton.isSubscriptionsTab() || selectedNavButton.isNotificationTab()) { return subscriptionsOption; } // A library tab variant is active. diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/KeywordContentFilter.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/KeywordContentFilter.java index 4470d0452e..17e35f436f 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/KeywordContentFilter.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/KeywordContentFilter.java @@ -361,10 +361,10 @@ private boolean hideKeywordSettingIsActive() { if (selectedNavButton == null) { return hideHome; // Unknown tab, treat the same as home. } - if (selectedNavButton == NavigationButton.HOME) { + if (selectedNavButton.isHomeTab()) { return hideHome; } - if (selectedNavButton == NavigationButton.SUBSCRIPTIONS) { + if (selectedNavButton.isSubscriptionsTab()) { return hideSubscriptions; } // User is in the Library or Notifications tab. diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/general/GeneralPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/general/GeneralPatch.java index 7408f62c92..3c0f1969e6 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/general/GeneralPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/general/GeneralPatch.java @@ -256,10 +256,14 @@ public static boolean hideSnackBar() { private static final Map shouldHideMap = new EnumMap<>(NavigationButton.class) { { put(NavigationButton.HOME, Settings.HIDE_NAVIGATION_HOME_BUTTON.get()); + put(NavigationButton.HOME_CAIRO, Settings.HIDE_NAVIGATION_HOME_BUTTON.get()); put(NavigationButton.SHORTS, Settings.HIDE_NAVIGATION_SHORTS_BUTTON.get()); + put(NavigationButton.SHORTS_CAIRO, Settings.HIDE_NAVIGATION_SHORTS_BUTTON.get()); put(NavigationButton.SUBSCRIPTIONS, Settings.HIDE_NAVIGATION_SUBSCRIPTIONS_BUTTON.get()); + put(NavigationButton.SUBSCRIPTIONS_CAIRO, Settings.HIDE_NAVIGATION_SUBSCRIPTIONS_BUTTON.get()); put(NavigationButton.CREATE, Settings.HIDE_NAVIGATION_CREATE_BUTTON.get()); put(NavigationButton.NOTIFICATIONS, Settings.HIDE_NAVIGATION_NOTIFICATIONS_BUTTON.get()); + put(NavigationButton.NOTIFICATIONS_CAIRO, Settings.HIDE_NAVIGATION_NOTIFICATIONS_BUTTON.get()); put(NavigationButton.LIBRARY_LOGGED_OUT, Settings.HIDE_NAVIGATION_LIBRARY_BUTTON.get()); put(NavigationButton.LIBRARY_INCOGNITO, Settings.HIDE_NAVIGATION_LIBRARY_BUTTON.get()); diff --git a/app/src/main/java/app/revanced/integrations/youtube/shared/NavigationBar.java b/app/src/main/java/app/revanced/integrations/youtube/shared/NavigationBar.java index a9f7f09826..a45a4facc8 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/shared/NavigationBar.java +++ b/app/src/main/java/app/revanced/integrations/youtube/shared/NavigationBar.java @@ -238,18 +238,22 @@ private static void navigationTabCreatedCallback(NavigationButton button, View t public enum NavigationButton { HOME("PIVOT_HOME"), + HOME_CAIRO("TAB_HOME_CAIRO"), SHORTS("TAB_SHORTS"), + SHORTS_CAIRO("TAB_SHORTS_CAIRO"), /** * Create new video tab. * This tab will never be in a selected state, even if the create video UI is on screen. */ CREATE("CREATION_TAB_LARGE"), SUBSCRIPTIONS("PIVOT_SUBSCRIPTIONS"), + SUBSCRIPTIONS_CAIRO("TAB_SUBSCRIPTIONS_CAIRO"), /** * Notifications tab. Only present when * {@link Settings#SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON} is active. */ NOTIFICATIONS("TAB_ACTIVITY"), + NOTIFICATIONS_CAIRO("TAB_ACTIVITY_CAIRO"), /** * Library tab when the user is not logged in. */ @@ -309,6 +313,22 @@ public static NavigationButton getSelectedNavigationButton() { this.ytEnumName = ytEnumName; } + public boolean isHomeTab() { + return this == HOME || this == HOME_CAIRO; + } + + public boolean isShortsTab() { + return this == SHORTS || this == SHORTS_CAIRO; + } + + public boolean isSubscriptionsTab() { + return this == SUBSCRIPTIONS || this == SUBSCRIPTIONS_CAIRO; + } + + public boolean isNotificationTab() { + return this == NOTIFICATIONS || this == NOTIFICATIONS_CAIRO; + } + public boolean isLibraryOrYouTab() { return this == LIBRARY_YOU || this == LIBRARY_PIVOT_UNKNOWN || this == LIBRARY_OLD_UI || this == LIBRARY_INCOGNITO