Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix: playlist shelf still gets hidden sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnconner122 committed Sep 26, 2023
1 parent faa89cd commit 402e85c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public class SuggestionsShelfFilter extends Filter {
SettingsEnum.SPOOF_APP_VERSION.getBoolean()
&& SettingsEnum.SPOOF_APP_VERSION_TARGET.getString().compareTo("17.08.35") <= 0;

// Must be volatile or synchronized, as litho filtering runs off main thread and this field is then access from the main thread.
public static volatile boolean isLibraryRecentShelfVisible;
public static volatile boolean isHomeFeedVisible;

public SuggestionsShelfFilter() {
pathFilterGroupList.addAll(
new StringFilterGroup(
Expand All @@ -31,11 +35,15 @@ public SuggestionsShelfFilter() {
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
FilterGroupList matchedList, FilterGroup matchedGroup, int matchedIndex) {
// Only one filter is added, so the matched group must be the horizontal video shelf.
if (path.contains("library_recent_shelf"))
if (path.contains("library_recent_shelf")) {
// If the library shelf is detected, set the current navbar index to 4
NavBarIndexHook.setCurrentNavBarIndex(4);

else if (NavBarIndexHook.isNotLibraryTab())
isLibraryRecentShelfVisible = true;
} else if (path.contains("more_drawer")) {
// If drawer button is detected, set the current NavBar index to zero
NavBarIndexHook.setCurrentNavBarIndex(0);
isHomeFeedVisible = true;
} else if (NavBarIndexHook.isNotLibraryTab())
// When the Library Tab is not detected, hide the suggestion shelf
return super.isFiltered(path, identifier, protobufBufferArray, matchedList, matchedGroup, matchedIndex);

Expand All @@ -44,7 +52,7 @@ else if (NavBarIndexHook.isNotLibraryTab())

/**
* Injection point.
*
* <p>
* Only used to hide breaking news on tablet layout which still uses the old UI components.
*/
public static void hideBreakingNews(View view) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.content.Context;

import app.revanced.integrations.patches.components.SuggestionsShelfFilter;

public class NavBarIndexHook {

private static int currentNavBarIndex = 0;
Expand All @@ -20,6 +22,16 @@ public static void setCurrentNavBarIndex(int navBarIndex) {
}

public static void setLastNavBarIndex() {
// if we come to back to Library fragment from any other like downloads page, playlists, your videos, or your clips
// NavBar index should still be same
if (SuggestionsShelfFilter.isLibraryRecentShelfVisible && currentNavBarIndex == 4)
return;

// if we come to back to Home fragment from any other like trending, or news, or sports page
// NavBar index should still be same
if (SuggestionsShelfFilter.isHomeFeedVisible && currentNavBarIndex == 0)
return;

currentNavBarIndex = lastNavBarIndex;
}

Expand Down

0 comments on commit 402e85c

Please sign in to comment.