mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
fix(YouTube): No longer setting the resource Id of a field in the Constructor method
This commit is contained in:
@ -29,6 +29,7 @@ public class BaseSettings {
|
||||
public static final BooleanSetting HIDE_PROMOTION_ALERT_BANNER = new BooleanSetting("revanced_hide_promotion_alert_banner", TRUE);
|
||||
|
||||
public static final BooleanSetting DISABLE_AUTO_CAPTIONS = new BooleanSetting("revanced_disable_auto_captions", FALSE, true);
|
||||
public static final BooleanSetting DISABLE_QUIC_PROTOCOL = new BooleanSetting("revanced_disable_quic_protocol", FALSE, true);
|
||||
|
||||
public static final BooleanSetting BYPASS_IMAGE_REGION_RESTRICTIONS = new BooleanSetting("revanced_bypass_image_region_restrictions", FALSE, true);
|
||||
public static final BooleanSetting RETURN_YOUTUBE_USERNAME_ENABLED = new BooleanSetting("revanced_return_youtube_username_enabled", FALSE, true);
|
||||
|
@ -110,14 +110,8 @@ public class StringRef extends Utils {
|
||||
? mActivity
|
||||
: getContext();
|
||||
if (resources == null) {
|
||||
resources = getResources();
|
||||
resources = context.getResources();
|
||||
}
|
||||
if (resources != null) {
|
||||
value = ResourceUtils.getString(value);
|
||||
resolved = true;
|
||||
return value;
|
||||
}
|
||||
resources = context.getResources();
|
||||
if (resources != null) {
|
||||
final String packageName = context.getPackageName();
|
||||
final int identifier = resources.getIdentifier(value, "string", packageName);
|
||||
|
@ -311,8 +311,8 @@ public class GeneralPatch {
|
||||
|
||||
// region [Toolbar components] patch
|
||||
|
||||
private static final int generalHeaderAttributeId = ResourceUtils.getAttrIdentifier("ytWordmarkHeader");
|
||||
private static final int premiumHeaderAttributeId = ResourceUtils.getAttrIdentifier("ytPremiumWordmarkHeader");
|
||||
private static int generalHeaderAttributeId = 0;
|
||||
private static int premiumHeaderAttributeId = 0;
|
||||
|
||||
public static void setDrawerNavigationHeader(View lithoView) {
|
||||
final int headerAttributeId = getHeaderAttributeId();
|
||||
@ -330,6 +330,11 @@ public class GeneralPatch {
|
||||
}
|
||||
|
||||
public static int getHeaderAttributeId() {
|
||||
if (premiumHeaderAttributeId == 0) {
|
||||
generalHeaderAttributeId = ResourceUtils.getAttrIdentifier("ytWordmarkHeader");
|
||||
premiumHeaderAttributeId = ResourceUtils.getAttrIdentifier("ytPremiumWordmarkHeader");
|
||||
}
|
||||
|
||||
return Settings.CHANGE_YOUTUBE_HEADER.get()
|
||||
? premiumHeaderAttributeId
|
||||
: generalHeaderAttributeId;
|
||||
@ -344,11 +349,6 @@ public class GeneralPatch {
|
||||
return ResourceUtils.getDrawable("");
|
||||
}
|
||||
|
||||
private static final int searchBarId = ResourceUtils.getIdIdentifier("search_bar");
|
||||
private static final int youtubeTextId = ResourceUtils.getIdIdentifier("youtube_text");
|
||||
private static final int searchBoxId = ResourceUtils.getIdIdentifier("search_box");
|
||||
private static final int searchIconId = ResourceUtils.getIdIdentifier("search_icon");
|
||||
|
||||
private static final boolean wideSearchbarEnabled = Settings.ENABLE_WIDE_SEARCH_BAR.get();
|
||||
// Loads the search bar deprecated by Google.
|
||||
private static final boolean wideSearchbarWithHeaderEnabled = Settings.ENABLE_WIDE_SEARCH_BAR_WITH_HEADER.get();
|
||||
@ -384,16 +384,30 @@ public class GeneralPatch {
|
||||
return !wideSearchbarYouTabEnabled && original;
|
||||
}
|
||||
|
||||
private static int searchBarId = 0;
|
||||
private static int youtubeTextId = 0;
|
||||
private static int searchBoxId = 0;
|
||||
private static int searchIconId = 0;
|
||||
|
||||
public static void setWideSearchBarLayout(View view) {
|
||||
if (!wideSearchbarEnabled)
|
||||
return;
|
||||
|
||||
if (searchBarId == 0) {
|
||||
searchBarId = ResourceUtils.getIdIdentifier("search_bar");
|
||||
}
|
||||
|
||||
if (!(view.findViewById(searchBarId) instanceof RelativeLayout searchBarView))
|
||||
return;
|
||||
|
||||
// When the deprecated search bar is loaded, two search bars overlap.
|
||||
// Manually hides another search bar.
|
||||
if (wideSearchbarWithHeaderEnabled) {
|
||||
if (youtubeTextId == 0) {
|
||||
youtubeTextId = ResourceUtils.getIdIdentifier("youtube_text");
|
||||
searchBoxId = ResourceUtils.getIdIdentifier("search_box");
|
||||
searchIconId = ResourceUtils.getIdIdentifier("search_icon");
|
||||
}
|
||||
final View searchIconView = searchBarView.findViewById(searchIconId);
|
||||
final View searchBoxView = searchBarView.findViewById(searchBoxId);
|
||||
final View textView = searchBarView.findViewById(youtubeTextId);
|
||||
@ -508,16 +522,18 @@ public class GeneralPatch {
|
||||
imageView.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
private static final int settingsDrawableId =
|
||||
ResourceUtils.getDrawableIdentifier("yt_outline_gear_black_24");
|
||||
private static final int settingsCairoDrawableId =
|
||||
ResourceUtils.getDrawableIdentifier("yt_outline_gear_cairo_black_24");
|
||||
private static int settingsDrawableId = 0;
|
||||
private static int settingsCairoDrawableId = 0;
|
||||
|
||||
public static int getCreateButtonDrawableId(int original) {
|
||||
if (!Settings.REPLACE_TOOLBAR_CREATE_BUTTON.get()) {
|
||||
return original;
|
||||
}
|
||||
|
||||
if (settingsDrawableId == 0) {
|
||||
settingsDrawableId = ResourceUtils.getDrawableIdentifier("yt_outline_gear_black_24");
|
||||
}
|
||||
|
||||
if (settingsDrawableId == 0) {
|
||||
return original;
|
||||
}
|
||||
@ -528,6 +544,10 @@ public class GeneralPatch {
|
||||
return settingsDrawableId;
|
||||
}
|
||||
|
||||
if (settingsCairoDrawableId == 0) {
|
||||
settingsCairoDrawableId = ResourceUtils.getDrawableIdentifier("yt_outline_gear_cairo_black_24");
|
||||
}
|
||||
|
||||
return settingsCairoDrawableId == 0
|
||||
? settingsDrawableId
|
||||
: settingsCairoDrawableId;
|
||||
|
@ -1,17 +1,11 @@
|
||||
package app.revanced.extension.youtube.patches.misc;
|
||||
|
||||
import app.revanced.extension.shared.utils.Logger;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class QUICProtocolPatch {
|
||||
|
||||
public static boolean disableQUICProtocol(boolean original) {
|
||||
try {
|
||||
return !Settings.DISABLE_QUIC_PROTOCOL.get() && original;
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "Failed to load disableQUICProtocol", ex);
|
||||
}
|
||||
return original;
|
||||
return !BaseSettings.DISABLE_QUIC_PROTOCOL.get() && original;
|
||||
}
|
||||
}
|
||||
|
@ -41,11 +41,9 @@ public final class AnimationFeedbackPatch {
|
||||
|
||||
private static final boolean HIDE_PLAY_PAUSE_FEEDBACK = Settings.HIDE_SHORTS_PLAY_PAUSE_BUTTON_BACKGROUND.get();
|
||||
|
||||
private static final int PAUSE_TAP_FEEDBACK_HIDDEN
|
||||
= ResourceUtils.getRawIdentifier("pause_tap_feedback_hidden");
|
||||
private static int PAUSE_TAP_FEEDBACK_HIDDEN = 0;
|
||||
|
||||
private static final int PLAY_TAP_FEEDBACK_HIDDEN
|
||||
= ResourceUtils.getRawIdentifier("play_tap_feedback_hidden");
|
||||
private static int PLAY_TAP_FEEDBACK_HIDDEN = 0;
|
||||
|
||||
|
||||
/**
|
||||
@ -66,8 +64,12 @@ public final class AnimationFeedbackPatch {
|
||||
if (!HIDE_PLAY_PAUSE_FEEDBACK) {
|
||||
return;
|
||||
}
|
||||
|
||||
LottieAnimationViewPatch.setLottieAnimationRawResources(lottieAnimationView, PAUSE_TAP_FEEDBACK_HIDDEN);
|
||||
if (PAUSE_TAP_FEEDBACK_HIDDEN == 0) {
|
||||
PAUSE_TAP_FEEDBACK_HIDDEN = ResourceUtils.getRawIdentifier("pause_tap_feedback_hidden");
|
||||
}
|
||||
if (PAUSE_TAP_FEEDBACK_HIDDEN != 0) {
|
||||
LottieAnimationViewPatch.setLottieAnimationRawResources(lottieAnimationView, PAUSE_TAP_FEEDBACK_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,8 +79,12 @@ public final class AnimationFeedbackPatch {
|
||||
if (!HIDE_PLAY_PAUSE_FEEDBACK) {
|
||||
return;
|
||||
}
|
||||
|
||||
LottieAnimationViewPatch.setLottieAnimationRawResources(lottieAnimationView, PLAY_TAP_FEEDBACK_HIDDEN);
|
||||
if (PLAY_TAP_FEEDBACK_HIDDEN == 0) {
|
||||
PLAY_TAP_FEEDBACK_HIDDEN = ResourceUtils.getRawIdentifier("play_tap_feedback_hidden");
|
||||
}
|
||||
if (PLAY_TAP_FEEDBACK_HIDDEN != 0) {
|
||||
LottieAnimationViewPatch.setLottieAnimationRawResources(lottieAnimationView, PLAY_TAP_FEEDBACK_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -552,7 +552,6 @@ public class Settings extends BaseSettings {
|
||||
// PreferenceScreen: Miscellaneous
|
||||
public static final BooleanSetting ENABLE_EXTERNAL_BROWSER = new BooleanSetting("revanced_enable_external_browser", TRUE, true);
|
||||
public static final BooleanSetting ENABLE_OPEN_LINKS_DIRECTLY = new BooleanSetting("revanced_enable_open_links_directly", TRUE);
|
||||
public static final BooleanSetting DISABLE_QUIC_PROTOCOL = new BooleanSetting("revanced_disable_quic_protocol", FALSE, true);
|
||||
|
||||
// Experimental Flags
|
||||
public static final BooleanSetting CHANGE_SHARE_SHEET = new BooleanSetting("revanced_change_share_sheet", FALSE, true);
|
||||
|
Reference in New Issue
Block a user