refactor(YouTube - PlayerTypeHook): Use search query instead of View to determine whether a user is in search results or not

This commit is contained in:
inotia00
2024-12-08 11:50:12 +09:00
parent 19bce281ef
commit e0bdce0c19
4 changed files with 50 additions and 43 deletions

View File

@ -2,20 +2,8 @@ package app.revanced.extension.youtube.shared;
import static app.revanced.extension.youtube.patches.components.RelatedVideoFilter.isActionBarVisible;
import android.view.View;
import java.lang.ref.WeakReference;
@SuppressWarnings("unused")
public final class RootView {
private static volatile WeakReference<View> searchBarResultsRef = new WeakReference<>(null);
/**
* Injection point.
*/
public static void searchBarResultsViewLoaded(View searchbarResults) {
searchBarResultsRef = new WeakReference<>(searchbarResults);
}
/**
* @return If the search bar is on screen. This includes if the player
@ -23,8 +11,8 @@ public final class RootView {
* Detecting the search is covered by the player can be done by checking {@link RootView#isPlayerActive()}.
*/
public static boolean isSearchBarActive() {
View searchbarResults = searchBarResultsRef.get();
return searchbarResults != null && searchbarResults.getParent() != null;
String searchQuery = getSearchQuery();
return !searchQuery.isEmpty();
}
public static boolean isPlayerActive() {
@ -38,4 +26,12 @@ public final class RootView {
public static String getBrowseId() {
return "";
}
/**
* Get current SearchQuery.
* Rest of the implementation added by patch.
*/
public static String getSearchQuery() {
return "";
}
}