mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-06-10 23:27:54 +02:00
Comments, logging
This commit is contained in:
parent
c4e4d7880c
commit
9b43c3c7d8
|
@ -5,6 +5,8 @@ import androidx.annotation.GuardedBy;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import app.revanced.integrations.shared.settings.BaseSettings;
|
||||
import app.revanced.integrations.shared.settings.EnumSetting;
|
||||
import app.revanced.integrations.shared.settings.Setting;
|
||||
import app.revanced.integrations.youtube.settings.Settings;
|
||||
import app.revanced.integrations.shared.Logger;
|
||||
|
@ -129,6 +131,11 @@ public final class AlternativeThumbnailsPatch {
|
|||
*/
|
||||
private static volatile long timeToResumeDeArrowAPICalls;
|
||||
|
||||
/**
|
||||
* Used only for debug logging.
|
||||
*/
|
||||
private static volatile EnumSetting<ThumbnailOption> currentOptionSetting;
|
||||
|
||||
static {
|
||||
dearrowApiUri = validateSettings();
|
||||
final int port = dearrowApiUri.getPort();
|
||||
|
@ -152,19 +159,19 @@ public final class AlternativeThumbnailsPatch {
|
|||
return apiUri;
|
||||
}
|
||||
|
||||
private static ThumbnailOption thumbnailOptionForCurrentNavigation() {
|
||||
private static EnumSetting<ThumbnailOption> optionSettingForCurrentNavigation() {
|
||||
if (NavigationBar.isSearchBarActive()) { // Must check search first.
|
||||
return ALT_THUMBNAIL_SEARCH.get();
|
||||
return ALT_THUMBNAIL_SEARCH;
|
||||
}
|
||||
if (NavigationButton.HOME.isSelected()
|
||||
|| PlayerType.getCurrent().isMaximizedOrFullscreen()) {
|
||||
return ALT_THUMBNAIL_HOME.get();
|
||||
return ALT_THUMBNAIL_HOME;
|
||||
}
|
||||
if (NavigationButton.libraryOrYouTabIsSelected()) {
|
||||
return ALT_THUMBNAIL_WATCH_HISTORY.get();
|
||||
return ALT_THUMBNAIL_WATCH_HISTORY;
|
||||
}
|
||||
// User is in the subscription or notification tab.
|
||||
return ALT_THUMBNAIL_SUBSCRIPTIONS.get();
|
||||
return ALT_THUMBNAIL_SUBSCRIPTIONS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,7 +249,15 @@ public final class AlternativeThumbnailsPatch {
|
|||
*/
|
||||
public static String overrideImageURL(String originalUrl) {
|
||||
try {
|
||||
ThumbnailOption option = thumbnailOptionForCurrentNavigation();
|
||||
EnumSetting<ThumbnailOption> optionSetting = optionSettingForCurrentNavigation();
|
||||
ThumbnailOption option = optionSetting.get();
|
||||
if (BaseSettings.DEBUG.get()) {
|
||||
if (currentOptionSetting != optionSetting) {
|
||||
currentOptionSetting = optionSetting;
|
||||
Logger.printDebug(() -> "Changed to setting: " + optionSetting.key);
|
||||
}
|
||||
}
|
||||
|
||||
if (option == ThumbnailOption.ORIGINAL) {
|
||||
return originalUrl;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ final class CustomFilter extends Filter {
|
|||
public static final String SYNTAX_BUFFER_SYMBOL = "$";
|
||||
|
||||
/**
|
||||
* @return the parsed objects, or NULL if there was a parse error.
|
||||
* @return the parsed objects
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
|
|
|
@ -2,6 +2,7 @@ package app.revanced.integrations.youtube.shared;
|
|||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.Nullable;
|
||||
import app.revanced.integrations.shared.Logger;
|
||||
|
@ -30,6 +31,19 @@ public final class NavigationBar {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* When the search bar is dismissed, YT uses a fade out animation
|
||||
* and during the fade out this method will still report the search is active
|
||||
* even though it's being dismissed.
|
||||
*
|
||||
* Depending on which hook this is called from,
|
||||
* if switching tabs with search active then this may return an outdated value.
|
||||
*
|
||||
* @return If the search bar is on screen.
|
||||
* A value of 'false' always means search is not active,
|
||||
* but a value of 'true' can be a false positive if the search is being dismissed
|
||||
* or the navigation tab is changing when search is on screen.
|
||||
*/
|
||||
public static boolean isSearchBarActive() {
|
||||
return searchbarIsActive;
|
||||
}
|
||||
|
@ -99,7 +113,7 @@ public final class NavigationBar {
|
|||
}
|
||||
|
||||
/** @noinspection EmptyMethod*/
|
||||
private static void navigationTabCreatedCallback(NavigationBar.NavigationButton button, View tabView) {
|
||||
private static void navigationTabCreatedCallback(NavigationButton button, View tabView) {
|
||||
// Code is added during patching.
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user