mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
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:
@ -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 "";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user