Skip to content

Commit

Permalink
fix(YouTube/Navigation bar components): navigation buttons are not hi…
Browse files Browse the repository at this point in the history
…dden when `Cairo navigation bar` is applied (A/B tests) inotia00/ReVanced_Extended#2169
  • Loading branch information
inotia00 committed Aug 28, 2024
1 parent eead4ce commit da09b5b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,14 @@ public static boolean hideSnackBar() {
private static final Map<NavigationButton, Boolean> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit da09b5b

Please sign in to comment.