From ce01062e4d923264870685c8f8da8e793b2c0903 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 29 Dec 2023 19:09:03 +0100 Subject: [PATCH 1/3] feat(YouTube - GmsCore support): Check for availability by adding a patch to add resources without needing to rely on a settings patch --- api/revanced-patches.api | 184 +++++++++--------- .../all/misc/strings/AddResourcesPatch.kt | 53 +++++ .../music/misc/gms/GmsCoreSupportPatch.kt | 6 +- .../misc/gms/GmsCoreSupportResourcePatch.kt | 2 +- .../misc/integrations/IntegrationsPatch.kt | 13 ++ .../ApplicationInitFingerprint.kt | 19 ++ .../CastContextFetchFingerprint.kt | 2 +- .../fingerprints/HomeActivityFingerprint.kt | 9 - .../misc/gms/AbstractGmsCoreSupportPatch.kt | 19 +- .../AbstractGmsCoreSupportResourcePatch.kt | 7 +- .../fingerprints/GmsCoreSupportFingerprint.kt | 2 +- .../settings/AbstractSettingsResourcePatch.kt | 133 ++++--------- .../settings/preference/BasePreference.kt | 3 +- .../preference/ComponentsExtensions.kt | 25 +-- .../preference/DefaultBasePreference.kt | 3 +- .../{Preference.kt => IntentPreference.kt} | 13 +- .../preference/impl/ListPreference.kt | 4 +- .../impl/NonInteractivePreference.kt | 3 +- .../preference/impl/PreferenceCategory.kt | 3 +- .../preference/impl/PreferenceScreen.kt | 3 +- .../preference/impl/SwitchPreference.kt | 8 +- .../preference/impl/TextPreference.kt | 4 +- .../settings/util/AbstractPreferenceScreen.kt | 9 +- .../patches/twitch/ad/audio/AudioAdsPatch.kt | 2 +- .../twitch/ad/embedded/EmbeddedAdsPatch.kt | 25 ++- .../patches/twitch/ad/video/VideoAdsPatch.kt | 2 +- .../antidelete/ShowDeletedMessagesPatch.kt | 22 ++- .../autoclaim/AutoClaimChannelPointsPatch.kt | 2 +- .../patches/twitch/debug/DebugModePatch.kt | 2 +- .../twitch/misc/settings/SettingsPatch.kt | 28 +-- .../misc/settings/SettingsResourcePatch.kt | 33 +--- .../ad/general/HideAdsResourcePatch.kt | 2 +- .../ad/getpremium/HideGetPremiumPatch.kt | 2 +- .../patches/youtube/ad/video/VideoAdsPatch.kt | 2 +- .../copyvideourl/CopyVideoUrlResourcePatch.kt | 10 +- .../RemoveViewerDiscretionDialogPatch.kt | 2 +- .../ExternalDownloadsResourcePatch.kt | 14 +- .../DisablePreciseSeekingGesturePatch.kt | 2 +- .../seekbar/EnableSeekbarTappingPatch.kt | 2 +- .../seekbar/EnableSlideToSeekPatch.kt | 2 +- .../SwipeControlsResourcePatch.kt | 1 + .../layout/autocaptions/AutoCaptionsPatch.kt | 2 +- .../layout/buttons/action/HideButtonsPatch.kt | 2 +- .../autoplay/HideAutoplayButtonPatch.kt | 2 +- .../captions/HideCaptionsButtonPatch.kt | 2 +- .../buttons/cast/HideCastButtonPatch.kt | 2 +- .../navigation/NavigationButtonsPatch.kt | 2 +- .../player/hide/HidePlayerButtonsPatch.kt | 2 +- .../albumcards/AlbumCardsResourcePatch.kt | 2 +- .../breakingnews/BreakingNewsResourcePatch.kt | 2 +- .../layout/hide/comments/CommentsPatch.kt | 2 +- .../CrowdfundingBoxResourcePatch.kt | 2 +- .../HideEndscreenCardsResourcePatch.kt | 2 +- .../filterbar/HideFilterBarResourcePatch.kt | 2 +- ...deFloatingMicrophoneButtonResourcePatch.kt | 2 +- .../DisableFullscreenAmbientModePatch.kt | 2 +- .../hide/general/HideLayoutComponentsPatch.kt | 1 + .../infocards/HideInfocardsResourcePatch.kt | 2 +- .../HideLoadMoreButtonResourcePatch.kt | 2 +- .../HideEmailAddressPatch.kt | 54 ----- .../HideEmailAddressResourcePatch.kt | 30 --- ...ntSwitcherAccessibilityLabelFingerprint.kt | 20 -- .../HidePlayerFlyoutMenuPatch.kt | 2 +- .../DisableRollingNumberAnimationPatch.kt | 2 +- .../layout/hide/seekbar/HideSeekbarPatch.kt | 2 +- .../HideShortsComponentsResourcePatch.kt | 2 +- ...bleSuggestedVideoEndScreenResourcePatch.kt | 2 +- .../layout/hide/time/HideTimestampPatch.kt | 2 +- .../panels/popup/PlayerPopupPanelsPatch.kt | 2 +- ...CustomPlayerOverlayOpacityResourcePatch.kt | 2 +- .../ReturnYouTubeDislikeResourcePatch.kt | 21 +- .../layout/searchbar/WideSearchbarPatch.kt | 2 +- .../RestoreOldSeekbarThumbnailsPatch.kt | 3 +- .../layout/seekbar/SeekbarPreferencesPatch.kt | 2 +- .../sponsorblock/SponsorBlockResourcePatch.kt | 21 +- .../spoofappversion/SpoofAppVersionPatch.kt | 4 +- .../layout/startpage/ChangeStartPagePatch.kt | 6 +- .../DisableResumingShortsOnStartupPatch.kt | 2 +- .../layout/tablet/EnableTabletLayoutPatch.kt | 2 +- .../tabletminiplayer/TabletMiniPlayerPatch.kt | 2 +- .../layout/theme/ThemeBytecodePatch.kt | 2 +- .../layout/theme/ThemeResourcePatch.kt | 2 +- .../thumbnails/AlternativeThumbnailsPatch.kt | 2 + .../AlternativeThumbnailsResourcePatch.kt | 10 +- .../misc/announcements/AnnouncementsPatch.kt | 2 +- .../misc/autorepeat/AutoRepeatPatch.kt | 2 +- .../youtube/misc/debugging/DebuggingPatch.kt | 2 +- .../spoof/SpoofDeviceDimensionsPatch.kt | 2 +- .../misc/fix/playback/SpoofSignaturePatch.kt | 2 +- .../youtube/misc/gms/GmsCoreSupportPatch.kt | 20 +- .../misc/gms/GmsCoreSupportResourcePatch.kt | 18 +- .../misc/links/BypassURLRedirectsPatch.kt | 2 +- .../misc/links/OpenLinksExternallyPatch.kt | 2 +- .../MinimizedPlaybackPatch.kt | 2 +- .../RemoveTrackingQueryParameterPatch.kt | 2 +- .../youtube/misc/settings/SettingsPatch.kt | 100 +++++----- .../misc/settings/SettingsResourcePatch.kt | 129 ++---------- .../fingerprints/SetThemeFingerprint.kt | 2 +- .../misc/zoomhaptics/ZoomHapticsPatch.kt | 2 +- .../fingerprints/HomeActivityFingerprint.kt | 9 + .../video/hdrbrightness/HDRBrightnessPatch.kt | 2 +- .../quality/RememberVideoQualityPatch.kt | 4 +- .../speed/custom/CustomPlaybackSpeedPatch.kt | 2 +- .../remember/RememberPlaybackSpeedPatch.kt | 4 +- ...RestoreOldVideoQualityMenuResourcePatch.kt | 2 +- .../kotlin/app/revanced/util/ResourceUtils.kt | 24 ++- .../impl => util/resource}/ArrayResource.kt | 3 +- .../resource}/BaseResource.kt | 17 +- .../impl => util/resource}/StringResource.kt | 4 +- .../twitch/settings/xml/revanced_prefs.xml | 4 - 110 files changed, 572 insertions(+), 710 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/all/misc/strings/AddResourcesPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/music/misc/integrations/IntegrationsPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/ApplicationInitFingerprint.kt rename src/main/kotlin/app/revanced/patches/{youtube/misc/gms => shared}/fingerprints/CastContextFetchFingerprint.kt (75%) delete mode 100644 src/main/kotlin/app/revanced/patches/shared/fingerprints/HomeActivityFingerprint.kt rename src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/{Preference.kt => IntentPreference.kt} (80%) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressResourcePatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/HomeActivityFingerprint.kt rename src/main/kotlin/app/revanced/{patches/shared/settings/preference/impl => util/resource}/ArrayResource.kt (86%) rename src/main/kotlin/app/revanced/{patches/shared/settings/preference => util/resource}/BaseResource.kt (65%) rename src/main/kotlin/app/revanced/{patches/shared/settings/preference/impl => util/resource}/StringResource.kt (85%) delete mode 100644 src/main/resources/twitch/settings/xml/revanced_prefs.xml diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 9a086a7838..a2a4b7cb30 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -38,6 +38,32 @@ public final class app/revanced/patches/all/misc/packagename/ChangePackageNamePa public final fun setOrGetFallbackPackageName (Ljava/lang/String;)Ljava/lang/String; } +public final class app/revanced/patches/all/misc/strings/AddResourcesPatch : app/revanced/patcher/patch/ResourcePatch, java/io/Closeable, java/util/Set, kotlin/jvm/internal/markers/KMutableSet { + public static final field INSTANCE Lapp/revanced/patches/all/misc/strings/AddResourcesPatch; + public fun add (Lapp/revanced/util/resource/BaseResource;)Z + public synthetic fun add (Ljava/lang/Object;)Z + public fun addAll (Ljava/util/Collection;)Z + public final fun addString (Ljava/lang/String;Ljava/lang/String;Z)Z + public static synthetic fun addString$default (Lapp/revanced/patches/all/misc/strings/AddResourcesPatch;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z + public fun clear ()V + public fun close ()V + public fun contains (Lapp/revanced/util/resource/BaseResource;)Z + public final fun contains (Ljava/lang/Object;)Z + public fun containsAll (Ljava/util/Collection;)Z + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V + public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V + public fun getSize ()I + public fun isEmpty ()Z + public fun iterator ()Ljava/util/Iterator; + public fun remove (Lapp/revanced/util/resource/BaseResource;)Z + public final fun remove (Ljava/lang/Object;)Z + public fun removeAll (Ljava/util/Collection;)Z + public fun retainAll (Ljava/util/Collection;)Z + public final fun size ()I + public fun toArray ()[Ljava/lang/Object; + public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object; +} + public abstract class app/revanced/patches/all/misc/transformation/AbstractTransformInstructionsPatch : app/revanced/patcher/patch/BytecodePatch { public fun ()V public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V @@ -321,6 +347,10 @@ public final class app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePat public static final field INSTANCE Lapp/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch; } +public final class app/revanced/patches/music/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/integrations/AbstractIntegrationsPatch { + public static final field INSTANCE Lapp/revanced/patches/music/misc/integrations/IntegrationsPatch; +} + public final class app/revanced/patches/music/premium/backgroundplay/BackgroundPlayPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/music/premium/backgroundplay/BackgroundPlayPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V @@ -519,10 +549,6 @@ public final class app/revanced/patches/serviceportalbund/detection/root/RootDet public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/shared/fingerprints/HomeActivityFingerprint : app/revanced/patches/shared/integrations/AbstractIntegrationsPatch$IntegrationsFingerprint { - public static final field INSTANCE Lapp/revanced/patches/shared/fingerprints/HomeActivityFingerprint; -} - public abstract class app/revanced/patches/shared/integrations/AbstractIntegrationsPatch : app/revanced/patcher/patch/BytecodePatch { public fun (Ljava/lang/String;Ljava/util/Set;)V public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V @@ -572,8 +598,8 @@ public final class app/revanced/patches/shared/misc/fix/verticalscroll/VerticalS } public abstract class app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportPatch : app/revanced/patcher/patch/BytecodePatch { - public fun (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Ljava/util/Set;Lapp/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Ljava/util/Set;Lapp/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Ljava/util/Set;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Lkotlin/reflect/KClass;Lapp/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Ljava/util/Set;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Lkotlin/reflect/KClass;Lapp/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } @@ -586,39 +612,29 @@ public abstract class app/revanced/patches/shared/misc/gms/AbstractGmsCoreSuppor protected final fun getGmsCoreVendor ()Ljava/lang/String; } -public final class app/revanced/patches/shared/misc/gms/fingerprints/GmsCoreSupportFingerprint : app/revanced/patcher/fingerprint/MethodFingerprint { - public static final field GET_GMS_CORE_VENDOR_METHOD_NAME Ljava/lang/String; - public static final field INSTANCE Lapp/revanced/patches/shared/misc/gms/fingerprints/GmsCoreSupportFingerprint; -} - public abstract class app/revanced/patches/shared/settings/AbstractSettingsResourcePatch : app/revanced/patcher/patch/ResourcePatch, java/io/Closeable { - public fun (Ljava/lang/String;Ljava/lang/String;)V + public fun ()V + public fun (Lkotlin/Pair;Ljava/util/Set;)V + public synthetic fun (Lkotlin/Pair;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun addPreference (Lapp/revanced/patches/shared/settings/preference/BasePreference;)V public fun close ()V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V } public abstract class app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getKey ()Ljava/lang/String; - public final fun getSummary ()Lapp/revanced/patches/shared/settings/preference/impl/StringResource; - public final fun getTag ()Ljava/lang/String; - public final fun getTitle ()Lapp/revanced/patches/shared/settings/preference/impl/StringResource; - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - -public abstract class app/revanced/patches/shared/settings/preference/BaseResource { - public fun (Ljava/lang/String;Ljava/lang/String;)V - public final fun getName ()Ljava/lang/String; + public final fun getSummary ()Lapp/revanced/util/resource/StringResource; public final fun getTag ()Ljava/lang/String; + public final fun getTitle ()Lapp/revanced/util/resource/StringResource; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; - public static synthetic fun serialize$default (Lapp/revanced/patches/shared/settings/preference/BaseResource;Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/w3c/dom/Element; } public abstract class app/revanced/patches/shared/settings/preference/DefaultBasePreference : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;Ljava/lang/Object;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;Ljava/lang/Object;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;Ljava/lang/Object;)V + public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;Ljava/lang/Object;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getDefault ()Ljava/lang/Object; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } @@ -633,12 +649,6 @@ public final class app/revanced/patches/shared/settings/preference/SummaryType : public static fun values ()[Lapp/revanced/patches/shared/settings/preference/SummaryType; } -public final class app/revanced/patches/shared/settings/preference/impl/ArrayResource : app/revanced/patches/shared/settings/preference/BaseResource { - public fun (Ljava/lang/String;Ljava/util/List;)V - public final fun getItems ()Ljava/util/List; - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - public final class app/revanced/patches/shared/settings/preference/impl/InputType : java/lang/Enum { public static final field NUMBER Lapp/revanced/patches/shared/settings/preference/impl/InputType; public static final field TEXT Lapp/revanced/patches/shared/settings/preference/impl/InputType; @@ -650,68 +660,60 @@ public final class app/revanced/patches/shared/settings/preference/impl/InputTyp public static fun values ()[Lapp/revanced/patches/shared/settings/preference/impl/InputType; } -public final class app/revanced/patches/shared/settings/preference/impl/ListPreference : app/revanced/patches/shared/settings/preference/DefaultBasePreference { - public fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getEntries ()Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource; - public final fun getEntryValues ()Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource; +public final class app/revanced/patches/shared/settings/preference/impl/IntentPreference : app/revanced/patches/shared/settings/preference/BasePreference { + public fun (Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/IntentPreference$Intent;)V + public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/IntentPreference$Intent;)V + public final fun getIntent ()Lapp/revanced/patches/shared/settings/preference/impl/IntentPreference$Intent; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } -public final class app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;Z)V - public synthetic fun (Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getSelectable ()Z - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; +public final class app/revanced/patches/shared/settings/preference/impl/IntentPreference$Intent { + public fun (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V } -public final class app/revanced/patches/shared/settings/preference/impl/Preference : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/Preference$Intent;)V - public fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/Preference$Intent;)V - public final fun getIntent ()Lapp/revanced/patches/shared/settings/preference/impl/Preference$Intent; +public final class app/revanced/patches/shared/settings/preference/impl/ListPreference : app/revanced/patches/shared/settings/preference/DefaultBasePreference { + public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getEntries ()Lapp/revanced/util/resource/ArrayResource; + public final fun getEntryValues ()Lapp/revanced/util/resource/ArrayResource; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } -public final class app/revanced/patches/shared/settings/preference/impl/Preference$Intent { - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V +public final class app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference : app/revanced/patches/shared/settings/preference/BasePreference { + public fun (Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;Z)V + public synthetic fun (Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getSelectable ()Z + public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } public class app/revanced/patches/shared/settings/preference/impl/PreferenceCategory : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/util/List;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/util/List;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Ljava/util/List;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Ljava/util/List;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getPreferences ()Ljava/util/List; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; public final fun setPreferences (Ljava/util/List;)V } public class app/revanced/patches/shared/settings/preference/impl/PreferenceScreen : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/util/List;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Ljava/util/List;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Ljava/util/List;Lapp/revanced/util/resource/StringResource;)V + public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Ljava/util/List;Lapp/revanced/util/resource/StringResource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getPreferences ()Ljava/util/List; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; public final fun setPreferences (Ljava/util/List;)V } -public final class app/revanced/patches/shared/settings/preference/impl/StringResource : app/revanced/patches/shared/settings/preference/BaseResource { - public fun (Ljava/lang/String;Ljava/lang/String;Z)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getFormatted ()Z - public final fun getValue ()Ljava/lang/String; - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; -} - public final class app/revanced/patches/shared/settings/preference/impl/SwitchPreference : app/revanced/patches/shared/settings/preference/DefaultBasePreference { - public fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Z)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getSummaryOff ()Lapp/revanced/patches/shared/settings/preference/impl/StringResource; - public final fun getSummaryOn ()Lapp/revanced/patches/shared/settings/preference/impl/StringResource; - public final fun getUserDialogMessage ()Lapp/revanced/patches/shared/settings/preference/impl/StringResource; + public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Z)V + public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getSummaryOff ()Lapp/revanced/util/resource/StringResource; + public final fun getSummaryOn ()Lapp/revanced/util/resource/StringResource; + public final fun getUserDialogMessage ()Lapp/revanced/util/resource/StringResource; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } public final class app/revanced/patches/shared/settings/preference/impl/TextPreference : app/revanced/patches/shared/settings/preference/DefaultBasePreference { - public fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/InputType;Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/InputType;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/InputType;Ljava/lang/String;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/InputType;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getInputType ()Lapp/revanced/patches/shared/settings/preference/impl/InputType; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } @@ -992,9 +994,6 @@ public final class app/revanced/patches/twitch/misc/integrations/IntegrationsPat public final class app/revanced/patches/twitch/misc/settings/SettingsPatch : app/revanced/patcher/patch/BytecodePatch, java/io/Closeable { public static final field INSTANCE Lapp/revanced/patches/twitch/misc/settings/SettingsPatch; - public final fun addPreferenceScreen (Lapp/revanced/patches/shared/settings/preference/impl/PreferenceScreen;)V - public final fun addString (Ljava/lang/String;Ljava/lang/String;Z)V - public static synthetic fun addString$default (Lapp/revanced/patches/twitch/misc/settings/SettingsPatch;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)V public fun close ()V public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V @@ -1002,9 +1001,6 @@ public final class app/revanced/patches/twitch/misc/settings/SettingsPatch : app public final class app/revanced/patches/twitch/misc/settings/SettingsResourcePatch : app/revanced/patches/shared/settings/AbstractSettingsResourcePatch { public static final field INSTANCE Lapp/revanced/patches/twitch/misc/settings/SettingsResourcePatch; - public final fun addArray (Lapp/revanced/patches/shared/settings/preference/impl/ArrayResource;)V - public final fun addPreferenceScreen (Lapp/revanced/patches/shared/settings/preference/impl/PreferenceScreen;)V - public final fun addString (Ljava/lang/String;Ljava/lang/String;Z)V } public final class app/revanced/patches/twitter/misc/dynamiccolor/DynamicColorPatch : app/revanced/patcher/patch/ResourcePatch { @@ -1250,12 +1246,6 @@ public final class app/revanced/patches/youtube/layout/hide/loadmorebutton/HideL public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressPatch : app/revanced/patcher/patch/BytecodePatch { - public static final field INSTANCE Lapp/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressPatch; - public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V - public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V -} - public final class app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch : app/revanced/patcher/patch/ResourcePatch { public static final field INSTANCE Lapp/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch; public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V @@ -1431,8 +1421,6 @@ public final class app/revanced/patches/youtube/misc/fix/playback/SpoofSignature public final class app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch : app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportPatch { public static final field INSTANCE Lapp/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch; - public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V - public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } public final class app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch : app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch { @@ -1513,15 +1501,10 @@ public final class app/revanced/patches/youtube/misc/privacy/RemoveTrackingQuery public final class app/revanced/patches/youtube/misc/settings/SettingsPatch : app/revanced/patcher/patch/BytecodePatch, java/io/Closeable { public static final field INSTANCE Lapp/revanced/patches/youtube/misc/settings/SettingsPatch; - public final fun addPreference (Lapp/revanced/patches/shared/settings/preference/impl/Preference;)V - public final fun addPreferenceScreen (Lapp/revanced/patches/shared/settings/preference/impl/PreferenceScreen;)V - public final fun addString (Ljava/lang/String;Ljava/lang/String;Z)V - public static synthetic fun addString$default (Lapp/revanced/patches/youtube/misc/settings/SettingsPatch;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)V public fun close ()V - public final fun createReVancedSettingsIntent (Ljava/lang/String;)Lapp/revanced/patches/shared/settings/preference/impl/Preference$Intent; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V - public final fun renameIntentsTargetPackage (Ljava/lang/String;)V + public final fun newIntent (Ljava/lang/String;)Lapp/revanced/patches/shared/settings/preference/impl/IntentPreference$Intent; } public final class app/revanced/patches/youtube/misc/settings/SettingsPatch$PreferenceScreen : app/revanced/patches/shared/settings/util/AbstractPreferenceScreen { @@ -1536,7 +1519,6 @@ public final class app/revanced/patches/youtube/misc/settings/SettingsPatch$Pref public final class app/revanced/patches/youtube/misc/settings/SettingsResourcePatch : app/revanced/patches/shared/settings/AbstractSettingsResourcePatch { public static final field INSTANCE Lapp/revanced/patches/youtube/misc/settings/SettingsResourcePatch; - public fun close ()V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V } @@ -1662,10 +1644,10 @@ public final class app/revanced/util/ResourceGroup { public final class app/revanced/util/ResourceUtilsKt { public static final fun copyResources (Lapp/revanced/patcher/data/ResourceContext;Ljava/lang/String;[Lapp/revanced/util/ResourceGroup;)V + public static final fun copyStrings (Lapp/revanced/patcher/data/ResourceContext;Ljava/lang/String;)V public static final fun copyXmlNode (Ljava/lang/String;Lapp/revanced/patcher/util/DomFileEditor;Lapp/revanced/patcher/util/DomFileEditor;)Ljava/lang/AutoCloseable; public static final fun doRecursively (Lorg/w3c/dom/Node;Lkotlin/jvm/functions/Function1;)V public static final fun iterateXmlNodeChildren (Lapp/revanced/patcher/data/ResourceContext;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V - public static final fun mergeStrings (Lapp/revanced/patcher/data/ResourceContext;Ljava/lang/String;)V } public abstract class app/revanced/util/patch/LiteralValueFingerprint : app/revanced/patcher/fingerprint/MethodFingerprint { @@ -1673,3 +1655,27 @@ public abstract class app/revanced/util/patch/LiteralValueFingerprint : app/reva public synthetic fun (Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;Lkotlin/jvm/functions/Function0;ILkotlin/jvm/internal/DefaultConstructorMarker;)V } +public final class app/revanced/util/resource/ArrayResource : app/revanced/util/resource/BaseResource { + public fun (Ljava/lang/String;Ljava/util/List;)V + public final fun getItems ()Ljava/util/List; + public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; +} + +public abstract class app/revanced/util/resource/BaseResource { + public fun (Ljava/lang/String;Ljava/lang/String;)V + public fun equals (Ljava/lang/Object;)Z + public final fun getName ()Ljava/lang/String; + public final fun getTag ()Ljava/lang/String; + public fun hashCode ()I + public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; + public static synthetic fun serialize$default (Lapp/revanced/util/resource/BaseResource;Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/w3c/dom/Element; +} + +public final class app/revanced/util/resource/StringResource : app/revanced/util/resource/BaseResource { + public fun (Ljava/lang/String;Ljava/lang/String;Z)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getFormatted ()Z + public final fun getValue ()Ljava/lang/String; + public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; +} + diff --git a/src/main/kotlin/app/revanced/patches/all/misc/strings/AddResourcesPatch.kt b/src/main/kotlin/app/revanced/patches/all/misc/strings/AddResourcesPatch.kt new file mode 100644 index 0000000000..bc8ed19f44 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/all/misc/strings/AddResourcesPatch.kt @@ -0,0 +1,53 @@ +package app.revanced.patches.all.misc.strings + +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.util.addResource +import app.revanced.util.getNode +import app.revanced.util.resource.ArrayResource +import app.revanced.util.resource.BaseResource +import app.revanced.util.resource.StringResource +import java.io.Closeable + +@Patch( + description = "Add resources such as strings or arrays to the app.", +) +object AddResourcesPatch : ResourcePatch(), Closeable, MutableSet by mutableSetOf() { + private lateinit var xmlFileHolder: ResourceContext.XmlFileHolder + + override fun execute(context: ResourceContext) { + xmlFileHolder = context.xmlEditor + } + + fun addString(name: String, value: String, formatted: Boolean = false) = add(StringResource(name, value, formatted)) + + override fun close() { + val strings = xmlFileHolder["res/values/strings.xml"] + val stringResources = strings.getNode("resources") + + val arrays = xmlFileHolder["res/values/arrays.xml"] + val arraysResources = arrays.getNode("resources") + + val addedStrings = hashSetOf() + + fun addResource(resource: BaseResource) { + when (resource) { + is StringResource -> { + // Strings are unique, so don't add them twice. + if (addedStrings.contains(resource.name)) return + addedStrings.add(resource.name) + + stringResources.addResource(resource) + } + is ArrayResource -> arraysResources.addResource(resource) { addResource(it) } + else -> throw NotImplementedError("Unsupported resource type") + } + } + + forEach(::addResource) + + strings.close() + arrays.close() + } +} diff --git a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt index 9b2dcec9ea..eac82bc36f 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt @@ -4,8 +4,10 @@ import app.revanced.patches.music.misc.gms.Constants.MUSIC_PACKAGE_NAME import app.revanced.patches.music.misc.gms.Constants.REVANCED_MUSIC_PACKAGE_NAME import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorOption import app.revanced.patches.music.misc.gms.fingerprints.* +import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint +import app.revanced.patches.music.misc.integrations.IntegrationsPatch import app.revanced.patches.shared.misc.gms.AbstractGmsCoreSupportPatch -import app.revanced.patches.youtube.misc.gms.fingerprints.CastContextFetchFingerprint +import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint @Suppress("unused") object GmsCoreSupportPatch : AbstractGmsCoreSupportPatch( @@ -19,6 +21,8 @@ object GmsCoreSupportPatch : AbstractGmsCoreSupportPatch( CastDynamiteModuleV2Fingerprint, CastContextFetchFingerprint, ), + mainActivityOnCreateFingerprint = ApplicationInitFingerprint, + integrationsPatchDependency = IntegrationsPatch::class, abstractGmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, compatiblePackages = setOf(CompatiblePackage("com.google.android.apps.youtube.music")), fingerprints = setOf( diff --git a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch.kt index 06c36bdef1..e37b478411 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch.kt @@ -8,4 +8,4 @@ object GmsCoreSupportResourcePatch : AbstractGmsCoreSupportResourcePatch( fromPackageName = MUSIC_PACKAGE_NAME, toPackageName = REVANCED_MUSIC_PACKAGE_NAME, spoofedPackageSignature = "afb0fed5eeaebdd86f56a97742f4b6b33ef59875" -) \ No newline at end of file +) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/integrations/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/integrations/IntegrationsPatch.kt new file mode 100644 index 0000000000..074f555b13 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/misc/integrations/IntegrationsPatch.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.music.misc.integrations + +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint +import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch + +@Patch(requiresIntegrations = true) +object IntegrationsPatch : AbstractIntegrationsPatch( + "Lapp/revanced/integrations/utils/ReVancedUtils;", + setOf( + ApplicationInitFingerprint, + ), +) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/ApplicationInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/ApplicationInitFingerprint.kt new file mode 100644 index 0000000000..665cc8e330 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/ApplicationInitFingerprint.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.music.misc.integrations.fingerprints + +import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import com.android.tools.smali.dexlib2.Opcode + +internal object ApplicationInitFingerprint : IntegrationsFingerprint( + returnType = "V", + parameters = emptyList(), + opcodes = listOf( + Opcode.NEW_INSTANCE, + Opcode.INVOKE_DIRECT, + Opcode.INVOKE_STATIC, + Opcode.NEW_INSTANCE, + Opcode.INVOKE_DIRECT, + Opcode.INVOKE_VIRTUAL + ), + strings = listOf("activity"), + customFingerprint = { methodDef, _ -> methodDef.name == "onCreate" }, +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/fingerprints/CastContextFetchFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/CastContextFetchFingerprint.kt similarity index 75% rename from src/main/kotlin/app/revanced/patches/youtube/misc/gms/fingerprints/CastContextFetchFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/fingerprints/CastContextFetchFingerprint.kt index b2d836fe3d..6553ef4210 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/fingerprints/CastContextFetchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/fingerprints/CastContextFetchFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.gms.fingerprints +package app.revanced.patches.shared.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/HomeActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/fingerprints/HomeActivityFingerprint.kt deleted file mode 100644 index 8edf3e003b..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/HomeActivityFingerprint.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.shared.fingerprints - -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint - -object HomeActivityFingerprint : IntegrationsFingerprint( - customFingerprint = { methodDef, classDef -> - methodDef.name == "onCreate" && classDef.type.endsWith("Shell_HomeActivity;") - }, -) diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportPatch.kt index dfb06c287a..915445184c 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportPatch.kt @@ -2,6 +2,7 @@ package app.revanced.patches.shared.misc.gms import app.revanced.patcher.PatchClass import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstructions import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.MethodFingerprint @@ -31,6 +32,8 @@ import com.android.tools.smali.dexlib2.util.MethodUtil * @param toPackageName The package name to fall back to if no custom package name is specified in patch options. * @param primeMethodFingerprint The fingerprint of the "prime" method that needs to be patched. * @param earlyReturnFingerprints The fingerprints of methods that need to be returned early. + * @param mainActivityOnCreateFingerprint The fingerprint of the main activity's onCreate method. + * @param integrationsPatchDependency The patch responsible for the integrations. * @param abstractGmsCoreSupportResourcePatch The corresponding resource patch that is used to patch the resources. * @param dependencies Additional dependencies of this patch. * @param compatiblePackages The compatible packages of this patch. @@ -41,6 +44,8 @@ abstract class AbstractGmsCoreSupportPatch( private val toPackageName: String, private val primeMethodFingerprint: MethodFingerprint, private val earlyReturnFingerprints: Set, + private val mainActivityOnCreateFingerprint: MethodFingerprint, + private val integrationsPatchDependency: PatchClass, abstractGmsCoreSupportResourcePatch: AbstractGmsCoreSupportResourcePatch, dependencies: Set = setOf(), compatiblePackages: Set? = null, @@ -49,9 +54,13 @@ abstract class AbstractGmsCoreSupportPatch( name = "GmsCore support", description = "Allows Google apps to run without root and under a different package name " + "by using GmsCore instead of Google Play Services.", - dependencies = setOf(ChangePackageNamePatch::class, abstractGmsCoreSupportResourcePatch::class) + dependencies, + dependencies = setOf( + ChangePackageNamePatch::class, + abstractGmsCoreSupportResourcePatch::class, + integrationsPatchDependency + ) + dependencies, compatiblePackages = compatiblePackages, - fingerprints = setOf(GmsCoreSupportFingerprint) + fingerprints, + fingerprints = setOf(GmsCoreSupportFingerprint, mainActivityOnCreateFingerprint) + fingerprints, requiresIntegrations = true ) { init { @@ -84,6 +93,12 @@ abstract class AbstractGmsCoreSupportPatch( // Return these methods early to prevent the app from crashing. earlyReturnFingerprints.toList().returnEarly() + // Check the availability of GmsCore. + mainActivityOnCreateFingerprint.result?.mutableMethod?.addInstruction( + 1, // Hack to not disturb other patches (such as the integrations patch). + "invoke-static {}, Lapp/revanced/integrations/patches/GmsCoreSupport;->checkAvailability()V" + ) ?: throw mainActivityOnCreateFingerprint.exception + // Change the vendor of GmsCore in ReVanced Integrations. GmsCoreSupportFingerprint.result?.mutableClass?.methods ?.single { it.name == GET_GMS_CORE_VENDOR_METHOD_NAME } diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt index 72ced135ad..87b2e6c312 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt @@ -5,7 +5,8 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch -import app.revanced.util.mergeStrings +import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.util.copyStrings import org.w3c.dom.Element import org.w3c.dom.Node @@ -23,7 +24,7 @@ abstract class AbstractGmsCoreSupportResourcePatch( private val toPackageName: String, private val spoofedPackageSignature: String, dependencies: Set = setOf() -) : ResourcePatch(dependencies = setOf(ChangePackageNamePatch::class) + dependencies) { +) : ResourcePatch(dependencies = setOf(ChangePackageNamePatch::class, AddResourcesPatch::class) + dependencies) { internal val gmsCoreVendorOption = stringPatchOption( key = "gmsCoreVendor", default = "com.mgoogle", @@ -39,7 +40,7 @@ abstract class AbstractGmsCoreSupportResourcePatch( protected val gmsCoreVendor by gmsCoreVendorOption override fun execute(context: ResourceContext) { - context.mergeStrings("gms/host/values/strings.xml") + context.copyStrings("gms/host/values/strings.xml") context.patchManifest() context.addSpoofingMetadata() } diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/gms/fingerprints/GmsCoreSupportFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/misc/gms/fingerprints/GmsCoreSupportFingerprint.kt index 5ecfa53c62..79be107f90 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/gms/fingerprints/GmsCoreSupportFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/gms/fingerprints/GmsCoreSupportFingerprint.kt @@ -2,7 +2,7 @@ package app.revanced.patches.shared.misc.gms.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint -object GmsCoreSupportFingerprint : MethodFingerprint( +internal object GmsCoreSupportFingerprint : MethodFingerprint( customFingerprint = { _, classDef -> classDef.type.endsWith("GmsCoreSupport;") } diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt index 4935370d8c..584d01fd45 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt @@ -1,121 +1,66 @@ package app.revanced.patches.shared.settings +import app.revanced.patcher.PatchClass import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.util.DomFileEditor +import app.revanced.patches.all.misc.strings.AddResourcesPatch import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.BaseResource -import app.revanced.patches.shared.settings.preference.addPreference -import app.revanced.patches.shared.settings.preference.addResource -import app.revanced.patches.shared.settings.preference.impl.ArrayResource -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.patches.shared.settings.preference.impl.IntentPreference import app.revanced.util.ResourceGroup import app.revanced.util.copyResources +import app.revanced.util.getNode import org.w3c.dom.Node import java.io.Closeable /** - * Abstract settings resource patch + * A resource patch that adds settings to a settings fragment. * - * @param preferenceFileName Name of the settings preference xml file - * @param sourceDirectory Source directory to copy the preference template from + * @param rootPreference A pair of an intent preference and the name of the fragment file to add it to. + * If null, no preference will be added. + * @param dependencies Additional dependencies of this patch. */ abstract class AbstractSettingsResourcePatch( - private val preferenceFileName: String, - private val sourceDirectory: String, -) : ResourcePatch(), Closeable { + private val rootPreference: Pair? = null, + dependencies: Set = emptySet() +) : ResourcePatch( + dependencies = setOf(AddResourcesPatch::class) + dependencies +), Closeable { + private lateinit var revancedPreferencesEditor: DomFileEditor + private lateinit var revancedPreferenceScreenNode: Node + override fun execute(context: ResourceContext) { - /* copy preference template from source dir */ context.copyResources( - sourceDirectory, - ResourceGroup( - "xml", "$preferenceFileName.xml" - ) + "settings", + ResourceGroup("xml", "revanced_prefs.xml") ) - /* prepare xml editors */ - stringsEditor = context.xmlEditor["res/values/strings.xml"] - arraysEditor = context.xmlEditor["res/values/arrays.xml"] - revancedPreferencesEditor = context.xmlEditor["res/xml/$preferenceFileName.xml"] - } - - internal companion object { - private var revancedPreferenceNode: Node? = null - private var stringsNode: Node? = null - private var arraysNode: Node? = null - - private var strings = mutableListOf() - - private var revancedPreferencesEditor: DomFileEditor? = null - set(value) { - field = value - revancedPreferenceNode = value.getNode("PreferenceScreen") + rootPreference?.let { (intentPreference, fragment) -> + context.xmlEditor["res/xml/$fragment.xml"].use { + it.getNode("PreferenceScreen").addPreference(intentPreference) } - private var stringsEditor: DomFileEditor? = null - set(value) { - field = value - stringsNode = value.getNode("resources") - } - private var arraysEditor: DomFileEditor? = null - set(value) { - field = value - arraysNode = value.getNode("resources") - } - - /** - * Add a new string to the resources. - * - * @param identifier The key of the string. - * @param value The value of the string. - * @throws IllegalArgumentException if the string already exists. - */ - fun addString(identifier: String, value: String, formatted: Boolean) = - StringResource(identifier, value, formatted).include() - - /** - * Add an array to the resources. - * - * @param arrayResource The array resource to add. - */ - fun addArray(arrayResource: ArrayResource) = - arraysNode!!.addResource(arrayResource) { it.include() } - - /** - * Add a preference to the settings. - * - * @param preference The preference to add. - */ - fun addPreference(preference: BasePreference) = - revancedPreferenceNode!!.addPreference(preference) { it.include() } + } - /** - * Add a new resource to the resources. - * - * @throws IllegalArgumentException if the resource already exists. - */ - internal fun BaseResource.include() { - when (this) { - is StringResource -> { - if (strings.any { it.name == name }) return - strings.add(this) - } + revancedPreferencesEditor = context.xmlEditor["res/xml/revanced_prefs.xml"] + revancedPreferenceScreenNode = revancedPreferencesEditor.getNode("PreferenceScreen") + } - is ArrayResource -> addArray(this) - else -> throw NotImplementedError("Unsupported resource type") - } - } + /** + * Add a preference to the settings fragment file. + * + * @param preference The preference to add. + */ + fun addPreference(preference: BasePreference) { + revancedPreferenceScreenNode.addPreference(preference) + } - internal fun DomFileEditor?.getNode(tagName: String) = this!!.file.getElementsByTagName(tagName).item(0) + private fun Node.addPreference(preference: BasePreference) { + preference.serialize(ownerDocument) { resource -> + AddResourcesPatch += resource + }.let(this::appendChild) } override fun close() { - // merge all strings, skip duplicates - strings.forEach { - stringsNode!!.addResource(it) - } - - revancedPreferencesEditor?.close() - stringsEditor?.close() - arraysEditor?.close() + revancedPreferencesEditor.close() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/BasePreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/BasePreference.kt index a150aa6fe8..a6a19806c3 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/BasePreference.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/BasePreference.kt @@ -1,6 +1,7 @@ package app.revanced.patches.shared.settings.preference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.BaseResource +import app.revanced.util.resource.StringResource import org.w3c.dom.Document import org.w3c.dom.Element diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/ComponentsExtensions.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/ComponentsExtensions.kt index 7e13127f0e..fdb8c2547a 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/ComponentsExtensions.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/ComponentsExtensions.kt @@ -1,28 +1,7 @@ package app.revanced.patches.shared.settings.preference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import org.w3c.dom.Element -import org.w3c.dom.Node - -/** - * Add a resource node child - * - * @param resource The resource to add. - * @param resourceCallback Called when a resource has been processed. - */ -internal fun Node.addResource(resource: BaseResource, resourceCallback: (BaseResource) -> Unit = { }) { - appendChild(resource.serialize(ownerDocument, resourceCallback)) -} - -/** - * Add a preference node child to the settings. - * - * @param preference The preference to add. - * @param resourceCallback Called when a resource has been processed. - */ -internal fun Node.addPreference(preference: BasePreference, resourceCallback: ((BaseResource) -> Unit) = { }) { - appendChild(preference.serialize(ownerDocument, resourceCallback)) -} internal fun Element.addSummary(summaryResource: StringResource?, summaryType: SummaryType = SummaryType.DEFAULT) = summaryResource?.let { summary -> @@ -45,4 +24,4 @@ internal fun Element.addDefault(default: T) { internal fun CharSequence.removePunctuation(): String { val punctuation = "\\p{P}+".toRegex() return this.replace(punctuation, "") -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/DefaultBasePreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/DefaultBasePreference.kt index 9371d48f8c..23721c1fa8 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/DefaultBasePreference.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/DefaultBasePreference.kt @@ -1,6 +1,7 @@ package app.revanced.patches.shared.settings.preference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.BaseResource +import app.revanced.util.resource.StringResource import org.w3c.dom.Document /** diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/Preference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/IntentPreference.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/Preference.kt rename to src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/IntentPreference.kt index 463a1fce28..919d09b681 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/Preference.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/IntentPreference.kt @@ -1,18 +1,19 @@ package app.revanced.patches.shared.settings.preference.impl import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.BaseResource +import app.revanced.util.resource.BaseResource +import app.revanced.util.resource.StringResource import org.w3c.dom.Document /** - * A preference object. + * A preference that opens an intent. * * @param key The key of the preference. * @param title The title of the preference. * @param summary The summary of the text preference. * @param intent The intent of the preference. */ -class Preference( +class IntentPreference( key: String, title: StringResource, summary: StringResource, @@ -27,15 +28,15 @@ class Preference( override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = super.serialize(ownerDocument, resourceCallback).apply { this.appendChild(ownerDocument.createElement("intent").also { intentNode -> - intentNode.setAttribute("android:targetPackage", intent.targetPackage) intentNode.setAttribute("android:data", intent.data) intentNode.setAttribute("android:targetClass", intent.targetClass) + intentNode.setAttribute("android:targetPackage", intent.targetPackageSupplier()) }) } class Intent( - internal val targetPackage: String, internal val data: String, - internal val targetClass: String + internal val targetClass: String, + internal val targetPackageSupplier: () -> String, ) } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ListPreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ListPreference.kt index 37181267fa..955cf1b13e 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ListPreference.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ListPreference.kt @@ -1,8 +1,10 @@ package app.revanced.patches.shared.settings.preference.impl -import app.revanced.patches.shared.settings.preference.BaseResource import app.revanced.patches.shared.settings.preference.DefaultBasePreference import app.revanced.patches.shared.settings.preference.addSummary +import app.revanced.util.resource.ArrayResource +import app.revanced.util.resource.BaseResource +import app.revanced.util.resource.StringResource import org.w3c.dom.Document /** diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt index ef08bc3e2f..26e8e6a717 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt @@ -1,7 +1,8 @@ package app.revanced.patches.shared.settings.preference.impl import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.BaseResource +import app.revanced.util.resource.BaseResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.addSummary import org.w3c.dom.Document import org.w3c.dom.Element diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceCategory.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceCategory.kt index 633e8d7849..90d0139c23 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceCategory.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceCategory.kt @@ -1,7 +1,8 @@ package app.revanced.patches.shared.settings.preference.impl import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.BaseResource +import app.revanced.util.resource.BaseResource +import app.revanced.util.resource.StringResource import org.w3c.dom.Document /** diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceScreen.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceScreen.kt index e0e435b23f..2c12dc66d0 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceScreen.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceScreen.kt @@ -1,7 +1,8 @@ package app.revanced.patches.shared.settings.preference.impl +import app.revanced.util.resource.BaseResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.BaseResource import app.revanced.patches.shared.settings.preference.addSummary import org.w3c.dom.Document diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/SwitchPreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/SwitchPreference.kt index 6623c3bf4f..dc6d99990c 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/SwitchPreference.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/SwitchPreference.kt @@ -1,10 +1,10 @@ package app.revanced.patches.shared.settings.preference.impl -import app.revanced.patches.shared.settings.preference.BaseResource import app.revanced.patches.shared.settings.preference.DefaultBasePreference import app.revanced.patches.shared.settings.preference.SummaryType import app.revanced.patches.shared.settings.preference.addSummary -import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch.Companion.include +import app.revanced.util.resource.BaseResource +import app.revanced.util.resource.StringResource import org.w3c.dom.Document import org.w3c.dom.Element @@ -24,9 +24,9 @@ class SwitchPreference( val summaryOff: StringResource, val userDialogMessage: StringResource? = null, default: Boolean = false, -) : DefaultBasePreference( key, title, null, "SwitchPreference", default) { +) : DefaultBasePreference(key, title, null, "SwitchPreference", default) { override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit): Element { - userDialogMessage?.include() + userDialogMessage?.let(resourceCallback::invoke) return super.serialize(ownerDocument, resourceCallback).apply { addSummary(summaryOn.also { resourceCallback.invoke(it) }, SummaryType.ON) diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/TextPreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/TextPreference.kt index aaac8c5c01..0ab6be4f52 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/TextPreference.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/TextPreference.kt @@ -1,7 +1,8 @@ package app.revanced.patches.shared.settings.preference.impl -import app.revanced.patches.shared.settings.preference.BaseResource import app.revanced.patches.shared.settings.preference.DefaultBasePreference +import app.revanced.util.resource.BaseResource +import app.revanced.util.resource.StringResource import org.w3c.dom.Document /** @@ -21,7 +22,6 @@ class TextPreference( default: String? = null, tag: String = "app.revanced.integrations.settingsmenu.ResettableEditTextPreference" ) : DefaultBasePreference(key, title, summary, tag, default) { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = super.serialize(ownerDocument, resourceCallback).apply { setAttribute("android:inputType", inputType.type) diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/util/AbstractPreferenceScreen.kt b/src/main/kotlin/app/revanced/patches/shared/settings/util/AbstractPreferenceScreen.kt index c1148841c4..f5b9d5a8ff 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/util/AbstractPreferenceScreen.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/util/AbstractPreferenceScreen.kt @@ -1,16 +1,16 @@ package app.revanced.patches.shared.settings.util import app.revanced.patches.shared.settings.preference.BasePreference +import app.revanced.patches.shared.settings.preference.impl.IntentPreference import app.revanced.patches.shared.settings.preference.impl.PreferenceCategory import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.shared.settings.preference.removePunctuation +import app.revanced.util.resource.StringResource import java.io.Closeable abstract class AbstractPreferenceScreen( private val root: MutableList = mutableListOf() ) : Closeable { - override fun close() { if (root.isEmpty()) return @@ -39,8 +39,9 @@ abstract class AbstractPreferenceScreen( ), preferences.sortedWith( compareBy( + { it is IntentPreference }, { it is PreferenceScreen }, - { it.title.value.removePunctuation().lowercase() } + { it.title.value.removePunctuation().lowercase() }, ) ) + categories.sortedBy { it.title.removePunctuation().lowercase() @@ -95,4 +96,4 @@ abstract class AbstractPreferenceScreen( ) { abstract fun transform(): BasePreference } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt index bd25a2cb3a..6d8459c810 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.twitch.ad.audio.fingerprints.AudioAdsPresenterPlayFingerprint import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt index 5b7f6d8d83..a1cbf8a174 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt @@ -1,23 +1,30 @@ package app.revanced.patches.twitch.ad.embedded -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.ArrayResource +import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.strings.AddResourcesPatch.addString import app.revanced.patches.shared.settings.preference.impl.ListPreference -import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.twitch.ad.embedded.fingerprints.CreateUsherClientFingerprint import app.revanced.patches.twitch.ad.video.VideoAdsPatch import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch import app.revanced.patches.twitch.misc.settings.SettingsPatch +import app.revanced.util.exception +import app.revanced.util.resource.ArrayResource +import app.revanced.util.resource.StringResource @Patch( name = "Block embedded ads", description = "Blocks embedded stream ads using services like Luminous or PurpleAdBlocker.", - dependencies = [VideoAdsPatch::class, IntegrationsPatch::class, SettingsPatch::class], + dependencies = [ + VideoAdsPatch::class, + IntegrationsPatch::class, + SettingsPatch::class, + AddResourcesPatch::class, + ], compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])] ) @Suppress("unused") @@ -64,7 +71,13 @@ object EmbeddedAdsPatch : BytecodePatch( ) ) - SettingsPatch.addString("revanced_embedded_ads_service_unavailable", "%s is unavailable. Ads may show. Try switching to another ad block service in settings.") - SettingsPatch.addString("revanced_embedded_ads_service_failed", "%s server returned an error. Ads may show. Try switching to another ad block service in settings.") + addString( + "revanced_embedded_ads_service_unavailable", + "%s is unavailable. Ads may show. Try switching to another ad block service in settings." + ) + addString( + "revanced_embedded_ads_service_failed", + "%s server returned an error. Ads may show. Try switching to another ad block service in settings." + ) } } diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt index 00b134774b..9edfd2f9d3 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.twitch.ad.shared.util.AbstractAdPatch import app.revanced.patches.twitch.ad.video.fingerprints.CheckAdEligibilityLambdaFingerprint diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt index d5224f60d2..ccf30a12eb 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.twitch.chat.antidelete -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels @@ -9,19 +8,25 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.ArrayResource +import app.revanced.patches.all.misc.strings.AddResourcesPatch import app.revanced.patches.shared.settings.preference.impl.ListPreference -import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.twitch.chat.antidelete.fingerprints.ChatUtilCreateDeletedSpanFingerprint import app.revanced.patches.twitch.chat.antidelete.fingerprints.DeletedMessageClickableSpanCtorFingerprint import app.revanced.patches.twitch.chat.antidelete.fingerprints.SetHasModAccessFingerprint import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch import app.revanced.patches.twitch.misc.settings.SettingsPatch +import app.revanced.util.exception +import app.revanced.util.resource.ArrayResource +import app.revanced.util.resource.StringResource @Patch( name = "Show deleted messages", description = "Shows deleted chat messages behind a clickable spoiler.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [ + IntegrationsPatch::class, + SettingsPatch::class, + AddResourcesPatch::class, + ], compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])] ) @Suppress("unused") @@ -68,7 +73,7 @@ object ShowDeletedMessagesPatch : BytecodePatch( """, ExternalLabel("no_reformat", getInstruction(0)) ) - } ?: throw ChatUtilCreateDeletedSpanFingerprint.exception + } ?: throw ChatUtilCreateDeletedSpanFingerprint.exception SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences( ListPreference( @@ -82,7 +87,10 @@ object ShowDeletedMessagesPatch : BytecodePatch( listOf( StringResource("revanced_deleted_messages_hide", "Do not show deleted messages"), StringResource("revanced_deleted_messages_spoiler", "Hide deleted messages behind a spoiler"), - StringResource("revanced_deleted_messages_cross_out", "Show deleted messages as crossed-out text") + StringResource( + "revanced_deleted_messages_cross_out", + "Show deleted messages as crossed-out text" + ) ) ), ArrayResource( @@ -97,6 +105,6 @@ object ShowDeletedMessagesPatch : BytecodePatch( ) ) - SettingsPatch.addString("revanced_deleted_msg", "message deleted") + AddResourcesPatch.addString("revanced_deleted_msg", "message deleted") } } diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt index a119669683..de1ca2b4d5 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.twitch.chat.autoclaim.fingerprints.CommunityPointsButtonViewDelegateFingerprint import app.revanced.patches.twitch.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt b/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt index ac07bdc572..38aade853d 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.twitch.debug.fingerprints.IsDebugConfigEnabledFingerprint import app.revanced.patches.twitch.debug.fingerprints.IsOmVerificationEnabledFingerprint diff --git a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt index 36245a25d2..53186fe0f2 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.twitch.misc.settings -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels @@ -12,14 +11,17 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.strings.AddResourcesPatch.addString import app.revanced.patches.shared.settings.preference.impl.PreferenceCategory -import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch import app.revanced.patches.twitch.misc.settings.fingerprints.MenuGroupsOnClickFingerprint import app.revanced.patches.twitch.misc.settings.fingerprints.MenuGroupsUpdatedFingerprint import app.revanced.patches.twitch.misc.settings.fingerprints.SettingsActivityOnCreateFingerprint import app.revanced.patches.twitch.misc.settings.fingerprints.SettingsMenuItemEnumFingerprint +import app.revanced.util.exception +import app.revanced.util.resource.StringResource import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.immutable.ImmutableField import java.io.Closeable @@ -28,7 +30,11 @@ import java.io.Closeable @Patch( name = "Settings", description = "Adds settings menu to Twitch.", - dependencies = [IntegrationsPatch::class, SettingsResourcePatch::class], + dependencies = [ + IntegrationsPatch::class, + SettingsResourcePatch::class, + AddResourcesPatch::class, + ], compatiblePackages = [ CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"]) ] @@ -47,7 +53,8 @@ object SettingsPatch : BytecodePatch( private const val REVANCED_SETTINGS_MENU_ITEM_ICON_RES = "ic_settings" private const val MENU_ITEM_ENUM_CLASS = "Ltv/twitch/android/feature/settings/menu/SettingsMenuItem;" - private const val MENU_DISMISS_EVENT_CLASS = "Ltv/twitch/android/feature/settings/menu/SettingsMenuViewDelegate\$Event\$OnDismissClicked;" + private const val MENU_DISMISS_EVENT_CLASS = + "Ltv/twitch/android/feature/settings/menu/SettingsMenuViewDelegate\$Event\$OnDismissClicked;" private const val INTEGRATIONS_PACKAGE = "app/revanced/twitch" private const val SETTINGS_HOOKS_CLASS = "L$INTEGRATIONS_PACKAGE/settingsmenu/SettingsHooks;" @@ -106,19 +113,13 @@ object SettingsPatch : BytecodePatch( """, ExternalLabel("no_rv_settings_onclick", mutableMethod.getInstruction(insertIndex)) ) - } ?: throw MenuGroupsOnClickFingerprint.exception + } ?: throw MenuGroupsOnClickFingerprint.exception addString("revanced_settings", "ReVanced Settings", false) addString("revanced_reboot_message", "Twitch needs to restart to apply your changes. Restart now?", false) addString("revanced_reboot", "Restart", false) } - fun addString(identifier: String, value: String, formatted: Boolean = true) = - SettingsResourcePatch.addString(identifier, value, formatted) - - fun addPreferenceScreen(preferenceScreen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) = - SettingsResourcePatch.addPreferenceScreen(preferenceScreen) - private fun MethodFingerprintResult.injectMenuItem( name: String, value: Int, @@ -185,9 +186,8 @@ object SettingsPatch : BytecodePatch( } } - override fun commit(screen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) { - addPreferenceScreen(screen) - } + override fun commit(screen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) = + SettingsResourcePatch.addPreference(screen) } override fun close() = PreferenceScreen.close() diff --git a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsResourcePatch.kt index f617846117..e9ad24dbcb 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsResourcePatch.kt @@ -1,36 +1,5 @@ package app.revanced.patches.twitch.misc.settings import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch -import app.revanced.patches.shared.settings.preference.impl.ArrayResource -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -object SettingsResourcePatch : AbstractSettingsResourcePatch( -"revanced_prefs", -"twitch/settings" -) { - /* Companion delegates */ - - /** - * Add a new string to the resources. - * - * @param identifier The key of the string. - * @param value The value of the string. - * @throws IllegalArgumentException if the string already exists. - */ - fun addString(identifier: String, value: String, formatted: Boolean) = - AbstractSettingsResourcePatch.addString(identifier, value, formatted) - - /** - * Add an array to the resources. - * - * @param arrayResource The array resource to add. - */ - fun addArray(arrayResource: ArrayResource) = AbstractSettingsResourcePatch.addArray(arrayResource) - - /** - * Add a preference to the settings. - * - * @param preferenceScreen The name of the preference screen. - */ - fun addPreferenceScreen(preferenceScreen: PreferenceScreen) = AbstractSettingsResourcePatch.addPreference(preferenceScreen) -} \ No newline at end of file +object SettingsResourcePatch : AbstractSettingsResourcePatch() \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt index d7c0ac13ef..7984f6bfcc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt index e337874a47..c9e97eed86 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.ad.getpremium.fingerprints.GetPremiumViewFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt index 3bf896f1d2..2319985fd5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.ad.video.fingerprints.LoadVideoAdsFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt index cb03d0f828..f708e7063e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt @@ -3,19 +3,21 @@ package app.revanced.patches.youtube.interaction.copyvideourl import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.all.misc.strings.AddResourcesPatch import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.playercontrols.BottomControlsResourcePatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.ResourceGroup import app.revanced.util.copyResources -import app.revanced.util.mergeStrings +import app.revanced.util.copyStrings +import app.revanced.util.resource.StringResource @Patch( dependencies = [ SettingsPatch::class, - BottomControlsResourcePatch::class + BottomControlsResourcePatch::class, + AddResourcesPatch::class, ] ) internal object CopyVideoUrlResourcePatch : ResourcePatch() { @@ -59,7 +61,7 @@ internal object CopyVideoUrlResourcePatch : ResourcePatch() { ) ) - context.mergeStrings("copyvideourl/host/values/strings.xml") + context.copyStrings("copyvideourl/host/values/strings.xml") BottomControlsResourcePatch.addControls("copyvideourl") } diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt index 1492ea970e..2735486cfb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.interaction.dialog.fingerprints.CreateDialogFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt index 3873a90972..d272643a2f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt @@ -3,17 +3,23 @@ package app.revanced.patches.youtube.interaction.downloads import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.* +import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.shared.settings.preference.impl.InputType +import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen +import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.shared.settings.preference.impl.TextPreference import app.revanced.patches.youtube.misc.playercontrols.BottomControlsResourcePatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.ResourceGroup import app.revanced.util.copyResources -import app.revanced.util.mergeStrings +import app.revanced.util.copyStrings +import app.revanced.util.resource.StringResource @Patch( dependencies = [ BottomControlsResourcePatch::class, - SettingsPatch::class + SettingsPatch::class, + AddResourcesPatch::class ] ) internal object ExternalDownloadsResourcePatch : ResourcePatch() { @@ -50,7 +56,7 @@ internal object ExternalDownloadsResourcePatch : ResourcePatch() { ) ) - context.mergeStrings("downloads/host/values/strings.xml") + context.copyStrings("downloads/host/values/strings.xml") context.copyResources( "downloads", diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt index 4578915f4b..f9bc7e44d6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.interaction.seekbar.fingerprints.IsSwipingUpFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt index de7bb5082f..6266587b10 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.interaction.seekbar.fingerprints.OnTouchEventHandlerFingerprint import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt index b8e884a428..1565a54784 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.interaction.seekbar.fingerprints.DoubleSpeedSeekNoticeFingerprint import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SlideToSeekFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt index 58c6a2146a..eb7949fd44 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt @@ -3,6 +3,7 @@ package app.revanced.patches.youtube.interaction.swipecontrols import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.* import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.ResourceGroup diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt index c0f0f396c2..ddc50a5d4a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.autocaptions.fingerprints.StartVideoInformerFingerprint import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleButtonControllerFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt index 2ee75c96d7..a4dec49e21 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt index 0d2e40cf98..bca95d6f46 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt index 55f09f2d84..ca186a7494 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleButtonControllerFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt index fe3f83329e..f7ca4d3dc8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt index 5727bb93b9..6668e7f87a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.* import app.revanced.patches.youtube.layout.buttons.navigation.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt index 22066eff13..5b511a5d8a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.buttons.player.hide.HidePlayerButtonsPatch.ParameterOffsets.HAS_NEXT import app.revanced.patches.youtube.layout.buttons.player.hide.HidePlayerButtonsPatch.ParameterOffsets.HAS_PREVIOUS diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt index 2501d47923..515fa98ba3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt index 9de7b83dd4..22cc5a2977 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt index a2ef81a170..0968752869 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt index 4df6484aa4..a57ae52c80 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt index 87e65d6330..715daed4cd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt index dedc114276..ffb56b14fb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt index 865462615a..27d72c154e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt index 6240eba9ad..73d993d0b0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.hide.fullscreenambientmode.fingerprints.InitializeAmbientModeFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index 78444f212f..ef9f41f000 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -10,6 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.* import app.revanced.patches.youtube.layout.hide.general.fingerprints.ParseElementFromBufferFingerprint import app.revanced.patches.youtube.layout.hide.general.fingerprints.PlayerOverlayFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt index fe3220fab8..bc590a97d9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt index 1d07c57026..cf75e3f99e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressPatch.kt deleted file mode 100644 index 011ec9df00..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressPatch.kt +++ /dev/null @@ -1,54 +0,0 @@ -package app.revanced.patches.youtube.layout.hide.personalinformation - -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotation.CompatiblePackage -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.youtube.layout.hide.personalinformation.fingerprints.AccountSwitcherAccessibilityLabelFingerprint -import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch -import app.revanced.util.exception -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction - -@Deprecated("This patch is no longer working and will be removed in a future release.") -@Patch( - description = "Hides the email address in the account switcher.", - dependencies = [IntegrationsPatch::class, HideEmailAddressResourcePatch::class], - compatiblePackages = [ - CompatiblePackage( - "com.google.android.youtube", [ - "18.32.39", - "18.37.36", - "18.38.44", - "18.43.45", - "18.44.41", - "18.45.41", - "18.45.43" - ] - ) - ] -) -@Suppress("unused") -object HideEmailAddressPatch : BytecodePatch( - setOf(AccountSwitcherAccessibilityLabelFingerprint) -) { - override fun execute(context: BytecodeContext) { - AccountSwitcherAccessibilityLabelFingerprint.result?.let { - it.mutableMethod.apply { - val setVisibilityConstIndex = it.scanResult.patternScanResult!!.endIndex - - val setVisibilityConstRegister = - getInstruction(setVisibilityConstIndex - 2).registerA - - addInstructions( - setVisibilityConstIndex, - """ - invoke-static {v$setVisibilityConstRegister}, Lapp/revanced/integrations/patches/HideEmailAddressPatch;->hideEmailAddress(I)I - move-result v$setVisibilityConstRegister - """ - ) - } - } ?: throw AccountSwitcherAccessibilityLabelFingerprint.exception - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressResourcePatch.kt deleted file mode 100644 index 3838d0dc42..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressResourcePatch.kt +++ /dev/null @@ -1,30 +0,0 @@ -package app.revanced.patches.youtube.layout.hide.personalinformation - -import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference -import app.revanced.patches.youtube.misc.settings.SettingsPatch - -@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class]) -@Suppress("unused") -internal object HideEmailAddressResourcePatch : ResourcePatch() { - internal var accountSwitcherAccessibilityLabelId: Long = -1 - - override fun execute(context: ResourceContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_email_address", - StringResource("revanced_hide_email_address_title", "Hide email in account switcher"), - StringResource("revanced_hide_email_address_summary_on", "Email address is hidden"), - StringResource("revanced_hide_email_address_summary_off", "Email address is shown") - ) - ) - - accountSwitcherAccessibilityLabelId = ResourceMappingPatch.resourceMappings.single { - it.type == "string" && it.name == "account_switcher_accessibility_label" - }.id - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt deleted file mode 100644 index 6ea89a8df0..0000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/fingerprints/AccountSwitcherAccessibilityLabelFingerprint.kt +++ /dev/null @@ -1,20 +0,0 @@ -package app.revanced.patches.youtube.layout.hide.personalinformation.fingerprints - -import app.revanced.patches.youtube.layout.hide.personalinformation.HideEmailAddressResourcePatch -import app.revanced.util.patch.LiteralValueFingerprint -import com.android.tools.smali.dexlib2.Opcode - -internal object AccountSwitcherAccessibilityLabelFingerprint : LiteralValueFingerprint( - returnType = "V", - parameters = listOf("L", "Ljava/lang/Object;"), - opcodes = listOf( - Opcode.INVOKE_VIRTUAL, - Opcode.IGET_OBJECT, - Opcode.IGET_OBJECT, - Opcode.NEW_ARRAY, - Opcode.CONST_4, - Opcode.APUT_OBJECT, - Opcode.CONST, - ), - literalSupplier = { HideEmailAddressResourcePatch.accountSwitcherAccessibilityLabelId } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt index ceea41f63b..e32b0808a6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt index 43b0d45414..7740190986 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt index 3d3c8dc205..fd6d8399d4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.seekbar.SeekbarColorBytecodePatch import app.revanced.patches.youtube.layout.seekbar.SeekbarPreferencesPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt index 51c05873e3..e41c7a9bd3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt index f43faaee32..a31df001e3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt index 0712c6cc8c..2a185c8c9e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.hide.time.fingerprints.TimeCounterFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt index f2d8d5ddc0..0bb1917679 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.panels.popup.fingerprints.EngagementPanelControllerFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt index 78649a6ae4..a724405cb4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.impl.InputType -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.TextPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt index de38d67141..76a9d8a526 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt @@ -3,28 +3,33 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.all.misc.strings.AddResourcesPatch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.Preference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.patches.shared.settings.preference.impl.IntentPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch -import app.revanced.util.mergeStrings +import app.revanced.util.copyStrings +import app.revanced.util.resource.StringResource @Patch( - dependencies = [SettingsPatch::class] + dependencies = [ + SettingsPatch::class, + AddResourcesPatch::class + ] ) internal object ReturnYouTubeDislikeResourcePatch : ResourcePatch() { internal var oldUIDislikeId: Long = -1 override fun execute(context: ResourceContext) { - SettingsPatch.addPreference( - Preference( + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + IntentPreference( StringResource("revanced_ryd_settings_title", "Return YouTube Dislike"), StringResource("revanced_ryd_settings_summary", "Settings for Return YouTube Dislike"), - SettingsPatch.createReVancedSettingsIntent("ryd_settings") + SettingsPatch.newIntent("ryd_settings") ) ) + // merge strings - context.mergeStrings("returnyoutubedislike/host/values/strings.xml") + context.copyStrings("returnyoutubedislike/host/values/strings.xml") oldUIDislikeId = ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == "dislike_button" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt index bc25906863..27db01924b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.searchbar.fingerprints.CreateSearchSuggestionsFingerprint import app.revanced.patches.youtube.layout.searchbar.fingerprints.SetWordmarkHeaderFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt index bebf677cf1..8da34fca0f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt @@ -7,11 +7,10 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.seekbar.fingerprints.FullscreenSeekbarThumbnailsFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch -import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( name = "Restore old seekbar thumbnails", diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt index dcdf6f672a..9bd025934a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.BasePreference import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.youtube.misc.settings.SettingsPatch import java.io.Closeable diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt index c3cb068e20..cd37941454 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt @@ -3,24 +3,29 @@ package app.revanced.patches.youtube.layout.sponsorblock import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.all.misc.strings.AddResourcesPatch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.Preference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.patches.shared.settings.preference.impl.IntentPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.ResourceGroup import app.revanced.util.copyResources +import app.revanced.util.copyStrings import app.revanced.util.copyXmlNode -import app.revanced.util.mergeStrings +import app.revanced.util.resource.StringResource -@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class]) +@Patch(dependencies = [ + SettingsPatch::class, + ResourceMappingPatch::class, + AddResourcesPatch::class +]) internal object SponsorBlockResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { - SettingsPatch.addPreference( - Preference( + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( + IntentPreference( StringResource("revanced_sponsorblock_settings_title", "SponsorBlock"), StringResource("revanced_sponsorblock_settings_summary", "SponsorBlock related settings"), - SettingsPatch.createReVancedSettingsIntent("sponsorblock_settings") + SettingsPatch.newIntent("sponsorblock_settings") ) ) val classLoader = this.javaClass.classLoader @@ -28,7 +33,7 @@ internal object SponsorBlockResourcePatch : ResourcePatch() { /* merge SponsorBlock strings to main strings */ - context.mergeStrings("sponsorblock/host/values/strings.xml") + context.copyStrings("sponsorblock/host/values/strings.xml") /* merge SponsorBlock drawables to main drawables diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt index f0892f8bc6..a62f229e7f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt @@ -6,9 +6,9 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.ArrayResource +import app.revanced.util.resource.ArrayResource import app.revanced.patches.shared.settings.preference.impl.ListPreference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.spoofappversion.fingerprints.SpoofAppVersionFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt index 5e11bf838d..cadb6e13fb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt @@ -5,10 +5,10 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.fingerprints.HomeActivityFingerprint -import app.revanced.patches.shared.settings.preference.impl.ArrayResource +import app.revanced.patches.youtube.shared.fingerprints.HomeActivityFingerprint +import app.revanced.util.resource.ArrayResource import app.revanced.patches.shared.settings.preference.impl.ListPreference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.youtube.layout.startpage.fingerprints.StartActivityFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt index 0bef8144ba..a9c72c638f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.startupshortsreset.fingerprints.UserWasInShortsFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt index 9b785d668a..ad23b9eec7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.tablet.fingerprints.GetFormFactorFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt index 5a22ce5bdb..2b3f27f2fa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerDimensionsCalculatorParentFingerprint import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerOverrideFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt index 50f7c2bf2b..0f61638384 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.layout.seekbar.SeekbarColorBytecodePatch import app.revanced.patches.youtube.layout.theme.fingerprints.UseGradientLoadingScreenFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt index f6fc643358..3baad14f3e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.impl.InputType -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.shared.settings.preference.impl.TextPreference import app.revanced.patches.youtube.layout.seekbar.SeekbarPreferencesPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt index 958b8aac3c..edb6698db0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt @@ -10,6 +10,8 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable +import app.revanced.util.resource.ArrayResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.* import app.revanced.patches.youtube.layout.thumbnails.fingerprints.MessageDigestImageUrlFingerprint import app.revanced.patches.youtube.layout.thumbnails.fingerprints.MessageDigestImageUrlParentFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt index 080b2beccb..5f8575f6f4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt @@ -3,14 +3,18 @@ package app.revanced.patches.youtube.layout.thumbnails import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.all.misc.strings.AddResourcesPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch -import app.revanced.util.mergeStrings +import app.revanced.util.copyStrings @Patch( - dependencies = [SettingsPatch::class] + dependencies = [ + SettingsPatch::class, + AddResourcesPatch::class + ] ) internal object AlternativeThumbnailsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { - context.mergeStrings("alternativethumbnails/host/values/strings.xml") + context.copyStrings("alternativethumbnails/host/values/strings.xml") } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt index 1636a9d65d..eafd65d1fa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.shared.fingerprints.WatchWhileActivityFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt index 293b25b557..c50891aa65 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.autorepeat.fingerprints.AutoRepeatFingerprint import app.revanced.patches.youtube.misc.autorepeat.fingerprints.AutoRepeatParentFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/DebuggingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/DebuggingPatch.kt index 8898b76eb7..2da63480ad 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/DebuggingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/DebuggingPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt index 974a344d81..5e36cebbef 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.dimensions.spoof.fingerprints.DeviceDimensionsModelToStringFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt index fda8784877..d8b234d8c8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.fix.playback.fingerprints.* import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt index 7d1a11e33e..6db85b9c10 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt @@ -1,8 +1,6 @@ package app.revanced.patches.youtube.misc.gms -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patches.shared.fingerprints.HomeActivityFingerprint +import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint import app.revanced.patches.shared.misc.gms.AbstractGmsCoreSupportPatch import app.revanced.patches.youtube.layout.buttons.cast.HideCastButtonPatch import app.revanced.patches.youtube.misc.fix.playback.ClientSpoofPatch @@ -10,7 +8,8 @@ import app.revanced.patches.youtube.misc.gms.Constants.REVANCED_YOUTUBE_PACKAGE_ import app.revanced.patches.youtube.misc.gms.Constants.YOUTUBE_PACKAGE_NAME import app.revanced.patches.youtube.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorOption import app.revanced.patches.youtube.misc.gms.fingerprints.* -import app.revanced.util.exception +import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch +import app.revanced.patches.youtube.shared.fingerprints.HomeActivityFingerprint @Suppress("unused") @@ -25,6 +24,8 @@ object GmsCoreSupportPatch : AbstractGmsCoreSupportPatch( CastDynamiteModuleV2Fingerprint, CastContextFetchFingerprint ), + mainActivityOnCreateFingerprint = HomeActivityFingerprint, + integrationsPatchDependency = IntegrationsPatch::class, dependencies = setOf( HideCastButtonPatch::class, ClientSpoofPatch::class @@ -50,18 +51,7 @@ object GmsCoreSupportPatch : AbstractGmsCoreSupportPatch( CastDynamiteModuleV2Fingerprint, CastContextFetchFingerprint, PrimeMethodFingerprint, - HomeActivityFingerprint, ) ) { override val gmsCoreVendor by gmsCoreVendorOption - - override fun execute(context: BytecodeContext) { - // Check the availability of GmsCore. - HomeActivityFingerprint.result?.mutableMethod?.addInstruction( - 0, - "invoke-static {}, Lapp/revanced/integrations/patches/GmsCoreSupport;->checkAvailability()V" - ) ?: throw HomeActivityFingerprint.exception - - super.execute(context) - } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt index 8482704d2a..5a3ae0bce3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt @@ -1,13 +1,12 @@ package app.revanced.patches.youtube.misc.gms import app.revanced.patcher.data.ResourceContext -import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch import app.revanced.patches.shared.misc.gms.AbstractGmsCoreSupportResourcePatch -import app.revanced.patches.shared.settings.preference.impl.Preference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.patches.shared.settings.preference.impl.IntentPreference import app.revanced.patches.youtube.misc.gms.Constants.REVANCED_YOUTUBE_PACKAGE_NAME import app.revanced.patches.youtube.misc.gms.Constants.YOUTUBE_PACKAGE_NAME import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.resource.StringResource object GmsCoreSupportResourcePatch : AbstractGmsCoreSupportResourcePatch( @@ -17,17 +16,16 @@ object GmsCoreSupportResourcePatch : AbstractGmsCoreSupportResourcePatch( dependencies = setOf(SettingsPatch::class) ) { override fun execute(context: ResourceContext) { - SettingsPatch.addPreference( - Preference( + SettingsPatch.PreferenceScreen.MISC.addPreferences( + IntentPreference( StringResource("microg_settings", "GmsCore Settings"), StringResource("microg_settings_summary", "Settings for GmsCore"), - Preference.Intent("$gmsCoreVendor.android.gms", "", "org.microg.gms.ui.SettingsActivity") + IntentPreference.Intent("", "org.microg.gms.ui.SettingsActivity") { + "$gmsCoreVendor.android.gms" + } ) ) - val packageName = ChangePackageNamePatch.setOrGetFallbackPackageName(REVANCED_YOUTUBE_PACKAGE_NAME) - SettingsPatch.renameIntentsTargetPackage(packageName) - super.execute(context) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt index 143d595417..fabb2e80ef 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.links.fingerprints.ABUriParserFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt index b8508db019..1fb2a98e90 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.all.misc.transformation.AbstractTransformInstructionsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/MinimizedPlaybackPatch.kt index 3704443d1f..d907430e9c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/MinimizedPlaybackPatch.kt @@ -9,7 +9,7 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.shared.settings.preference.impl.NonInteractivePreference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.KidsMinimizedPlaybackPolicyControllerFingerprint import app.revanced.patches.youtube.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt index 1a10eb1878..62b132599e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.privacy.fingerprints.CopyTextFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt index 67ad2c00e5..32a8f474e5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.misc.settings -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -8,11 +7,16 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.Preference +import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch +import app.revanced.patches.shared.settings.preference.impl.InputType +import app.revanced.patches.shared.settings.preference.impl.IntentPreference +import app.revanced.patches.shared.settings.preference.impl.TextPreference import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.fingerprints.LicenseActivityFingerprint import app.revanced.patches.youtube.misc.settings.fingerprints.SetThemeFingerprint +import app.revanced.util.exception +import app.revanced.util.resource.StringResource import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.util.MethodUtil @@ -33,16 +37,16 @@ object SettingsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { // TODO: Remove this when it is only required at one place. fun getSetThemeInstructionString( - registers: String = "v0", - classDescriptor: String = THEME_HELPER_DESCRIPTOR, - methodName: String = SET_THEME_METHOD_NAME, - parameters: String = "Ljava/lang/Object;" + registers: String = "v0", + classDescriptor: String = THEME_HELPER_DESCRIPTOR, + methodName: String = SET_THEME_METHOD_NAME, + parameters: String = "Ljava/lang/Object;" ) = "invoke-static { $registers }, $classDescriptor->$methodName($parameters)V" SetThemeFingerprint.result?.mutableMethod?.let { setThemeMethod -> setThemeMethod.implementation!!.instructions.mapIndexedNotNull { i, instruction -> - if (instruction.opcode == Opcode.RETURN_OBJECT) i else null - } + if (instruction.opcode == Opcode.RETURN_OBJECT) i else null + } .asReversed() // Prevent index shifting. .forEach { returnIndex -> // The following strategy is to replace the return instruction with the setTheme instruction, @@ -60,61 +64,54 @@ object SettingsPatch : BytecodePatch( } } ?: throw SetThemeFingerprint.exception - // Modify the license activity and remove all existing layout code. // Must modify an existing activity and cannot add a new activity to the manifest, // as that fails for root installations. LicenseActivityFingerprint.result!!.apply licenseActivity@{ - mutableMethod.apply { - fun buildSettingsActivityInvokeString( - registers: String = "p0", - classDescriptor: String = SETTINGS_ACTIVITY_DESCRIPTOR, - methodName: String = "initializeSettings", - parameters: String = "Landroid/app/Activity;" - ) = getSetThemeInstructionString(registers, classDescriptor, methodName, parameters) - - // initialize the settings - addInstructions( - 1, - """ - ${buildSettingsActivityInvokeString()} - return-void - """ - ) - } - - // remove method overrides + fun buildSettingsActivityInvokeString( + registers: String = "p0", + classDescriptor: String = SETTINGS_ACTIVITY_DESCRIPTOR, + methodName: String = "initializeSettings", + parameters: String = "Landroid/app/Activity;" + ) = getSetThemeInstructionString(registers, classDescriptor, methodName, parameters) + + // Initialize settings. + mutableMethod.addInstructions( + 1, + """ + ${buildSettingsActivityInvokeString()} + return-void + """ + ) + + // Remove method overrides. mutableClass.apply { methods.removeIf { it.name != "onCreate" && !MethodUtil.isConstructor(it) } } } - } - - fun addString(identifier: String, value: String, formatted: Boolean = true) = - SettingsResourcePatch.addString(identifier, value, formatted) - - fun addPreferenceScreen(preferenceScreen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) = - SettingsResourcePatch.addPreferenceScreen(preferenceScreen) - - fun addPreference(preference: Preference) = SettingsResourcePatch.addPreference(preference) - - fun renameIntentsTargetPackage(newPackage: String) { - SettingsResourcePatch.overrideIntentsTargetPackage = newPackage + PreferenceScreen.MISC.addPreferences( + TextPreference( + key = null, + title = StringResource("revanced_pref_import_export_title", "Import / Export"), + summary = StringResource("revanced_pref_import_export_summary", "Import / Export ReVanced settings"), + inputType = InputType.TEXT_MULTI_LINE, + tag = "app.revanced.integrations.settingsmenu.ImportExportPreference" + ) + ) } /** - * Creates an intent to open ReVanced settings of the given name + * Creates an intent to open ReVanced settings. */ - fun createReVancedSettingsIntent(settingsName: String) = Preference.Intent( - "com.google.android.youtube", - settingsName, - "com.google.android.libraries.social.licenses.LicenseActivity" - ) + fun newIntent(settingsName: String) = IntentPreference.Intent( + data = settingsName, + targetClass = "com.google.android.libraries.social.licenses.LicenseActivity" + ) { + // The package name change has to be reflected in the intent. + ChangePackageNamePatch.setOrGetFallbackPackageName("com.google.android.apps.youtube") + } - /** - * Preference screens patches should add their settings to. - */ object PreferenceScreen : AbstractPreferenceScreen() { val ADS = Screen("ads", "Ads", "Ad related settings") val INTERACTIONS = Screen("interactions", "Interaction", "Settings related to interactions") @@ -122,9 +119,8 @@ object SettingsPatch : BytecodePatch( val VIDEO = Screen("video", "Video", "Settings related to the video player") val MISC = Screen("misc", "Misc", "Miscellaneous patches") - override fun commit(screen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) { - addPreferenceScreen(screen) - } + override fun commit(screen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) = + SettingsResourcePatch.addPreference(screen) } override fun close() = PreferenceScreen.close() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt index a95eb31a1c..6a806bab15 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt @@ -1,39 +1,30 @@ package app.revanced.patches.youtube.misc.settings import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patcher.util.DomFileEditor +import app.revanced.patches.all.misc.strings.AddResourcesPatch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch -import app.revanced.patches.shared.settings.preference.addPreference -import app.revanced.patches.shared.settings.preference.impl.* +import app.revanced.patches.shared.settings.preference.impl.IntentPreference import app.revanced.util.ResourceGroup import app.revanced.util.copyResources -import app.revanced.util.mergeStrings +import app.revanced.util.copyStrings +import app.revanced.util.resource.StringResource import org.w3c.dom.Element -import org.w3c.dom.Node -@Patch( - dependencies = [ResourceMappingPatch::class] -) object SettingsResourcePatch : AbstractSettingsResourcePatch( - "revanced_prefs", - "settings" + IntentPreference( + StringResource("revanced_settings", "ReVanced"), + StringResource("revanced_settings_summary", "Settings for ReVanced"), + SettingsPatch.newIntent("revanced_settings") + ) to "settings_fragment", + dependencies = setOf( + ResourceMappingPatch::class, + AddResourcesPatch::class, + ) ) { // Used for a fingerprint from SettingsPatch. internal var appearanceStringId = -1L - // if this is not null, all intents will be renamed to this - internal var overrideIntentsTargetPackage: String? = null - - private var preferencesNode: Node? = null - - private var preferencesEditor: DomFileEditor? = null - set(value) { - field = value - preferencesNode = value.getNode("PreferenceScreen") - } - override fun execute(context: ResourceContext) { super.execute(context) @@ -42,22 +33,17 @@ object SettingsResourcePatch : AbstractSettingsResourcePatch( it.type == "string" && it.name == "app_theme_appearance_dark" }!!.id - /* - * copy layout resources - */ arrayOf( ResourceGroup("layout", "revanced_settings_with_toolbar.xml") ).forEach { resourceGroup -> context.copyResources("settings", resourceGroup) } - preferencesEditor = context.xmlEditor["res/xml/settings_fragment.xml"] - - // Modify the manifest and add an data intent filter to the LicenseActivity. + // Modify the manifest and add a data intent filter to the LicenseActivity. // Some devices freak out if undeclared data is passed to an intent, // and this change appears to fix the issue. context.xmlEditor["AndroidManifest.xml"].use { editor -> - // An xml regular expression would probably work better than this manual searching. + // A xml regular-expression would probably work better than this manual searching. val manifestNodes = editor.file.getElementsByTagName("manifest").item(0).childNodes for (i in 0..manifestNodes.length) { val node = manifestNodes.item(i) @@ -80,89 +66,6 @@ object SettingsResourcePatch : AbstractSettingsResourcePatch( } } - - // Add the ReVanced settings to the YouTube settings - SettingsPatch.addPreference( - Preference( - StringResource("revanced_settings", "ReVanced"), - StringResource("revanced_settings_summary", "ReVanced specific settings"), - SettingsPatch.createReVancedSettingsIntent("revanced_settings") - ) - ) - - SettingsPatch.PreferenceScreen.MISC.addPreferences( - TextPreference( - key = null, - title = StringResource("revanced_pref_import_export_title", "Import / Export"), - summary = StringResource("revanced_pref_import_export_summary", "Import / Export ReVanced settings"), - inputType = InputType.TEXT_MULTI_LINE, - tag = "app.revanced.integrations.settingsmenu.ImportExportPreference" - ) - ) - - context.mergeStrings("settings/host/values/strings.xml") - } - - override fun close() { - super.close() - - // rename the intent package names if it was set - overrideIntentsTargetPackage?.let { packageName -> - val preferences = preferencesEditor!!.getNode("PreferenceScreen").childNodes - for (i in 1 until preferences.length) { - val preferenceNode = preferences.item(i) - // preferences have a child node with the intent tag, skip over every other node - if (preferenceNode.childNodes.length == 0) continue - - val intentNode = preferenceNode.firstChild - - // if the node doesn't have a target package attribute, skip it - val targetPackageAttribute = intentNode.attributes.getNamedItem("android:targetPackage") ?: continue - - // do not replace intent target package if the package name is not from YouTube - val youtubePackage = "com.google.android.youtube" - if (targetPackageAttribute.nodeValue != youtubePackage) continue - - // replace the target package name - intentNode.attributes.setNamedItem(preferenceNode.ownerDocument.createAttribute("android:targetPackage") - .also { attribute -> - attribute.value = packageName - }) - } - } - - preferencesEditor?.close() + context.copyStrings("settings/host/values/strings.xml") } - - /** - * Add a preference fragment to the main preferences. - * - * @param preference The preference to add. - */ - internal fun addPreference(preference: Preference) = - preferencesNode!!.addPreference(preference) { it.include() } - - /** - * Add a new string to the resources. - * - * @param identifier The key of the string. - * @param value The value of the string. - * @throws IllegalArgumentException if the string already exists. - */ - internal fun addString(identifier: String, value: String, formatted: Boolean) = - AbstractSettingsResourcePatch.addString(identifier, value, formatted) - - /** - * Add an array to the resources. - * - * @param arrayResource The array resource to add. - */ - internal fun addArray(arrayResource: ArrayResource) = AbstractSettingsResourcePatch.addArray(arrayResource) - - /** - * Add a preference to the settings. - * - * @param preferenceScreen The name of the preference screen. - */ - internal fun addPreferenceScreen(preferenceScreen: PreferenceScreen) = addPreference(preferenceScreen) } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/fingerprints/SetThemeFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/fingerprints/SetThemeFingerprint.kt index 28d9d41199..caf19d4269 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/fingerprints/SetThemeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/fingerprints/SetThemeFingerprint.kt @@ -12,4 +12,4 @@ internal object SetThemeFingerprint : LiteralValueFingerprint( parameters = listOf(), opcodes = listOf(Opcode.RETURN_OBJECT), literalSupplier = { SettingsResourcePatch.appearanceStringId } -) \ No newline at end of file +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt index 3c14f81a86..2ef4f701a5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.misc.zoomhaptics.fingerprints.ZoomHapticsFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/HomeActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/HomeActivityFingerprint.kt new file mode 100644 index 0000000000..f54b9ee7c8 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/HomeActivityFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.youtube.shared.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object HomeActivityFingerprint : MethodFingerprint( + customFingerprint = { methodDef, classDef -> + methodDef.name == "onCreate" && classDef.type.endsWith("Shell_HomeActivity;") + }, +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/HDRBrightnessPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/HDRBrightnessPatch.kt index d565d0a40c..6847be8001 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/HDRBrightnessPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/HDRBrightnessPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt index 1f1ca33759..33a46dab81 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt @@ -9,9 +9,9 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.ArrayResource +import app.revanced.util.resource.ArrayResource import app.revanced.patches.shared.settings.preference.impl.ListPreference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt index 4c572ffa6c..18518812cb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable import app.revanced.patches.shared.settings.preference.impl.InputType -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.TextPreference import app.revanced.patches.youtube.misc.recyclerviewtree.hook.RecyclerViewTreeHookPatch import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt index c37c7792c6..3e15f1b152 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt @@ -7,9 +7,9 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.ArrayResource +import app.revanced.util.resource.ArrayResource import app.revanced.patches.shared.settings.preference.impl.ListPreference -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt index b16e1066fd..bbe8152536 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.StringResource +import app.revanced.util.resource.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/util/ResourceUtils.kt b/src/main/kotlin/app/revanced/util/ResourceUtils.kt index d7aef39b6e..b073f9f5e7 100644 --- a/src/main/kotlin/app/revanced/util/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/util/ResourceUtils.kt @@ -2,8 +2,8 @@ package app.revanced.util import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.util.DomFileEditor -import app.revanced.patches.shared.settings.preference.impl.StringResource -import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.util.resource.BaseResource import org.w3c.dom.Node import java.nio.file.Files import java.nio.file.StandardCopyOption @@ -21,11 +21,11 @@ fun Node.doRecursively(action: (Node) -> Unit) { } /** - * Merge strings. This manages [StringResource]s automatically. + * Add strings from a hosting xml resource. * * @param host The hosting xml resource. Needs to be a valid strings.xml resource. */ -fun ResourceContext.mergeStrings(host: String) { +fun ResourceContext.copyStrings(host: String) { this.iterateXmlNodeChildren(host, "resources") { // TODO: figure out why this is needed if (!it.hasAttributes()) return@iterateXmlNodeChildren @@ -36,7 +36,7 @@ fun ResourceContext.mergeStrings(host: String) { val formatted = attributes.getNamedItem("formatted") == null - SettingsPatch.addString(key, value, formatted) + AddResourcesPatch.addString(key, value, formatted) } } @@ -106,4 +106,16 @@ fun String.copyXmlNode(source: DomFileEditor, target: DomFileEditor): AutoClosea source.close() target.close() } -} \ No newline at end of file +} + +/** + * Add a resource node child. + * + * @param resource The resource to add. + * @param resourceCallback Called when a resource has been processed. + */ +internal fun Node.addResource(resource: BaseResource, resourceCallback: (BaseResource) -> Unit = { }) { + appendChild(resource.serialize(ownerDocument, resourceCallback)) +} + +internal fun DomFileEditor?.getNode(tagName: String) = this!!.file.getElementsByTagName(tagName).item(0) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ArrayResource.kt b/src/main/kotlin/app/revanced/util/resource/ArrayResource.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ArrayResource.kt rename to src/main/kotlin/app/revanced/util/resource/ArrayResource.kt index fa5e12f3ce..eb4b846b81 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ArrayResource.kt +++ b/src/main/kotlin/app/revanced/util/resource/ArrayResource.kt @@ -1,6 +1,5 @@ -package app.revanced.patches.shared.settings.preference.impl +package app.revanced.util.resource -import app.revanced.patches.shared.settings.preference.BaseResource import org.w3c.dom.Document // TODO: allow specifying an array resource file instead of using a list of StringResources diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/BaseResource.kt b/src/main/kotlin/app/revanced/util/resource/BaseResource.kt similarity index 65% rename from src/main/kotlin/app/revanced/patches/shared/settings/preference/BaseResource.kt rename to src/main/kotlin/app/revanced/util/resource/BaseResource.kt index 682ccb33ae..f8b22512fd 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/BaseResource.kt +++ b/src/main/kotlin/app/revanced/util/resource/BaseResource.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.settings.preference +package app.revanced.util.resource import org.w3c.dom.Document import org.w3c.dom.Element @@ -24,4 +24,19 @@ abstract class BaseResource( setAttribute("name", name) } } + + override fun hashCode(): Int { + var result = name.hashCode() + result = 31 * result + tag.hashCode() + return result + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as BaseResource + + return name == other.name + } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/StringResource.kt b/src/main/kotlin/app/revanced/util/resource/StringResource.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/StringResource.kt rename to src/main/kotlin/app/revanced/util/resource/StringResource.kt index b3cd839723..9c1b6825c1 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/StringResource.kt +++ b/src/main/kotlin/app/revanced/util/resource/StringResource.kt @@ -1,6 +1,5 @@ -package app.revanced.patches.shared.settings.preference.impl +package app.revanced.util.resource -import app.revanced.patches.shared.settings.preference.BaseResource import org.w3c.dom.Document /** @@ -16,7 +15,6 @@ class StringResource( val value: String, val formatted: Boolean = true ) : BaseResource(name, "string") { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = super.serialize(ownerDocument, resourceCallback).apply { // if the string is un-formatted, explicitly add the formatted attribute diff --git a/src/main/resources/twitch/settings/xml/revanced_prefs.xml b/src/main/resources/twitch/settings/xml/revanced_prefs.xml deleted file mode 100644 index 14e1c85de5..0000000000 --- a/src/main/resources/twitch/settings/xml/revanced_prefs.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file From 06e9e52b267d13f80022321c8073b122d984d1f5 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 6 Jan 2024 16:15:44 +0100 Subject: [PATCH 2/3] fix: Use correct package name --- src/main/kotlin/app/revanced/meta/PatchesFileGenerator.kt | 2 +- .../all/misc/{strings => resources}/AddResourcesPatch.kt | 2 +- .../shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt | 2 +- .../patches/shared/settings/AbstractSettingsResourcePatch.kt | 2 +- .../revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt | 4 ++-- .../twitch/chat/antidelete/ShowDeletedMessagesPatch.kt | 2 +- .../revanced/patches/twitch/misc/settings/SettingsPatch.kt | 4 ++-- .../interaction/copyvideourl/CopyVideoUrlResourcePatch.kt | 2 +- .../interaction/downloads/ExternalDownloadsResourcePatch.kt | 2 +- .../returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt | 2 +- .../youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt | 2 +- .../layout/thumbnails/AlternativeThumbnailsResourcePatch.kt | 2 +- .../patches/youtube/misc/settings/SettingsResourcePatch.kt | 3 +-- src/main/kotlin/app/revanced/util/ResourceUtils.kt | 2 +- 14 files changed, 16 insertions(+), 17 deletions(-) rename src/main/kotlin/app/revanced/patches/all/misc/{strings => resources}/AddResourcesPatch.kt (97%) diff --git a/src/main/kotlin/app/revanced/meta/PatchesFileGenerator.kt b/src/main/kotlin/app/revanced/meta/PatchesFileGenerator.kt index 61d8e85dae..2e6703b8ba 100644 --- a/src/main/kotlin/app/revanced/meta/PatchesFileGenerator.kt +++ b/src/main/kotlin/app/revanced/meta/PatchesFileGenerator.kt @@ -17,4 +17,4 @@ internal interface PatchesFileGenerator { arrayOf(JsonGenerator()).forEach { generator -> generator.generate(bundle) } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/all/misc/strings/AddResourcesPatch.kt b/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/all/misc/strings/AddResourcesPatch.kt rename to src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt index bc8ed19f44..9ae468db77 100644 --- a/src/main/kotlin/app/revanced/patches/all/misc/strings/AddResourcesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.all.misc.strings +package app.revanced.patches.all.misc.resources import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt index 87b2e6c312..6e37ebbe90 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch -import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.util.copyStrings import org.w3c.dom.Element import org.w3c.dom.Node diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt index 08e7dcdce6..73226fefd2 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.PatchClass import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.util.DomFileEditor -import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.settings.preference.BasePreference import app.revanced.patches.shared.settings.preference.impl.IntentPreference import app.revanced.util.ResourceGroup diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt index f72195eb7a..17d794a3da 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.all.misc.strings.AddResourcesPatch -import app.revanced.patches.all.misc.strings.AddResourcesPatch.addString +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch.addString import app.revanced.patches.shared.settings.preference.impl.ListPreference import app.revanced.patches.twitch.ad.embedded.fingerprints.CreateUsherClientFingerprint import app.revanced.patches.twitch.ad.video.VideoAdsPatch diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt index 5bcbd7bfc8..50224d4232 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.settings.preference.impl.ListPreference import app.revanced.patches.twitch.chat.antidelete.fingerprints.ChatUtilCreateDeletedSpanFingerprint import app.revanced.patches.twitch.chat.antidelete.fingerprints.DeletedMessageClickableSpanCtorFingerprint diff --git a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt index faeb8cdc96..b59a3e05a4 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt @@ -11,8 +11,8 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.all.misc.strings.AddResourcesPatch -import app.revanced.patches.all.misc.strings.AddResourcesPatch.addString +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch.addString import app.revanced.patches.shared.settings.preference.impl.PreferenceCategory import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt index f708e7063e..d98b271c90 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.interaction.copyvideourl import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.playercontrols.BottomControlsResourcePatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt index d272643a2f..3bba3c1c93 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.interaction.downloads import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.settings.preference.impl.InputType import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen import app.revanced.patches.shared.settings.preference.impl.SwitchPreference diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt index 76a9d8a526..fe70b776c4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.impl.IntentPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt index cd37941454..475684bba4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.sponsorblock import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.shared.settings.preference.impl.IntentPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt index 5f8575f6f4..5cb9e0a03a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.thumbnails import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.copyStrings diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt index ed7c6209af..a7200b9607 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt @@ -1,13 +1,12 @@ package app.revanced.patches.youtube.misc.settings import app.revanced.patcher.data.ResourceContext -import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch import app.revanced.patches.shared.settings.preference.impl.IntentPreference import app.revanced.util.ResourceGroup import app.revanced.util.copyResources -import app.revanced.util.copyStrings import app.revanced.util.resource.StringResource import org.w3c.dom.Element diff --git a/src/main/kotlin/app/revanced/util/ResourceUtils.kt b/src/main/kotlin/app/revanced/util/ResourceUtils.kt index c8489d20a7..8636fbf5a3 100644 --- a/src/main/kotlin/app/revanced/util/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/util/ResourceUtils.kt @@ -2,7 +2,7 @@ package app.revanced.util import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.util.DomFileEditor -import app.revanced.patches.all.misc.strings.AddResourcesPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.util.resource.BaseResource import org.w3c.dom.Node import java.io.InputStream From 4bee51af30a4b2883c97ea6685e6aa86b853d003 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 27 Jan 2024 01:57:34 +0100 Subject: [PATCH 3/3] feat: Support adding resources directly from the patch resources with localization for strings in mind (#2593) Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Co-authored-by: semantic-release-bot Co-authored-by: Aunali321 --- api/revanced-patches.api | 424 ++++--- ...eGenerator.kt => IPatchesFileGenerator.kt} | 4 +- ...nerator.kt => JsonPatchesFileGenerator.kt} | 2 +- .../connectivity/wifi/spoof/SpoofWifiPatch.kt | 4 +- .../packagename/ChangePackageNamePatch.kt | 20 +- .../all/misc/resources/AddResourcesPatch.kt | 278 ++++- ...h.kt => BaseTransformInstructionsPatch.kt} | 2 +- .../RemoveCaptureRestrictionPatch.kt | 4 +- .../RemoveScreenshotRestrictionPatch.kt | 6 +- .../sim/spoof/SpoofSimCountryPatch.kt | 4 +- .../music/misc/gms/GmsCoreSupportPatch.kt | 6 +- .../misc/gms/GmsCoreSupportResourcePatch.kt | 4 +- .../misc/integrations/IntegrationsPatch.kt | 4 +- .../ApplicationInitFingerprint.kt | 2 +- ...ClientPatch.kt => BaseSpoofClientPatch.kt} | 4 +- .../baconreader/api/SpoofClientPatch.kt | 4 +- .../boostforreddit/api/SpoofClientPatch.kt | 4 +- .../infinityforreddit/api/SpoofClientPatch.kt | 4 +- .../joeyforreddit/api/SpoofClientPatch.kt | 4 +- .../redditisfun/api/SpoofClientPatch.kt | 4 +- ...gerprint.kt => BaseClientIdFingerprint.kt} | 2 +- .../BasicAuthorizationFingerprint.kt | 2 +- .../BuildAuthorizationStringFingerprint.kt | 2 +- .../relayforreddit/api/SpoofClientPatch.kt | 4 +- ...gerprint.kt => BaseClientIdFingerprint.kt} | 2 +- .../GetLoggedInBearerTokenFingerprint.kt | 2 +- .../GetLoggedOutBearerTokenFingerprint.kt | 2 +- .../GetRefreshTokenFingerprint.kt | 2 +- .../LoginActivityClientIdFingerprint.kt | 2 +- .../slide/api/SpoofClientPatch.kt | 4 +- .../syncforreddit/api/SpoofClientPatch.kt | 4 +- ...ortPatch.kt => BaseGmsCoreSupportPatch.kt} | 16 +- ....kt => BaseGmsCoreSupportResourcePatch.kt} | 6 +- .../integrations/BaseIntegrationsPatch.kt} | 16 +- .../mapping}/ResourceMappingPatch.kt | 2 +- .../settings/BaseSettingsResourcePatch.kt} | 58 +- .../settings/preference/BasePreference.kt | 62 + .../preference/BasePreferenceScreen.kt | 93 ++ .../settings/preference}/InputType.kt | 2 +- .../settings/preference/IntentPreference.kt | 56 + .../settings/preference/ListPreference.kt | 72 ++ .../preference/NonInteractivePreference.kt | 26 + .../settings/preference/PreferenceCategory.kt | 28 + .../settings/preference/PreferenceScreen.kt | 30 + .../settings/preference/SummaryType.kt | 2 +- .../settings/preference/SwitchPreference.kt | 28 + .../settings/preference/TextPreference.kt | 28 + .../settings/preference/BasePreference.kt | 35 - .../preference/ComponentsExtensions.kt | 27 - .../preference/impl/IntentPreference.kt | 42 - .../preference/impl/ListPreference.kt | 32 - .../impl/NonInteractivePreference.kt | 36 - .../preference/impl/PreferenceCategory.kt | 27 - .../preference/impl/PreferenceScreen.kt | 30 - .../preference/impl/SwitchPreference.kt | 34 - .../preference/impl/TextPreference.kt | 27 - .../settings/util/AbstractPreferenceScreen.kt | 99 -- .../navbar/PremiumNavbarTabResourcePatch.kt | 2 +- .../misc/integrations/IntegrationsPatch.kt | 4 +- .../fingerprints/InitFingerprint.kt | 2 +- .../patches/twitch/ad/audio/AudioAdsPatch.kt | 28 +- .../twitch/ad/embedded/EmbeddedAdsPatch.kt | 48 +- .../{AbstractAdPatch.kt => BaseAdPatch.kt} | 2 +- .../patches/twitch/ad/video/VideoAdsPatch.kt | 34 +- .../antidelete/ShowDeletedMessagesPatch.kt | 44 +- .../autoclaim/AutoClaimChannelPointsPatch.kt | 28 +- .../patches/twitch/debug/DebugModePatch.kt | 30 +- .../misc/integrations/IntegrationsPatch.kt | 4 +- .../fingerprints/InitFingerprint.kt | 2 +- .../twitch/misc/settings/SettingsPatch.kt | 58 +- .../misc/settings/SettingsResourcePatch.kt | 4 +- ...BaseHookPatchPatch.kt => BaseHookPatch.kt} | 2 +- .../{HideAdsPatch.kt => HideAdsHookPatch.kt} | 4 +- .../HideRecommendedUsersPatch.kt | 4 +- .../ad/general/HideAdsResourcePatch.kt | 74 +- .../ad/getpremium/HideGetPremiumPatch.kt | 28 +- .../patches/youtube/ad/video/VideoAdsPatch.kt | 18 +- .../copyvideourl/CopyVideoUrlResourcePatch.kt | 39 +- .../RemoveViewerDiscretionDialogPatch.kt | 30 +- .../ExternalDownloadsResourcePatch.kt | 44 +- .../DisablePreciseSeekingGesturePatch.kt | 17 +- .../seekbar/EnableSeekbarTappingPatch.kt | 19 +- .../seekbar/EnableSlideToSeekPatch.kt | 28 +- .../SwipeControlsResourcePatch.kt | 103 +- .../layout/autocaptions/AutoCaptionsPatch.kt | 19 +- .../layout/buttons/action/HideButtonsPatch.kt | 87 +- .../autoplay/HideAutoplayButtonPatch.kt | 24 +- .../captions/HideCaptionsButtonPatch.kt | 18 +- .../buttons/cast/HideCastButtonPatch.kt | 18 +- .../navigation/NavigationButtonsPatch.kt | 73 +- .../ResolvePivotBarFingerprintsPatch.kt | 2 +- .../player/hide/HidePlayerButtonsPatch.kt | 29 +- .../albumcards/AlbumCardsResourcePatch.kt | 20 +- .../breakingnews/BreakingNewsResourcePatch.kt | 20 +- .../layout/hide/comments/CommentsPatch.kt | 35 +- .../CrowdfundingBoxResourcePatch.kt | 20 +- .../HideEndscreenCardsResourcePatch.kt | 20 +- .../filterbar/HideFilterBarResourcePatch.kt | 76 +- ...deFloatingMicrophoneButtonResourcePatch.kt | 23 +- .../DisableFullscreenAmbientModePatch.kt | 26 +- .../hide/general/HideLayoutComponentsPatch.kt | 439 +------ .../infocards/HideInfocardsResourcePatch.kt | 20 +- .../HideLoadMoreButtonResourcePatch.kt | 20 +- .../HideEmailAddressPatch.kt} | 0 .../HidePlayerFlyoutMenuPatch.kt | 87 +- .../DisableRollingNumberAnimationPatch.kt | 17 +- .../layout/hide/seekbar/HideSeekbarPatch.kt | 23 +- .../hide/shorts/HideShortsComponentsPatch.kt | 2 +- .../HideShortsComponentsResourcePatch.kt | 102 +- ...bleSuggestedVideoEndScreenResourcePatch.kt | 27 +- .../layout/hide/time/HideTimestampPatch.kt | 19 +- .../panels/popup/PlayerPopupPanelsPatch.kt | 19 +- ...CustomPlayerOverlayOpacityResourcePatch.kt | 25 +- .../ReturnYouTubeDislikeResourcePatch.kt | 16 +- .../layout/searchbar/WideSearchbarPatch.kt | 19 +- .../RestoreOldSeekbarThumbnailsPatch.kt | 28 +- .../seekbar/SeekbarColorResourcePatch.kt | 2 +- .../layout/seekbar/SeekbarPreferencesPatch.kt | 21 +- .../sponsorblock/SponsorBlockBytecodePatch.kt | 2 +- .../sponsorblock/SponsorBlockResourcePatch.kt | 75 +- .../spoofappversion/SpoofAppVersionPatch.kt | 54 +- .../layout/startpage/ChangeStartPagePatch.kt | 40 +- .../DisableResumingShortsOnStartupPatch.kt | 17 +- .../layout/tablet/EnableTabletLayoutPatch.kt | 20 +- .../tabletminiplayer/TabletMiniPlayerPatch.kt | 19 +- .../layout/theme/ThemeBytecodePatch.kt | 28 +- .../layout/theme/ThemeResourcePatch.kt | 38 +- .../thumbnails/AlternativeThumbnailsPatch.kt | 114 +- .../AlternativeThumbnailsResourcePatch.kt | 5 +- .../misc/announcements/AnnouncementsPatch.kt | 33 +- .../misc/autorepeat/AutoRepeatPatch.kt | 17 +- .../youtube/misc/debugging/DebuggingPatch.kt | 58 +- .../spoof/SpoofDeviceDimensionsPatch.kt | 23 +- .../misc/fix/playback/SpoofSignaturePatch.kt | 74 +- .../playback/SpoofSignatureResourcePatch.kt | 2 +- .../youtube/misc/gms/GmsCoreSupportPatch.kt | 6 +- .../misc/gms/GmsCoreSupportResourcePatch.kt | 17 +- .../misc/integrations/IntegrationsPatch.kt | 4 +- .../APIPlayerServiceFingerprint.kt | 2 +- .../ApplicationInitFingerprint.kt | 2 +- ...mbeddedPlayerControlsOverlayFingerprint.kt | 2 +- .../fingerprints/EmbeddedPlayerFingerprint.kt | 2 +- .../RemoteEmbedFragmentFingerprint.kt | 2 +- .../RemoteEmbeddedPlayerFingerprint.kt | 2 +- .../StandalonePlayerActivityFingerprint.kt | 2 +- .../misc/links/BypassURLRedirectsPatch.kt | 19 +- .../misc/links/OpenLinksExternallyPatch.kt | 20 +- .../MinimizedPlaybackPatch.kt | 25 +- .../BottomControlsResourcePatch.kt | 2 +- .../RemoveTrackingQueryParameterPatch.kt | 28 +- .../youtube/misc/settings/SettingsPatch.kt | 56 +- .../misc/settings/SettingsResourcePatch.kt | 16 +- .../misc/zoomhaptics/ZoomHapticsPatch.kt | 17 +- .../video/hdrbrightness/HDRBrightnessPatch.kt | 17 +- .../quality/RememberVideoQualityPatch.kt | 82 +- .../speed/custom/CustomPlaybackSpeedPatch.kt | 28 +- .../CustomPlaybackSpeedResourcePatch.kt | 2 +- .../remember/RememberPlaybackSpeedPatch.kt | 61 +- ...RestoreOldVideoQualityMenuResourcePatch.kt | 17 +- .../kotlin/app/revanced/util/BytecodeUtils.kt | 2 +- .../kotlin/app/revanced/util/ResourceUtils.kt | 38 +- .../revanced/util/resource/ArrayResource.kt | 21 +- .../revanced/util/resource/BaseResource.kt | 1 + .../revanced/util/resource/StringResource.kt | 22 +- .../resources/addresources/values/arrays.xml | 100 ++ .../resources/addresources/values/strings.xml | 1019 +++++++++++++++++ .../host/values/strings.xml | 9 - .../youtube_controls_bottom_ui_container.xml | 4 +- .../copyvideourl/host/values/strings.xml | 5 - .../youtube_controls_bottom_ui_container.xml | 2 +- .../downloads/host/values/strings.xml | 4 - .../resources/gms/host/values/strings.xml | 5 - .../host/values/strings.xml | 60 - .../settings/host/values/strings.xml | 15 - ...c_sb_adjust.xml => revanced_sb_adjust.xml} | 0 ...sb_compare.xml => revanced_sb_compare.xml} | 0 .../{ic_sb_edit.xml => revanced_sb_edit.xml} | 0 .../{ic_sb_logo.xml => revanced_sb_logo.xml} | 0 ...sb_publish.xml => revanced_sb_publish.xml} | 0 ...c_sb_voting.xml => revanced_sb_voting.xml} | 0 .../host/layout/youtube_controls_layout.xml | 10 +- .../sponsorblock/host/values/strings.xml | 194 ---- ...=> revanced_sb_inline_sponsor_overlay.xml} | 10 +- ...egment.xml => revanced_sb_new_segment.xml} | 22 +- ...ml => revanced_sb_skip_sponsor_button.xml} | 8 +- ...xml => revanced_ic_sc_brightness_auto.xml} | 0 ...l => revanced_ic_sc_brightness_manual.xml} | 0 ...ute.xml => revanced_ic_sc_volume_mute.xml} | 0 ...l.xml => revanced_ic_sc_volume_normal.xml} | 0 189 files changed, 3097 insertions(+), 3330 deletions(-) rename src/main/kotlin/app/revanced/meta/{PatchesFileGenerator.kt => IPatchesFileGenerator.kt} (78%) rename src/main/kotlin/app/revanced/meta/{JsonGenerator.kt => JsonPatchesFileGenerator.kt} (95%) rename src/main/kotlin/app/revanced/patches/all/misc/transformation/{AbstractTransformInstructionsPatch.kt => BaseTransformInstructionsPatch.kt} (96%) rename src/main/kotlin/app/revanced/patches/reddit/customclients/{AbstractSpoofClientPatch.kt => BaseSpoofClientPatch.kt} (98%) rename src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/{AbstractClientIdFingerprint.kt => BaseClientIdFingerprint.kt} (68%) rename src/main/kotlin/app/revanced/patches/reddit/customclients/relayforreddit/api/fingerprints/{AbstractClientIdFingerprint.kt => BaseClientIdFingerprint.kt} (68%) rename src/main/kotlin/app/revanced/patches/shared/misc/gms/{AbstractGmsCoreSupportPatch.kt => BaseGmsCoreSupportPatch.kt} (95%) rename src/main/kotlin/app/revanced/patches/shared/misc/gms/{AbstractGmsCoreSupportResourcePatch.kt => BaseGmsCoreSupportResourcePatch.kt} (96%) rename src/main/kotlin/app/revanced/patches/shared/{integrations/AbstractIntegrationsPatch.kt => misc/integrations/BaseIntegrationsPatch.kt} (84%) rename src/main/kotlin/app/revanced/patches/shared/{mapping/misc => misc/mapping}/ResourceMappingPatch.kt (98%) rename src/main/kotlin/app/revanced/patches/shared/{settings/AbstractSettingsResourcePatch.kt => misc/settings/BaseSettingsResourcePatch.kt} (51%) create mode 100644 src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreference.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt rename src/main/kotlin/app/revanced/patches/shared/{settings/preference/impl => misc/settings/preference}/InputType.kt (73%) create mode 100644 src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/ListPreference.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/NonInteractivePreference.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceCategory.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceScreen.kt rename src/main/kotlin/app/revanced/patches/shared/{ => misc}/settings/preference/SummaryType.kt (63%) create mode 100644 src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SwitchPreference.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/TextPreference.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/preference/BasePreference.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/preference/ComponentsExtensions.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/IntentPreference.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ListPreference.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceCategory.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceScreen.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/SwitchPreference.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/TextPreference.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/util/AbstractPreferenceScreen.kt rename src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/{AbstractAdPatch.kt => BaseAdPatch.kt} (98%) rename src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/{BaseHookPatchPatch.kt => BaseHookPatch.kt} (78%) rename src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/ads/{HideAdsPatch.kt => HideAdsHookPatch.kt} (80%) rename src/main/kotlin/app/revanced/patches/{shared/settings/preference/DefaultBasePreference.kt => youtube/layout/hide/personalinformation/HideEmailAddressPatch.kt} (100%) create mode 100644 src/main/resources/addresources/values/arrays.xml create mode 100644 src/main/resources/addresources/values/strings.xml delete mode 100644 src/main/resources/alternativethumbnails/host/values/strings.xml delete mode 100644 src/main/resources/copyvideourl/host/values/strings.xml delete mode 100644 src/main/resources/downloads/host/values/strings.xml delete mode 100644 src/main/resources/gms/host/values/strings.xml delete mode 100644 src/main/resources/returnyoutubedislike/host/values/strings.xml delete mode 100644 src/main/resources/settings/host/values/strings.xml rename src/main/resources/sponsorblock/drawable/{ic_sb_adjust.xml => revanced_sb_adjust.xml} (100%) rename src/main/resources/sponsorblock/drawable/{ic_sb_compare.xml => revanced_sb_compare.xml} (100%) rename src/main/resources/sponsorblock/drawable/{ic_sb_edit.xml => revanced_sb_edit.xml} (100%) rename src/main/resources/sponsorblock/drawable/{ic_sb_logo.xml => revanced_sb_logo.xml} (100%) rename src/main/resources/sponsorblock/drawable/{ic_sb_publish.xml => revanced_sb_publish.xml} (100%) rename src/main/resources/sponsorblock/drawable/{ic_sb_voting.xml => revanced_sb_voting.xml} (100%) delete mode 100644 src/main/resources/sponsorblock/host/values/strings.xml rename src/main/resources/sponsorblock/layout/{inline_sponsor_overlay.xml => revanced_sb_inline_sponsor_overlay.xml} (79%) rename src/main/resources/sponsorblock/layout/{new_segment.xml => revanced_sb_new_segment.xml} (84%) rename src/main/resources/sponsorblock/layout/{skip_sponsor_button.xml => revanced_sb_skip_sponsor_button.xml} (82%) rename src/main/resources/swipecontrols/drawable/{ic_sc_brightness_auto.xml => revanced_ic_sc_brightness_auto.xml} (100%) rename src/main/resources/swipecontrols/drawable/{ic_sc_brightness_manual.xml => revanced_ic_sc_brightness_manual.xml} (100%) rename src/main/resources/swipecontrols/drawable/{ic_sc_volume_mute.xml => revanced_ic_sc_volume_mute.xml} (100%) rename src/main/resources/swipecontrols/drawable/{ic_sc_volume_normal.xml => revanced_ic_sc_volume_normal.xml} (100%) diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 29a4bb942f..1555a14978 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -4,7 +4,7 @@ public final class app/revanced/patches/all/activity/exportall/ExportAllActiviti public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V } -public final class app/revanced/patches/all/connectivity/wifi/spoof/SpoofWifiPatch : app/revanced/patches/all/misc/transformation/AbstractTransformInstructionsPatch { +public final class app/revanced/patches/all/connectivity/wifi/spoof/SpoofWifiPatch : app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch { public static final field INSTANCE Lapp/revanced/patches/all/connectivity/wifi/spoof/SpoofWifiPatch; public synthetic fun filterMap (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Ljava/lang/Object; public fun filterMap (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Lkotlin/Triple; @@ -38,33 +38,44 @@ public final class app/revanced/patches/all/misc/packagename/ChangePackageNamePa public final fun setOrGetFallbackPackageName (Ljava/lang/String;)Ljava/lang/String; } -public final class app/revanced/patches/all/misc/resources/AddResourcesPatch : app/revanced/patcher/patch/ResourcePatch, java/io/Closeable, java/util/Set, kotlin/jvm/internal/markers/KMutableSet { +public final class app/revanced/patches/all/misc/resources/AddResourcesPatch : app/revanced/patcher/patch/ResourcePatch, java/io/Closeable, java/util/Map, kotlin/jvm/internal/markers/KMutableMap { public static final field INSTANCE Lapp/revanced/patches/all/misc/resources/AddResourcesPatch; - public fun add (Lapp/revanced/util/resource/BaseResource;)Z - public synthetic fun add (Ljava/lang/Object;)Z - public fun addAll (Ljava/util/Collection;)Z - public final fun addString (Ljava/lang/String;Ljava/lang/String;Z)Z - public static synthetic fun addString$default (Lapp/revanced/patches/all/misc/resources/AddResourcesPatch;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z public fun clear ()V public fun close ()V - public fun contains (Lapp/revanced/util/resource/BaseResource;)Z - public final fun contains (Ljava/lang/Object;)Z - public fun containsAll (Ljava/util/Collection;)Z + public final fun containsKey (Ljava/lang/Object;)Z + public fun containsKey (Ljava/lang/String;)Z + public final fun containsValue (Ljava/lang/Object;)Z + public fun containsValue (Ljava/util/Set;)Z + public final fun entrySet ()Ljava/util/Set; public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V + public final synthetic fun get (Ljava/lang/Object;)Ljava/lang/Object; + public final fun get (Ljava/lang/Object;)Ljava/util/Set; + public fun get (Ljava/lang/String;)Ljava/util/Set; + public fun getEntries ()Ljava/util/Set; + public fun getKeys ()Ljava/util/Set; public fun getSize ()I + public fun getValues ()Ljava/util/Collection; + public final fun invoke (Ljava/lang/String;Lapp/revanced/util/resource/BaseResource;)Z + public final fun invoke (Ljava/lang/String;Ljava/lang/Iterable;)Z + public final fun invoke (Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;)Z + public final fun invoke (Ljava/lang/String;Ljava/util/List;)Z + public final fun invoke (Lkotlin/reflect/KClass;Lkotlin/jvm/functions/Function1;)Z + public static synthetic fun invoke$default (Lapp/revanced/patches/all/misc/resources/AddResourcesPatch;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;ILjava/lang/Object;)Z + public static synthetic fun invoke$default (Lapp/revanced/patches/all/misc/resources/AddResourcesPatch;Lkotlin/reflect/KClass;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Z public fun isEmpty ()Z - public fun iterator ()Ljava/util/Iterator; - public fun remove (Lapp/revanced/util/resource/BaseResource;)Z - public final fun remove (Ljava/lang/Object;)Z - public fun removeAll (Ljava/util/Collection;)Z - public fun retainAll (Ljava/util/Collection;)Z + public final fun keySet ()Ljava/util/Set; + public synthetic fun put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun put (Ljava/lang/String;Ljava/util/Set;)Ljava/util/Set; + public fun putAll (Ljava/util/Map;)V + public final synthetic fun remove (Ljava/lang/Object;)Ljava/lang/Object; + public final fun remove (Ljava/lang/Object;)Ljava/util/Set; + public fun remove (Ljava/lang/String;)Ljava/util/Set; public final fun size ()I - public fun toArray ()[Ljava/lang/Object; - public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object; + public final fun values ()Ljava/util/Collection; } -public abstract class app/revanced/patches/all/misc/transformation/AbstractTransformInstructionsPatch : app/revanced/patcher/patch/BytecodePatch { +public abstract class app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch : app/revanced/patcher/patch/BytecodePatch { public fun ()V public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V @@ -85,7 +96,7 @@ public final class app/revanced/patches/all/misc/transformation/IMethodCall$Defa public static fun replaceInvokeVirtualWithIntegrations (Lapp/revanced/patches/all/misc/transformation/IMethodCall;Ljava/lang/String;Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Lcom/android/tools/smali/dexlib2/iface/instruction/formats/Instruction35c;I)V } -public final class app/revanced/patches/all/screencapture/removerestriction/RemoveCaptureRestrictionPatch : app/revanced/patches/all/misc/transformation/AbstractTransformInstructionsPatch { +public final class app/revanced/patches/all/screencapture/removerestriction/RemoveCaptureRestrictionPatch : app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch { public static final field INSTANCE Lapp/revanced/patches/all/screencapture/removerestriction/RemoveCaptureRestrictionPatch; public synthetic fun filterMap (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Ljava/lang/Object; public fun filterMap (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Lkotlin/Triple; @@ -106,7 +117,7 @@ public final class app/revanced/patches/all/screencapture/removerestriction/Remo public static fun values ()[Lapp/revanced/patches/all/screencapture/removerestriction/RemoveCaptureRestrictionPatch$MethodCall; } -public final class app/revanced/patches/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch : app/revanced/patches/all/misc/transformation/AbstractTransformInstructionsPatch { +public final class app/revanced/patches/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch : app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch { public static final field INSTANCE Lapp/revanced/patches/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V @@ -129,7 +140,7 @@ public final class app/revanced/patches/all/screenshot/removerestriction/RemoveS public static fun values ()[Lapp/revanced/patches/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch$MethodCall; } -public final class app/revanced/patches/all/telephony/sim/spoof/SpoofSimCountryPatch : app/revanced/patches/all/misc/transformation/AbstractTransformInstructionsPatch { +public final class app/revanced/patches/all/telephony/sim/spoof/SpoofSimCountryPatch : app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch { public static final field INSTANCE Lapp/revanced/patches/all/telephony/sim/spoof/SpoofSimCountryPatch; public synthetic fun filterMap (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Ljava/lang/Object; public fun filterMap (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Lkotlin/Pair; @@ -339,15 +350,15 @@ public final class app/revanced/patches/music/misc/gms/Constants { public static final field INSTANCE Lapp/revanced/patches/music/misc/gms/Constants; } -public final class app/revanced/patches/music/misc/gms/GmsCoreSupportPatch : app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportPatch { +public final class app/revanced/patches/music/misc/gms/GmsCoreSupportPatch : app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch { public static final field INSTANCE Lapp/revanced/patches/music/misc/gms/GmsCoreSupportPatch; } -public final class app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch : app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch { +public final class app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch : app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch { public static final field INSTANCE Lapp/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch; } -public final class app/revanced/patches/music/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/integrations/AbstractIntegrationsPatch { +public final class app/revanced/patches/music/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch { public static final field INSTANCE Lapp/revanced/patches/music/misc/integrations/IntegrationsPatch; } @@ -437,7 +448,7 @@ public final class app/revanced/patches/reddit/ad/general/HideAdsPatch : app/rev public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public abstract class app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch : app/revanced/patcher/patch/BytecodePatch { +public abstract class app/revanced/patches/reddit/customclients/BaseSpoofClientPatch : app/revanced/patcher/patch/BytecodePatch { public fun (Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;)V public synthetic fun (Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V @@ -454,17 +465,17 @@ public final class app/revanced/patches/reddit/customclients/Constants { public static final field OAUTH_USER_AGENT Ljava/lang/String; } -public final class app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch { +public final class app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } -public final class app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch { +public final class app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } -public final class app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch { +public final class app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } @@ -481,7 +492,7 @@ public final class app/revanced/patches/reddit/customclients/joeyforreddit/ads/D public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch { +public final class app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } @@ -492,19 +503,19 @@ public final class app/revanced/patches/reddit/customclients/joeyforreddit/detec public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch { +public final class app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V public fun patchUserAgent (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } -public final class app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch { +public final class app/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/relayforreddit/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V public fun patchMiscellaneous (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } -public final class app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch { +public final class app/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/slide/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } @@ -521,7 +532,7 @@ public final class app/revanced/patches/reddit/customclients/syncforreddit/annoy public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/reddit/customclients/syncforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch { +public final class app/revanced/patches/reddit/customclients/syncforreddit/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/syncforreddit/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V public fun patchMiscellaneous (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V @@ -563,41 +574,62 @@ public final class app/revanced/patches/serviceportalbund/detection/root/RootDet public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public abstract class app/revanced/patches/shared/integrations/AbstractIntegrationsPatch : app/revanced/patcher/patch/BytecodePatch { +public final class app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + +public abstract class app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch : app/revanced/patcher/patch/BytecodePatch { + public fun (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Ljava/util/Set;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Lkotlin/reflect/KClass;Lapp/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Ljava/util/Set;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Lkotlin/reflect/KClass;Lapp/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + +public abstract class app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch : app/revanced/patcher/patch/ResourcePatch { + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V + public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V + protected final fun getGmsCoreVendor ()Ljava/lang/String; +} + +public abstract class app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch : app/revanced/patcher/patch/BytecodePatch { public fun (Ljava/lang/String;Ljava/util/Set;)V public fun (Ljava/util/Set;)V public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public abstract class app/revanced/patches/shared/integrations/AbstractIntegrationsPatch$IntegrationsFingerprint : app/revanced/patcher/fingerprint/MethodFingerprint { +public abstract class app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch$IntegrationsFingerprint : app/revanced/patcher/fingerprint/MethodFingerprint { public fun ()V public fun (Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)V public synthetic fun (Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun invoke (Ljava/lang/String;)V } -public abstract interface class app/revanced/patches/shared/integrations/AbstractIntegrationsPatch$IntegrationsFingerprint$RegisterResolver : kotlin/jvm/functions/Function1 { +public abstract interface class app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch$IntegrationsFingerprint$IRegisterResolver : kotlin/jvm/functions/Function1 { public abstract fun invoke (Lcom/android/tools/smali/dexlib2/iface/Method;)Ljava/lang/Integer; } -public final class app/revanced/patches/shared/integrations/AbstractIntegrationsPatch$IntegrationsFingerprint$RegisterResolver$DefaultImpls { - public static fun invoke (Lapp/revanced/patches/shared/integrations/AbstractIntegrationsPatch$IntegrationsFingerprint$RegisterResolver;Lcom/android/tools/smali/dexlib2/iface/Method;)Ljava/lang/Integer; +public final class app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch$IntegrationsFingerprint$IRegisterResolver$DefaultImpls { + public static fun invoke (Lapp/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch$IntegrationsFingerprint$IRegisterResolver;Lcom/android/tools/smali/dexlib2/iface/Method;)Ljava/lang/Integer; } -public final class app/revanced/patches/shared/mapping/misc/ResourceMappingPatch : app/revanced/patcher/patch/ResourcePatch { - public static final field INSTANCE Lapp/revanced/patches/shared/mapping/misc/ResourceMappingPatch; +public final class app/revanced/patches/shared/misc/mapping/ResourceMappingPatch : app/revanced/patcher/patch/ResourcePatch { + public static final field INSTANCE Lapp/revanced/patches/shared/misc/mapping/ResourceMappingPatch; public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V } -public final class app/revanced/patches/shared/mapping/misc/ResourceMappingPatch$ResourceElement { +public final class app/revanced/patches/shared/misc/mapping/ResourceMappingPatch$ResourceElement { public fun (Ljava/lang/String;Ljava/lang/String;J)V public final fun component1 ()Ljava/lang/String; public final fun component2 ()Ljava/lang/String; public final fun component3 ()J - public final fun copy (Ljava/lang/String;Ljava/lang/String;J)Lapp/revanced/patches/shared/mapping/misc/ResourceMappingPatch$ResourceElement; - public static synthetic fun copy$default (Lapp/revanced/patches/shared/mapping/misc/ResourceMappingPatch$ResourceElement;Ljava/lang/String;Ljava/lang/String;JILjava/lang/Object;)Lapp/revanced/patches/shared/mapping/misc/ResourceMappingPatch$ResourceElement; + public final fun copy (Ljava/lang/String;Ljava/lang/String;J)Lapp/revanced/patches/shared/misc/mapping/ResourceMappingPatch$ResourceElement; + public static synthetic fun copy$default (Lapp/revanced/patches/shared/misc/mapping/ResourceMappingPatch$ResourceElement;Ljava/lang/String;Ljava/lang/String;JILjava/lang/Object;)Lapp/revanced/patches/shared/misc/mapping/ResourceMappingPatch$ResourceElement; public fun equals (Ljava/lang/Object;)Z public final fun getId ()J public final fun getName ()Ljava/lang/String; @@ -606,157 +638,175 @@ public final class app/revanced/patches/shared/mapping/misc/ResourceMappingPatch public fun toString ()Ljava/lang/String; } -public final class app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch : app/revanced/patcher/patch/BytecodePatch { - public static final field INSTANCE Lapp/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch; - public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V - public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V -} - -public abstract class app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportPatch : app/revanced/patcher/patch/BytecodePatch { - public fun (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Ljava/util/Set;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Lkotlin/reflect/KClass;Lapp/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Ljava/util/Set;Lapp/revanced/patcher/fingerprint/MethodFingerprint;Lkotlin/reflect/KClass;Lapp/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V - public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V -} - -public abstract class app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch : app/revanced/patcher/patch/ResourcePatch { - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V - public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V - protected final fun getGmsCoreVendor ()Ljava/lang/String; -} - -public abstract class app/revanced/patches/shared/settings/AbstractSettingsResourcePatch : app/revanced/patcher/patch/ResourcePatch, java/io/Closeable { +public abstract class app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch : app/revanced/patcher/patch/ResourcePatch, java/io/Closeable, java/util/Set, kotlin/jvm/internal/markers/KMutableSet { public fun ()V public fun (Lkotlin/Pair;Ljava/util/Set;)V public synthetic fun (Lkotlin/Pair;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun addPreference (Lapp/revanced/patches/shared/settings/preference/BasePreference;)V + public fun add (Lapp/revanced/patches/shared/misc/settings/preference/BasePreference;)Z + public synthetic fun add (Ljava/lang/Object;)Z + public fun addAll (Ljava/util/Collection;)Z + public fun clear ()V public fun close ()V + public fun contains (Lapp/revanced/patches/shared/misc/settings/preference/BasePreference;)Z + public final fun contains (Ljava/lang/Object;)Z + public fun containsAll (Ljava/util/Collection;)Z public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V + public fun getSize ()I + public fun isEmpty ()Z + public fun iterator ()Ljava/util/Iterator; + public fun remove (Lapp/revanced/patches/shared/misc/settings/preference/BasePreference;)Z + public final fun remove (Ljava/lang/Object;)Z + public fun removeAll (Ljava/util/Collection;)Z + public fun retainAll (Ljava/util/Collection;)Z + public final fun size ()I + public fun toArray ()[Ljava/lang/Object; + public fun toArray ([Ljava/lang/Object;)[Ljava/lang/Object; } -public abstract class app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +public abstract class app/revanced/patches/shared/misc/settings/preference/BasePreference { + public static final field Companion Lapp/revanced/patches/shared/misc/settings/preference/BasePreference$Companion; + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun equals (Ljava/lang/Object;)Z public final fun getKey ()Ljava/lang/String; - public final fun getSummary ()Lapp/revanced/util/resource/StringResource; + public final fun getSummaryKey ()Ljava/lang/String; public final fun getTag ()Ljava/lang/String; - public final fun getTitle ()Lapp/revanced/util/resource/StringResource; + public final fun getTitleKey ()Ljava/lang/String; + public fun hashCode ()I public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } -public final class app/revanced/patches/shared/settings/preference/SummaryType : java/lang/Enum { - public static final field DEFAULT Lapp/revanced/patches/shared/settings/preference/SummaryType; - public static final field OFF Lapp/revanced/patches/shared/settings/preference/SummaryType; - public static final field ON Lapp/revanced/patches/shared/settings/preference/SummaryType; - public static fun getEntries ()Lkotlin/enums/EnumEntries; - public final fun getType ()Ljava/lang/String; - public static fun valueOf (Ljava/lang/String;)Lapp/revanced/patches/shared/settings/preference/SummaryType; - public static fun values ()[Lapp/revanced/patches/shared/settings/preference/SummaryType; +public final class app/revanced/patches/shared/misc/settings/preference/BasePreference$Companion { + public final fun addSummary (Lorg/w3c/dom/Element;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/SummaryType;)V + public static synthetic fun addSummary$default (Lapp/revanced/patches/shared/misc/settings/preference/BasePreference$Companion;Lorg/w3c/dom/Element;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/SummaryType;ILjava/lang/Object;)V +} + +public abstract class app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen : java/io/Closeable { + public fun ()V + public fun (Ljava/util/Set;)V + public synthetic fun (Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun close ()V + public abstract fun commit (Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreen;)V } -public final class app/revanced/patches/shared/settings/preference/impl/InputType : java/lang/Enum { - public static final field NUMBER Lapp/revanced/patches/shared/settings/preference/impl/InputType; - public static final field TEXT Lapp/revanced/patches/shared/settings/preference/impl/InputType; - public static final field TEXT_CAP_CHARACTERS Lapp/revanced/patches/shared/settings/preference/impl/InputType; - public static final field TEXT_MULTI_LINE Lapp/revanced/patches/shared/settings/preference/impl/InputType; +public abstract class app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$BasePreferenceCollection { + public fun ()V + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getKey ()Ljava/lang/String; + public final fun getPreferences ()Ljava/util/Set; + public final fun getTitleKey ()Ljava/lang/String; + public abstract fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreference; +} + +public class app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen : app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$BasePreferenceCollection { + public fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;)V + public synthetic fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;)V + public synthetic fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen;Ljava/lang/String;Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun addPreferences ([Lapp/revanced/patches/shared/misc/settings/preference/BasePreference;)V + public final fun getCategories ()Ljava/util/Set; + public synthetic fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreference; + public fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreen; +} + +public class app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen$Category : app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$BasePreferenceCollection { + public fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;)V + public synthetic fun (Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun addPreferences ([Lapp/revanced/patches/shared/misc/settings/preference/BasePreference;)V + public synthetic fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreference; + public fun transform ()Lapp/revanced/patches/shared/misc/settings/preference/PreferenceCategory; +} + +public final class app/revanced/patches/shared/misc/settings/preference/InputType : java/lang/Enum { + public static final field NUMBER Lapp/revanced/patches/shared/misc/settings/preference/InputType; + public static final field TEXT Lapp/revanced/patches/shared/misc/settings/preference/InputType; + public static final field TEXT_CAP_CHARACTERS Lapp/revanced/patches/shared/misc/settings/preference/InputType; + public static final field TEXT_MULTI_LINE Lapp/revanced/patches/shared/misc/settings/preference/InputType; public static fun getEntries ()Lkotlin/enums/EnumEntries; public final fun getType ()Ljava/lang/String; - public static fun valueOf (Ljava/lang/String;)Lapp/revanced/patches/shared/settings/preference/impl/InputType; - public static fun values ()[Lapp/revanced/patches/shared/settings/preference/impl/InputType; + public static fun valueOf (Ljava/lang/String;)Lapp/revanced/patches/shared/misc/settings/preference/InputType; + public static fun values ()[Lapp/revanced/patches/shared/misc/settings/preference/InputType; } -public final class app/revanced/patches/shared/settings/preference/impl/IntentPreference : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/IntentPreference$Intent;)V - public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/IntentPreference$Intent;)V - public final fun getIntent ()Lapp/revanced/patches/shared/settings/preference/impl/IntentPreference$Intent; +public final class app/revanced/patches/shared/misc/settings/preference/IntentPreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun equals (Ljava/lang/Object;)Z + public final fun getIntent ()Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent; + public fun hashCode ()I public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } -public final class app/revanced/patches/shared/settings/preference/impl/IntentPreference$Intent { +public final class app/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent { public fun (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V + public final fun copy (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;)Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent; + public static synthetic fun copy$default (Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; } -public final class app/revanced/patches/shared/settings/preference/impl/ListPreference : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/StringResource;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/StringResource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +public final class app/revanced/patches/shared/misc/settings/preference/ListPreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { + public fun ()V + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/ArrayResource;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/util/resource/ArrayResource;Lapp/revanced/util/resource/ArrayResource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getEntries ()Lapp/revanced/util/resource/ArrayResource; + public final fun getEntriesKey ()Ljava/lang/String; + public final fun getEntryValues ()Lapp/revanced/util/resource/ArrayResource; + public final fun getEntryValuesKey ()Ljava/lang/String; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } -public final class app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;Z)V - public synthetic fun (Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V +public final class app/revanced/patches/shared/misc/settings/preference/NonInteractivePreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getSelectable ()Z public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } -public class app/revanced/patches/shared/settings/preference/impl/PreferenceCategory : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Ljava/util/List;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Ljava/util/List;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getPreferences ()Ljava/util/List; +public class app/revanced/patches/shared/misc/settings/preference/PreferenceCategory : app/revanced/patches/shared/misc/settings/preference/BasePreference { + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getPreferences ()Ljava/util/Set; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; - public final fun setPreferences (Ljava/util/List;)V } -public class app/revanced/patches/shared/settings/preference/impl/PreferenceScreen : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Ljava/util/List;Lapp/revanced/util/resource/StringResource;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Ljava/util/List;Lapp/revanced/util/resource/StringResource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getPreferences ()Ljava/util/List; +public class app/revanced/patches/shared/misc/settings/preference/PreferenceScreen : app/revanced/patches/shared/misc/settings/preference/BasePreference { + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getPreferences ()Ljava/util/Set; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; - public final fun setPreferences (Ljava/util/List;)V } -public final class app/revanced/patches/shared/settings/preference/impl/SwitchPreference : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getSummaryOff ()Lapp/revanced/util/resource/StringResource; - public final fun getSummaryOn ()Lapp/revanced/util/resource/StringResource; - public final fun getUserDialogMessage ()Lapp/revanced/util/resource/StringResource; - public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; +public final class app/revanced/patches/shared/misc/settings/preference/SummaryType : java/lang/Enum { + public static final field DEFAULT Lapp/revanced/patches/shared/misc/settings/preference/SummaryType; + public static final field OFF Lapp/revanced/patches/shared/misc/settings/preference/SummaryType; + public static final field ON Lapp/revanced/patches/shared/misc/settings/preference/SummaryType; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public final fun getType ()Ljava/lang/String; + public static fun valueOf (Ljava/lang/String;)Lapp/revanced/patches/shared/misc/settings/preference/SummaryType; + public static fun values ()[Lapp/revanced/patches/shared/misc/settings/preference/SummaryType; } -public final class app/revanced/patches/shared/settings/preference/impl/TextPreference : app/revanced/patches/shared/settings/preference/BasePreference { - public fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/InputType;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Lapp/revanced/util/resource/StringResource;Lapp/revanced/util/resource/StringResource;Lapp/revanced/patches/shared/settings/preference/impl/InputType;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getInputType ()Lapp/revanced/patches/shared/settings/preference/impl/InputType; +public final class app/revanced/patches/shared/misc/settings/preference/SwitchPreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { + public fun ()V + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getSummaryOffKey ()Ljava/lang/String; + public final fun getSummaryOnKey ()Ljava/lang/String; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } -public abstract class app/revanced/patches/shared/settings/util/AbstractPreferenceScreen : java/io/Closeable { +public final class app/revanced/patches/shared/misc/settings/preference/TextPreference : app/revanced/patches/shared/misc/settings/preference/BasePreference { public fun ()V - public fun (Ljava/util/List;)V - public synthetic fun (Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun close ()V - public abstract fun commit (Lapp/revanced/patches/shared/settings/preference/impl/PreferenceScreen;)V -} - -public abstract class app/revanced/patches/shared/settings/util/AbstractPreferenceScreen$BasePreferenceCollection { - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getKey ()Ljava/lang/String; - public final fun getPreferences ()Ljava/util/List; - public final fun getTitle ()Ljava/lang/String; - public abstract fun transform ()Lapp/revanced/patches/shared/settings/preference/BasePreference; -} - -public class app/revanced/patches/shared/settings/util/AbstractPreferenceScreen$Screen : app/revanced/patches/shared/settings/util/AbstractPreferenceScreen$BasePreferenceCollection { - public fun (Lapp/revanced/patches/shared/settings/util/AbstractPreferenceScreen;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/util/List;)V - public synthetic fun (Lapp/revanced/patches/shared/settings/util/AbstractPreferenceScreen;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun addPreferences ([Lapp/revanced/patches/shared/settings/preference/BasePreference;)V - public final fun getCategories ()Ljava/util/List; - public final fun getSummary ()Ljava/lang/String; - public synthetic fun transform ()Lapp/revanced/patches/shared/settings/preference/BasePreference; - public fun transform ()Lapp/revanced/patches/shared/settings/preference/impl/PreferenceScreen; -} - -public class app/revanced/patches/shared/settings/util/AbstractPreferenceScreen$Screen$Category : app/revanced/patches/shared/settings/util/AbstractPreferenceScreen$BasePreferenceCollection { - public fun (Lapp/revanced/patches/shared/settings/util/AbstractPreferenceScreen$Screen;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V - public synthetic fun (Lapp/revanced/patches/shared/settings/util/AbstractPreferenceScreen$Screen;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun addPreferences ([Lapp/revanced/patches/shared/settings/preference/BasePreference;)V - public synthetic fun transform ()Lapp/revanced/patches/shared/settings/preference/BasePreference; - public fun transform ()Lapp/revanced/patches/shared/settings/preference/impl/PreferenceCategory; + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/InputType;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patches/shared/misc/settings/preference/InputType;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getInputType ()Lapp/revanced/patches/shared/misc/settings/preference/InputType; + public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } public final class app/revanced/patches/solidexplorer2/functionality/filesize/RemoveFileSizeLimitPatch : app/revanced/patcher/patch/BytecodePatch { @@ -850,7 +900,7 @@ public final class app/revanced/patches/tiktok/interaction/speed/PlaybackSpeedPa public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/tiktok/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/integrations/AbstractIntegrationsPatch { +public final class app/revanced/patches/tiktok/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch { public static final field INSTANCE Lapp/revanced/patches/tiktok/misc/integrations/IntegrationsPatch; } @@ -944,25 +994,25 @@ public final class app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch : ap public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public abstract class app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch : app/revanced/patcher/patch/BytecodePatch { +public abstract class app/revanced/patches/twitch/ad/shared/util/BaseAdPatch : app/revanced/patcher/patch/BytecodePatch { public fun (Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;)V public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - protected final fun blockMethods (Lapp/revanced/patcher/data/BytecodeContext;Ljava/lang/String;[Ljava/lang/String;Lapp/revanced/patches/twitch/ad/shared/util/AbstractAdPatch$ReturnMethod;)Z - public static synthetic fun blockMethods$default (Lapp/revanced/patches/twitch/ad/shared/util/AbstractAdPatch;Lapp/revanced/patcher/data/BytecodeContext;Ljava/lang/String;[Ljava/lang/String;Lapp/revanced/patches/twitch/ad/shared/util/AbstractAdPatch$ReturnMethod;ILjava/lang/Object;)Z + protected final fun blockMethods (Lapp/revanced/patcher/data/BytecodeContext;Ljava/lang/String;[Ljava/lang/String;Lapp/revanced/patches/twitch/ad/shared/util/BaseAdPatch$ReturnMethod;)Z + public static synthetic fun blockMethods$default (Lapp/revanced/patches/twitch/ad/shared/util/BaseAdPatch;Lapp/revanced/patcher/data/BytecodeContext;Ljava/lang/String;[Ljava/lang/String;Lapp/revanced/patches/twitch/ad/shared/util/BaseAdPatch$ReturnMethod;ILjava/lang/Object;)Z protected final fun createConditionInstructions (Ljava/lang/String;)Ljava/lang/String; - public static synthetic fun createConditionInstructions$default (Lapp/revanced/patches/twitch/ad/shared/util/AbstractAdPatch;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String; + public static synthetic fun createConditionInstructions$default (Lapp/revanced/patches/twitch/ad/shared/util/BaseAdPatch;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String; public final fun getConditionCall ()Ljava/lang/String; public final fun getSkipLabelName ()Ljava/lang/String; } -protected final class app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch$ReturnMethod { +protected final class app/revanced/patches/twitch/ad/shared/util/BaseAdPatch$ReturnMethod { public fun ()V public fun (CLjava/lang/String;)V public synthetic fun (CLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()C public final fun component2 ()Ljava/lang/String; - public final fun copy (CLjava/lang/String;)Lapp/revanced/patches/twitch/ad/shared/util/AbstractAdPatch$ReturnMethod; - public static synthetic fun copy$default (Lapp/revanced/patches/twitch/ad/shared/util/AbstractAdPatch$ReturnMethod;CLjava/lang/String;ILjava/lang/Object;)Lapp/revanced/patches/twitch/ad/shared/util/AbstractAdPatch$ReturnMethod; + public final fun copy (CLjava/lang/String;)Lapp/revanced/patches/twitch/ad/shared/util/BaseAdPatch$ReturnMethod; + public static synthetic fun copy$default (Lapp/revanced/patches/twitch/ad/shared/util/BaseAdPatch$ReturnMethod;CLjava/lang/String;ILjava/lang/Object;)Lapp/revanced/patches/twitch/ad/shared/util/BaseAdPatch$ReturnMethod; public fun equals (Ljava/lang/Object;)Z public final fun getReturnType ()C public final fun getValue ()Ljava/lang/String; @@ -970,7 +1020,7 @@ protected final class app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch public fun toString ()Ljava/lang/String; } -public final class app/revanced/patches/twitch/ad/video/VideoAdsPatch : app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch { +public final class app/revanced/patches/twitch/ad/video/VideoAdsPatch : app/revanced/patches/twitch/ad/shared/util/BaseAdPatch { public static final field INSTANCE Lapp/revanced/patches/twitch/ad/video/VideoAdsPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V @@ -982,8 +1032,8 @@ public final class app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessag public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointPatch : app/revanced/patcher/patch/BytecodePatch { - public static final field INSTANCE Lapp/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointPatch; +public final class app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } @@ -994,7 +1044,7 @@ public final class app/revanced/patches/twitch/debug/DebugModePatch : app/revanc public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/twitch/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/integrations/AbstractIntegrationsPatch { +public final class app/revanced/patches/twitch/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch { public static final field INSTANCE Lapp/revanced/patches/twitch/misc/integrations/IntegrationsPatch; } @@ -1005,7 +1055,7 @@ public final class app/revanced/patches/twitch/misc/settings/SettingsPatch : app public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/twitch/misc/settings/SettingsResourcePatch : app/revanced/patches/shared/settings/AbstractSettingsResourcePatch { +public final class app/revanced/patches/twitch/misc/settings/SettingsResourcePatch : app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch { public static final field INSTANCE Lapp/revanced/patches/twitch/misc/settings/SettingsResourcePatch; } @@ -1022,17 +1072,17 @@ public final class app/revanced/patches/twitter/misc/hook/json/JsonHookPatch : a public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public abstract class app/revanced/patches/twitter/misc/hook/patch/BaseHookPatchPatch : app/revanced/patcher/patch/BytecodePatch { +public abstract class app/revanced/patches/twitter/misc/hook/patch/BaseHookPatch : app/revanced/patcher/patch/BytecodePatch { public fun (Ljava/lang/String;)V public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/twitter/misc/hook/patch/ads/HideAdsPatch : app/revanced/patches/twitter/misc/hook/patch/BaseHookPatchPatch { - public static final field INSTANCE Lapp/revanced/patches/twitter/misc/hook/patch/ads/HideAdsPatch; +public final class app/revanced/patches/twitter/misc/hook/patch/ads/HideAdsHookPatch : app/revanced/patches/twitter/misc/hook/patch/BaseHookPatch { + public static final field INSTANCE Lapp/revanced/patches/twitter/misc/hook/patch/ads/HideAdsHookPatch; } -public final class app/revanced/patches/twitter/misc/hook/patch/recommendation/HideRecommendedUsersPatch : app/revanced/patches/twitter/misc/hook/patch/BaseHookPatchPatch { +public final class app/revanced/patches/twitter/misc/hook/patch/recommendation/HideRecommendedUsersPatch : app/revanced/patches/twitter/misc/hook/patch/BaseHookPatch { public static final field INSTANCE Lapp/revanced/patches/twitter/misc/hook/patch/recommendation/HideRecommendedUsersPatch; } @@ -1431,17 +1481,17 @@ public final class app/revanced/patches/youtube/misc/fix/playback/SpoofSignature public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V } -public final class app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch : app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportPatch { +public final class app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch : app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch { public static final field INSTANCE Lapp/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch; } -public final class app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch : app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch { +public final class app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch : app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch { public static final field INSTANCE Lapp/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch; public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V } -public final class app/revanced/patches/youtube/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/integrations/AbstractIntegrationsPatch { +public final class app/revanced/patches/youtube/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch { public static final field INSTANCE Lapp/revanced/patches/youtube/misc/integrations/IntegrationsPatch; } @@ -1451,7 +1501,7 @@ public final class app/revanced/patches/youtube/misc/links/BypassURLRedirectsPat public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } -public final class app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch : app/revanced/patches/all/misc/transformation/AbstractTransformInstructionsPatch { +public final class app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch : app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch { public static final field INSTANCE Lapp/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V @@ -1516,20 +1566,20 @@ public final class app/revanced/patches/youtube/misc/settings/SettingsPatch : ap public fun close ()V public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V - public final fun newIntent (Ljava/lang/String;)Lapp/revanced/patches/shared/settings/preference/impl/IntentPreference$Intent; + public final fun newIntent (Ljava/lang/String;)Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent; } -public final class app/revanced/patches/youtube/misc/settings/SettingsPatch$PreferenceScreen : app/revanced/patches/shared/settings/util/AbstractPreferenceScreen { +public final class app/revanced/patches/youtube/misc/settings/SettingsPatch$PreferenceScreen : app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen { public static final field INSTANCE Lapp/revanced/patches/youtube/misc/settings/SettingsPatch$PreferenceScreen; - public fun commit (Lapp/revanced/patches/shared/settings/preference/impl/PreferenceScreen;)V - public final fun getADS ()Lapp/revanced/patches/shared/settings/util/AbstractPreferenceScreen$Screen; - public final fun getINTERACTIONS ()Lapp/revanced/patches/shared/settings/util/AbstractPreferenceScreen$Screen; - public final fun getLAYOUT ()Lapp/revanced/patches/shared/settings/util/AbstractPreferenceScreen$Screen; - public final fun getMISC ()Lapp/revanced/patches/shared/settings/util/AbstractPreferenceScreen$Screen; - public final fun getVIDEO ()Lapp/revanced/patches/shared/settings/util/AbstractPreferenceScreen$Screen; + public fun commit (Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreen;)V + public final fun getADS ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; + public final fun getINTERACTIONS ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; + public final fun getLAYOUT ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; + public final fun getMISC ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; + public final fun getVIDEO ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen; } -public final class app/revanced/patches/youtube/misc/settings/SettingsResourcePatch : app/revanced/patches/shared/settings/AbstractSettingsResourcePatch { +public final class app/revanced/patches/youtube/misc/settings/SettingsResourcePatch : app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch { public static final field INSTANCE Lapp/revanced/patches/youtube/misc/settings/SettingsResourcePatch; public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V @@ -1655,10 +1705,12 @@ public final class app/revanced/util/ResourceGroup { } public final class app/revanced/util/ResourceUtilsKt { + public static final fun asSequence (Lorg/w3c/dom/NodeList;)Lkotlin/sequences/Sequence; + public static final fun childElementsSequence (Lorg/w3c/dom/Node;)Lkotlin/sequences/Sequence; public static final fun copyResources (Lapp/revanced/patcher/data/ResourceContext;Ljava/lang/String;[Lapp/revanced/util/ResourceGroup;)V - public static final fun copyStrings (Lapp/revanced/patcher/data/ResourceContext;Ljava/lang/String;)V public static final fun copyXmlNode (Ljava/lang/String;Lapp/revanced/patcher/util/DomFileEditor;Lapp/revanced/patcher/util/DomFileEditor;)Ljava/lang/AutoCloseable; public static final fun doRecursively (Lorg/w3c/dom/Node;Lkotlin/jvm/functions/Function1;)V + public static final fun forEachChildElement (Lorg/w3c/dom/Node;Lkotlin/jvm/functions/Function1;)V public static final fun iterateXmlNodeChildren (Lapp/revanced/patcher/data/ResourceContext;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V } @@ -1668,11 +1720,16 @@ public abstract class app/revanced/util/patch/LiteralValueFingerprint : app/reva } public final class app/revanced/util/resource/ArrayResource : app/revanced/util/resource/BaseResource { + public static final field Companion Lapp/revanced/util/resource/ArrayResource$Companion; public fun (Ljava/lang/String;Ljava/util/List;)V public final fun getItems ()Ljava/util/List; public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } +public final class app/revanced/util/resource/ArrayResource$Companion { + public final fun fromNode (Lorg/w3c/dom/Node;)Lapp/revanced/util/resource/ArrayResource; +} + public abstract class app/revanced/util/resource/BaseResource { public fun (Ljava/lang/String;Ljava/lang/String;)V public fun equals (Ljava/lang/Object;)Z @@ -1684,6 +1741,7 @@ public abstract class app/revanced/util/resource/BaseResource { } public final class app/revanced/util/resource/StringResource : app/revanced/util/resource/BaseResource { + public static final field Companion Lapp/revanced/util/resource/StringResource$Companion; public fun (Ljava/lang/String;Ljava/lang/String;Z)V public synthetic fun (Ljava/lang/String;Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getFormatted ()Z @@ -1691,3 +1749,7 @@ public final class app/revanced/util/resource/StringResource : app/revanced/util public fun serialize (Lorg/w3c/dom/Document;Lkotlin/jvm/functions/Function1;)Lorg/w3c/dom/Element; } +public final class app/revanced/util/resource/StringResource$Companion { + public final fun fromNode (Lorg/w3c/dom/Node;)Lapp/revanced/util/resource/StringResource; +} + diff --git a/src/main/kotlin/app/revanced/meta/PatchesFileGenerator.kt b/src/main/kotlin/app/revanced/meta/IPatchesFileGenerator.kt similarity index 78% rename from src/main/kotlin/app/revanced/meta/PatchesFileGenerator.kt rename to src/main/kotlin/app/revanced/meta/IPatchesFileGenerator.kt index 2e6703b8ba..49d46e5141 100644 --- a/src/main/kotlin/app/revanced/meta/PatchesFileGenerator.kt +++ b/src/main/kotlin/app/revanced/meta/IPatchesFileGenerator.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.PatchBundleLoader import app.revanced.patcher.PatchSet import java.io.File -internal interface PatchesFileGenerator { +internal interface IPatchesFileGenerator { fun generate(patches: PatchSet) private companion object { @@ -14,7 +14,7 @@ internal interface PatchesFileGenerator { ).also { loader -> if (loader.isEmpty()) throw IllegalStateException("No patches found") }.let { bundle -> - arrayOf(JsonGenerator()).forEach { generator -> generator.generate(bundle) } + arrayOf(JsonPatchesFileGenerator()).forEach { generator -> generator.generate(bundle) } } } } diff --git a/src/main/kotlin/app/revanced/meta/JsonGenerator.kt b/src/main/kotlin/app/revanced/meta/JsonPatchesFileGenerator.kt similarity index 95% rename from src/main/kotlin/app/revanced/meta/JsonGenerator.kt rename to src/main/kotlin/app/revanced/meta/JsonPatchesFileGenerator.kt index 651297e2fd..6755706c68 100644 --- a/src/main/kotlin/app/revanced/meta/JsonGenerator.kt +++ b/src/main/kotlin/app/revanced/meta/JsonPatchesFileGenerator.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.patch.Patch import com.google.gson.GsonBuilder import java.io.File -internal class JsonGenerator : PatchesFileGenerator { +internal class JsonPatchesFileGenerator : IPatchesFileGenerator { override fun generate(patches: PatchSet) = patches.map { JsonPatch( it.name!!, diff --git a/src/main/kotlin/app/revanced/patches/all/connectivity/wifi/spoof/SpoofWifiPatch.kt b/src/main/kotlin/app/revanced/patches/all/connectivity/wifi/spoof/SpoofWifiPatch.kt index 5871749a05..3f79c29e9f 100644 --- a/src/main/kotlin/app/revanced/patches/all/connectivity/wifi/spoof/SpoofWifiPatch.kt +++ b/src/main/kotlin/app/revanced/patches/all/connectivity/wifi/spoof/SpoofWifiPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.all.connectivity.wifi.spoof import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.all.misc.transformation.AbstractTransformInstructionsPatch +import app.revanced.patches.all.misc.transformation.BaseTransformInstructionsPatch import app.revanced.patches.all.misc.transformation.IMethodCall import app.revanced.patches.all.misc.transformation.Instruction35cInfo import app.revanced.patches.all.misc.transformation.filterMapInstruction35c @@ -17,7 +17,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.Instruction requiresIntegrations = true ) @Suppress("unused") -object SpoofWifiPatch : AbstractTransformInstructionsPatch() { +object SpoofWifiPatch : BaseTransformInstructionsPatch() { private const val INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX = "Lapp/revanced/integrations/all/connectivity/wifi/spoof/SpoofWifiPatch" private const val INTEGRATIONS_CLASS_DESCRIPTOR = "$INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX;" diff --git a/src/main/kotlin/app/revanced/patches/all/misc/packagename/ChangePackageNamePatch.kt b/src/main/kotlin/app/revanced/patches/all/misc/packagename/ChangePackageNamePatch.kt index 0471427ab4..ea847c4d70 100644 --- a/src/main/kotlin/app/revanced/patches/all/misc/packagename/ChangePackageNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/all/misc/packagename/ChangePackageNamePatch.kt @@ -41,22 +41,22 @@ object ChangePackageNamePatch : ResourcePatch(), Closeable { * @throws PatchOptionException.ValueValidationException If the package name is invalid. */ fun setOrGetFallbackPackageName(fallbackPackageName: String): String { - val packageName = this.packageNameOption.value!! + val packageName = packageNameOption.value!! - return if (packageName == this.packageNameOption.default) - fallbackPackageName.also { this.packageNameOption.value = it } + return if (packageName == packageNameOption.default) + fallbackPackageName.also { packageNameOption.value = it } else packageName } override fun close() = context.xmlEditor["AndroidManifest.xml"].use { editor -> - val manifest = editor.file.getElementsByTagName("manifest").item(0) as Element - val originalPackageName = manifest.getAttribute("package") - - var replacementPackageName = this.packageNameOption.value - if (replacementPackageName == this.packageNameOption.default) - replacementPackageName = "$originalPackageName.revanced" + val replacementPackageName = packageNameOption.value - manifest.setAttribute("package", replacementPackageName) + val manifest = editor.file.getElementsByTagName("manifest").item(0) as Element + manifest.setAttribute( + "package", + if (replacementPackageName != packageNameOption.default) replacementPackageName + else "${manifest.getAttribute("package")}.revanced" + ) } } diff --git a/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt b/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt index 9ae468db77..bb72c077df 100644 --- a/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt @@ -1,53 +1,277 @@ package app.revanced.patches.all.misc.resources +import app.revanced.patcher.PatchClass import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.addResource -import app.revanced.util.getNode +import app.revanced.patcher.util.DomFileEditor +import app.revanced.patches.all.misc.resources.AddResourcesPatch.resources +import app.revanced.util.* import app.revanced.util.resource.ArrayResource import app.revanced.util.resource.BaseResource import app.revanced.util.resource.StringResource +import org.w3c.dom.Node import java.io.Closeable +import java.util.* -@Patch( - description = "Add resources such as strings or arrays to the app.", -) -object AddResourcesPatch : ResourcePatch(), Closeable, MutableSet by mutableSetOf() { - private lateinit var xmlFileHolder: ResourceContext.XmlFileHolder +/** + * An identifier of an app. For example, `youtube`. + */ +private typealias AppId = String +/** + * An identifier of a patch. For example, `ad.general.HideAdsPatch`. + */ +private typealias PatchId = String +/** + * A set of resources of a patch. + */ +private typealias PatchResources = MutableSet +/** + * A map of resources belonging to a patch. + */ +private typealias AppResources = MutableMap +/** + * A map of resources belonging to an app. + */ +private typealias Resources = MutableMap + +/** + * The value of a resource. + * For example, `values` or `values-de`. + */ +private typealias Value = String + +@Patch(description = "Add resources such as strings or arrays to the app.") +object AddResourcesPatch : ResourcePatch(), MutableMap> by mutableMapOf(), Closeable { + private lateinit var context: ResourceContext + + /** + * A map of all resources associated by their value staged by [execute]. + */ + private lateinit var resources: Map + + /* + The strategy of this patch is to stage resources present in `/resources/addresources`. + These resources are organized by their respective value and patch. + + On AddResourcesPatch#execute, all resources are staged in a temporary map. + After that, other patches that depend on AddResourcesPatch can call + AddResourcesPatch#invoke(PatchClass) to stage resources belonging to that patch + from the temporary map to AddResourcesPatch. + + After all patches that depend on AddResourcesPatch have been executed, + AddResourcesPatch#close is finally called to add all staged resources to the app. + */ override fun execute(context: ResourceContext) { - xmlFileHolder = context.xmlEditor + this.context = context + + resources = buildMap { + /** + * Puts resources under `/resources/addresources//.xml` into the map. + * + * @param value The value of the resource. For example, `values` or `values-de`. + * @param resourceKind The kind of the resource. For example, `strings` or `arrays`. + * @param transform A function that transforms the [Node]s from the XML files to a [BaseResource]. + */ + fun addResources( + value: Value, + resourceKind: String, + transform: (Node) -> BaseResource, + ) { + inputStreamFromBundledResource( + "addresources", + "$value/$resourceKind.xml" + )?.let { stream -> + // Add the resources associated with the given value to the map, + // instead of overwriting it. + // This covers the example case such as adding strings and arrays of the same value. + getOrPut(value, ::mutableMapOf).apply { + context.xmlEditor[stream].use { + it.file.getElementsByTagName("app").asSequence().forEach { app -> + val appId = app.attributes.getNamedItem("id").textContent + + getOrPut(appId, ::mutableMapOf).apply { + app.forEachChildElement { patch -> + val patchId = patch.attributes.getNamedItem("id").textContent + + getOrPut(patchId, ::mutableSetOf).apply { + patch.forEachChildElement { resourceNode -> + val resource = transform(resourceNode) + + add(resource) + } + } + } + } + } + } + } + } + } + + // Stage all resources to a temporary map. + // Staged resources consumed by AddResourcesPatch#invoke(PatchClass) + // are later used in AddResourcesPatch#close. + try { + val addStringResources = { value: Value -> + addResources(value, "strings", StringResource::fromNode) + } + Locale.getISOLanguages().asSequence().map { "values-$it" }.forEach { addStringResources(it) } + addStringResources("values") + + addResources("values", "arrays", ArrayResource::fromNode) + } catch (e: Exception) { + throw PatchException("Failed to read resources", e) + } + } } - fun addString(name: String, value: String, formatted: Boolean = false) = add(StringResource(name, value, formatted)) + /** + * Adds a [BaseResource] to the map using [MutableMap.getOrPut]. + * + * @param value The value of the resource. For example, `values` or `values-de`. + * @param resource The resource to add. + * + * @return True if the resource was added, false if it already existed. + */ + operator fun invoke(value: Value, resource: BaseResource) = + getOrPut(value, ::mutableSetOf).add(resource) - override fun close() { - val strings = xmlFileHolder["res/values/strings.xml"] - val stringResources = strings.getNode("resources") + /** + * Adds a list of [BaseResource]s to the map using [MutableMap.getOrPut]. + * + * @param value The value of the resource. For example, `values` or `values-de`. + * @param resources The resources to add. + * + * @return True if the resources were added, false if they already existed. + */ + operator fun invoke(value: Value, resources: Iterable) = + getOrPut(value, ::mutableSetOf).addAll(resources) - val arrays = xmlFileHolder["res/values/arrays.xml"] - val arraysResources = arrays.getNode("resources") + /** + * Adds a [StringResource]. + * + * @param name The name of the string resource. + * @param value The value of the string resource. + * @param formatted Whether the string resource is formatted. Defaults to `true`. + * @param resourceValue The value of the resource. For example, `values` or `values-de`. + * + * @return True if the resource was added, false if it already existed. + */ + operator fun invoke( + name: String, + value: String, + formatted: Boolean = true, + resourceValue: Value = "values", + ) = invoke(resourceValue, StringResource(name, value, formatted)) - val addedStrings = hashSetOf() + /** + * Adds an [ArrayResource]. + * + * @param name The name of the array resource. + * @param items The items of the array resource. + * + * @return True if the resource was added, false if it already existed. + */ + operator fun invoke( + name: String, + items: List + ) = invoke("values", ArrayResource(name, items)) - fun addResource(resource: BaseResource) { - when (resource) { - is StringResource -> { - // Strings are unique, so don't add them twice. - if (addedStrings.contains(resource.name)) return - addedStrings.add(resource.name) - stringResources.addResource(resource) - } - is ArrayResource -> arraysResources.addResource(resource) { addResource(it) } + /** + * Puts all resources of any [Value] staged in [resources] for the given [PatchClass] to [AddResourcesPatch]. + * + * @param patch The class of the patch to add resources for. + * @param parseIds A function that parses the [AppId] and [PatchId] from the given [PatchClass]. + * This is used to access the resources in [resources] to stage them in [AddResourcesPatch]. + * The default implementation assumes that the [PatchClass] qualified name has the following format: + * `....`. + * + * @return True if any resources were added, false if none were added. + * + * @see AddResourcesPatch.close + */ + operator fun invoke( + patch: PatchClass, + parseIds: PatchClass.() -> Pair = { + val qualifiedName = qualifiedName ?: throw PatchException("Patch qualified name is null") + + // This requires qualifiedName to have the following format: + // `....` + with(qualifiedName.split(".")) { + if (size < 5) throw PatchException("Patch qualified name has invalid format") + + val appId = this[3] + val patchId = subList(4, size).joinToString(".") + + appId to patchId + } + } + ): Boolean { + val (appId, patchId) = patch.parseIds() + + var result = false + + // Stage resources for the given patch to AddResourcesPatch associated with their value. + resources.forEach { (value, resources) -> + resources[appId]?.get(patchId)?.let { patchResources -> + if (invoke(value, patchResources)) result = true + } + } + + return result + } + + /** + * Adds all resources staged in [AddResourcesPatch] to the app. + * This is called after all patches that depend on [AddResourcesPatch] have been executed. + */ + override fun close() { + operator fun MutableMap>.invoke( + value: Value, + resource: BaseResource + ) { + // TODO: Fix open-closed principle violation by modifying BaseResource#serialize so that it accepts + // a Value and the map of editors. It will then get or put the editor suitable for its resource type + // to serialize itself to it. + val resourceFileName = when (resource) { + is StringResource -> "strings" + is ArrayResource -> "arrays" else -> throw NotImplementedError("Unsupported resource type") } + + getOrPut(resourceFileName) { + val targetFile = context["res/$value/$resourceFileName.xml"].also { + it.parentFile?.mkdirs() + it.createNewFile() + } + + context.xmlEditor[targetFile.path].let { editor -> + // Save the target node here as well + // in order to avoid having to call editor.getNode("resources") + // every time addUsingEditors is called but also save the editor so that it can be closed later. + editor to editor.getNode("resources") + } + }.let { (_, targetNode) -> + targetNode.addResource(resource) { invoke(value, it) } + } } - forEach(::addResource) + forEach { (value, resources) -> + // A map of editors associated by their kind (e.g. strings, arrays). + // Each editor is accompanied by the target node to which resources are added. + // A map is used because Map#getOrPut allows opening a new editor for the duration of a resource value. + // This is done to prevent having to open the files for every resource that is added. + // Instead, it is cached once and reused for resources of the same value. + // This map is later accessed to close all editors for the current resource value. + val resourceFileEditors = mutableMapOf>() - strings.close() - arrays.close() + resources.forEach { resource -> resourceFileEditors(value, resource) } + + resourceFileEditors.values.forEach { (editor, _) -> editor.close() } + } } } diff --git a/src/main/kotlin/app/revanced/patches/all/misc/transformation/AbstractTransformInstructionsPatch.kt b/src/main/kotlin/app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/all/misc/transformation/AbstractTransformInstructionsPatch.kt rename to src/main/kotlin/app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch.kt index a4c447e9dc..68e8a68bac 100644 --- a/src/main/kotlin/app/revanced/patches/all/misc/transformation/AbstractTransformInstructionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/all/misc/transformation/BaseTransformInstructionsPatch.kt @@ -9,7 +9,7 @@ import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.instruction.Instruction @Suppress("MemberVisibilityCanBePrivate") -abstract class AbstractTransformInstructionsPatch : BytecodePatch() { +abstract class BaseTransformInstructionsPatch : BytecodePatch() { abstract fun filterMap( classDef: ClassDef, method: Method, diff --git a/src/main/kotlin/app/revanced/patches/all/screencapture/removerestriction/RemoveCaptureRestrictionPatch.kt b/src/main/kotlin/app/revanced/patches/all/screencapture/removerestriction/RemoveCaptureRestrictionPatch.kt index 3bc821665d..b3afc3d6eb 100644 --- a/src/main/kotlin/app/revanced/patches/all/screencapture/removerestriction/RemoveCaptureRestrictionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/all/screencapture/removerestriction/RemoveCaptureRestrictionPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.all.screencapture.removerestriction import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.all.misc.transformation.AbstractTransformInstructionsPatch +import app.revanced.patches.all.misc.transformation.BaseTransformInstructionsPatch import app.revanced.patches.all.misc.transformation.IMethodCall import app.revanced.patches.all.misc.transformation.Instruction35cInfo import app.revanced.patches.all.misc.transformation.filterMapInstruction35c @@ -18,7 +18,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.Instruction requiresIntegrations = true ) @Suppress("unused") -object RemoveCaptureRestrictionPatch : AbstractTransformInstructionsPatch() { +object RemoveCaptureRestrictionPatch : BaseTransformInstructionsPatch() { private const val INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX = "Lapp/revanced/integrations/all/screencapture/removerestriction/RemoveScreencaptureRestrictionPatch" private const val INTEGRATIONS_CLASS_DESCRIPTOR = "$INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX;" diff --git a/src/main/kotlin/app/revanced/patches/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.kt b/src/main/kotlin/app/revanced/patches/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.kt index 12006f6548..0667ed0f57 100644 --- a/src/main/kotlin/app/revanced/patches/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.all.misc.transformation.AbstractTransformInstructionsPatch +import app.revanced.patches.all.misc.transformation.BaseTransformInstructionsPatch import app.revanced.patches.all.misc.transformation.IMethodCall import app.revanced.patches.all.misc.transformation.Instruction35cInfo import app.revanced.patches.all.misc.transformation.filterMapInstruction35c @@ -22,7 +22,7 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference requiresIntegrations = true, ) @Suppress("unused") -object RemoveScreenshotRestrictionPatch : AbstractTransformInstructionsPatch() { +object RemoveScreenshotRestrictionPatch : BaseTransformInstructionsPatch() { private const val INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX = "Lapp/revanced/integrations/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch" private const val INTEGRATIONS_CLASS_DESCRIPTOR = "$INTEGRATIONS_CLASS_DESCRIPTOR_PREFIX;" @@ -71,7 +71,7 @@ object RemoveScreenshotRestrictionPatch : AbstractTransformInstructionsPatch>() { +private class ModifyLayoutParamsFlags : BaseTransformInstructionsPatch>() { override fun filterMap( classDef: ClassDef, method: Method, diff --git a/src/main/kotlin/app/revanced/patches/all/telephony/sim/spoof/SpoofSimCountryPatch.kt b/src/main/kotlin/app/revanced/patches/all/telephony/sim/spoof/SpoofSimCountryPatch.kt index 068861b022..63afac86f2 100644 --- a/src/main/kotlin/app/revanced/patches/all/telephony/sim/spoof/SpoofSimCountryPatch.kt +++ b/src/main/kotlin/app/revanced/patches/all/telephony/sim/spoof/SpoofSimCountryPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.all.misc.transformation.AbstractTransformInstructionsPatch +import app.revanced.patches.all.misc.transformation.BaseTransformInstructionsPatch import com.android.tools.smali.dexlib2.iface.ClassDef import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.instruction.Instruction @@ -23,7 +23,7 @@ import java.util.* use = false, ) @Suppress("unused") -object SpoofSimCountryPatch : AbstractTransformInstructionsPatch>() { +object SpoofSimCountryPatch : BaseTransformInstructionsPatch>() { private val countries = Locale.getISOCountries().associateBy { Locale("", it).displayCountry } private val networkCountryIso by isoCountryPatchOption( diff --git a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt index eac82bc36f..5bb8e2a454 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt @@ -6,11 +6,11 @@ import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVe import app.revanced.patches.music.misc.gms.fingerprints.* import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint import app.revanced.patches.music.misc.integrations.IntegrationsPatch -import app.revanced.patches.shared.misc.gms.AbstractGmsCoreSupportPatch +import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint @Suppress("unused") -object GmsCoreSupportPatch : AbstractGmsCoreSupportPatch( +object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( fromPackageName = MUSIC_PACKAGE_NAME, toPackageName = REVANCED_MUSIC_PACKAGE_NAME, primeMethodFingerprint = PrimeMethodFingerprint, @@ -23,7 +23,7 @@ object GmsCoreSupportPatch : AbstractGmsCoreSupportPatch( ), mainActivityOnCreateFingerprint = ApplicationInitFingerprint, integrationsPatchDependency = IntegrationsPatch::class, - abstractGmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, + gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, compatiblePackages = setOf(CompatiblePackage("com.google.android.apps.youtube.music")), fingerprints = setOf( ServiceCheckFingerprint, diff --git a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch.kt index e37b478411..5daa421cab 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportResourcePatch.kt @@ -2,9 +2,9 @@ package app.revanced.patches.music.misc.gms import app.revanced.patches.music.misc.gms.Constants.MUSIC_PACKAGE_NAME import app.revanced.patches.music.misc.gms.Constants.REVANCED_MUSIC_PACKAGE_NAME -import app.revanced.patches.shared.misc.gms.AbstractGmsCoreSupportResourcePatch +import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportResourcePatch -object GmsCoreSupportResourcePatch : AbstractGmsCoreSupportResourcePatch( +object GmsCoreSupportResourcePatch : BaseGmsCoreSupportResourcePatch( fromPackageName = MUSIC_PACKAGE_NAME, toPackageName = REVANCED_MUSIC_PACKAGE_NAME, spoofedPackageSignature = "afb0fed5eeaebdd86f56a97742f4b6b33ef59875" diff --git a/src/main/kotlin/app/revanced/patches/music/misc/integrations/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/integrations/IntegrationsPatch.kt index 074f555b13..06f45d7e97 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/integrations/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/integrations/IntegrationsPatch.kt @@ -2,10 +2,10 @@ package app.revanced.patches.music.misc.integrations import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch @Patch(requiresIntegrations = true) -object IntegrationsPatch : AbstractIntegrationsPatch( +object IntegrationsPatch : BaseIntegrationsPatch( "Lapp/revanced/integrations/utils/ReVancedUtils;", setOf( ApplicationInitFingerprint, diff --git a/src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/ApplicationInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/ApplicationInitFingerprint.kt index 665cc8e330..d825b4e8d3 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/ApplicationInitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/integrations/fingerprints/ApplicationInitFingerprint.kt @@ -1,6 +1,6 @@ package app.revanced.patches.music.misc.integrations.fingerprints -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.Opcode internal object ApplicationInitFingerprint : IntegrationsFingerprint( diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/BaseSpoofClientPatch.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt rename to src/main/kotlin/app/revanced/patches/reddit/customclients/BaseSpoofClientPatch.kt index 228703d337..0a7c3e752e 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/BaseSpoofClientPatch.kt @@ -1,14 +1,14 @@ package app.revanced.patches.reddit.customclients -import app.revanced.util.exception import app.revanced.patcher.PatchClass import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption +import app.revanced.util.exception -abstract class AbstractSpoofClientPatch( +abstract class BaseSpoofClientPatch( redirectUri: String, private val miscellaneousFingerprints: Set = emptySet(), private val clientIdFingerprints: Set = emptySet(), diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt index 0d7b8c918a..befc582bc7 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch.kt @@ -4,14 +4,14 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.MethodFingerprintResult -import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch +import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.GetAuthorizationUrlFingerprint import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.RequestTokenFingerprint import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Suppress("unused") -object SpoofClientPatch : AbstractSpoofClientPatch( +object SpoofClientPatch : BaseSpoofClientPatch( redirectUri = "http://baconreader.com/auth", clientIdFingerprints = setOf(GetAuthorizationUrlFingerprint, RequestTokenFingerprint), compatiblePackages = setOf( diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt index 8b48c0f437..e7a76441ff 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.reddit.customclients.boostforreddit.api import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.MethodFingerprintResult -import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch +import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.LoginActivityOnCreateFingerprint @Suppress("unused") -object SpoofClientPatch : AbstractSpoofClientPatch( +object SpoofClientPatch : BaseSpoofClientPatch( redirectUri = "http://rubenmayayo.com", clientIdFingerprints = setOf(GetClientIdFingerprint), userAgentFingerprints = setOf(LoginActivityOnCreateFingerprint), diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt index 59cc195a9d..0565bfefa7 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt @@ -5,14 +5,14 @@ import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.util.smali.toInstructions -import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch +import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.APIUtilsFingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethodImplementation @Suppress("unused") -object SpoofClientPatch : AbstractSpoofClientPatch( +object SpoofClientPatch : BaseSpoofClientPatch( redirectUri = "infinity://localhost", clientIdFingerprints = setOf(APIUtilsFingerprint), compatiblePackages = setOf(CompatiblePackage("ml.docilealligator.infinityforreddit")) diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt index 3dd1b7e9a3..7826956909 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt @@ -3,13 +3,13 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.api import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.MethodFingerprintResult -import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch +import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch import app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints.GetClientIdFingerprint import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.DisablePiracyDetectionPatch @Suppress("unused") -object SpoofClientPatch : AbstractSpoofClientPatch( +object SpoofClientPatch : BaseSpoofClientPatch( redirectUri = "https://127.0.0.1:65023/authorize_callback", clientIdFingerprints = setOf(GetClientIdFingerprint), compatiblePackages = setOf( diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt index 251efcf97c..ab110821ec 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patcher.fingerprint.MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult.StringMatch -import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch +import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BasicAuthorizationFingerprint import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BuildAuthorizationStringFingerprint import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.GetUserAgentFingerprint @@ -14,7 +14,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Suppress("unused") -object SpoofClientPatch : AbstractSpoofClientPatch( +object SpoofClientPatch : BaseSpoofClientPatch( redirectUri = "redditisfun://auth", clientIdFingerprints = setOf(BuildAuthorizationStringFingerprint, BasicAuthorizationFingerprint), userAgentFingerprints = setOf(GetUserAgentFingerprint), diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/AbstractClientIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/BaseClientIdFingerprint.kt similarity index 68% rename from src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/AbstractClientIdFingerprint.kt rename to src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/BaseClientIdFingerprint.kt index 761987ba2d..108b4f97d0 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/AbstractClientIdFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/BaseClientIdFingerprint.kt @@ -2,6 +2,6 @@ package app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint -internal abstract class AbstractClientIdFingerprint(string: String) : MethodFingerprint( +internal abstract class BaseClientIdFingerprint(string: String) : MethodFingerprint( strings = listOfNotNull("yyOCBp.RHJhDKd", string), ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/BasicAuthorizationFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/BasicAuthorizationFingerprint.kt index d524097fe2..30aacd6fd1 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/BasicAuthorizationFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/BasicAuthorizationFingerprint.kt @@ -1,5 +1,5 @@ package app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints -internal object BasicAuthorizationFingerprint : AbstractClientIdFingerprint( +internal object BasicAuthorizationFingerprint : BaseClientIdFingerprint( string = "fJOxVwBUyo*=f:, private val mainActivityOnCreateFingerprint: MethodFingerprint, private val integrationsPatchDependency: PatchClass, - abstractGmsCoreSupportResourcePatch: AbstractGmsCoreSupportResourcePatch, + gmsCoreSupportResourcePatch: BaseGmsCoreSupportResourcePatch, dependencies: Set = setOf(), compatiblePackages: Set? = null, fingerprints: Set = emptySet(), @@ -56,7 +56,7 @@ abstract class AbstractGmsCoreSupportPatch( "by using GmsCore instead of Google Play Services.", dependencies = setOf( ChangePackageNamePatch::class, - abstractGmsCoreSupportResourcePatch::class, + gmsCoreSupportResourcePatch::class, integrationsPatchDependency ) + dependencies, compatiblePackages = compatiblePackages, @@ -65,7 +65,7 @@ abstract class AbstractGmsCoreSupportPatch( ) { init { // Manually register all options of the resource patch so that they are visible in the patch API. - abstractGmsCoreSupportResourcePatch.options.values.forEach(options::register) + gmsCoreSupportResourcePatch.options.values.forEach(options::register) } internal abstract val gmsCoreVendor: String? diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt index 6e37ebbe90..cfd80488bf 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/gms/AbstractGmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt @@ -6,7 +6,6 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.util.copyStrings import org.w3c.dom.Element import org.w3c.dom.Node @@ -19,7 +18,7 @@ import org.w3c.dom.Node * @param spoofedPackageSignature The signature of the package to spoof to. * @param dependencies Additional dependencies of this patch. */ -abstract class AbstractGmsCoreSupportResourcePatch( +abstract class BaseGmsCoreSupportResourcePatch( private val fromPackageName: String, private val toPackageName: String, private val spoofedPackageSignature: String, @@ -40,7 +39,8 @@ abstract class AbstractGmsCoreSupportResourcePatch( protected val gmsCoreVendor by gmsCoreVendorOption override fun execute(context: ResourceContext) { - context.copyStrings("gms/host/values/strings.xml") + AddResourcesPatch(BaseGmsCoreSupportResourcePatch::class) + context.patchManifest() context.addSpoofingMetadata() } diff --git a/src/main/kotlin/app/revanced/patches/shared/integrations/AbstractIntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/shared/integrations/AbstractIntegrationsPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch.kt index 9b75a18a28..9cf84495c9 100644 --- a/src/main/kotlin/app/revanced/patches/shared/integrations/AbstractIntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch.kt @@ -1,16 +1,16 @@ -package app.revanced.patches.shared.integrations +package app.revanced.patches.shared.misc.integrations import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint.RegisterResolver +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint.IRegisterResolver import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.ClassDef import com.android.tools.smali.dexlib2.iface.Method -abstract class AbstractIntegrationsPatch( +abstract class BaseIntegrationsPatch( private val hooks: Set ) : BytecodePatch(hooks) { @@ -29,13 +29,15 @@ abstract class AbstractIntegrationsPatch( "Integrations have not been merged yet. This patch can not succeed without merging the integrations." ) - for (hook in hooks) hook.invoke(INTEGRATIONS_CLASS_DESCRIPTOR) + hooks.forEach { hook -> + hook.invoke(INTEGRATIONS_CLASS_DESCRIPTOR) + } } /** * [MethodFingerprint] for integrations. * - * @param contextRegisterResolver A [RegisterResolver] to get the register. + * @param contextRegisterResolver A [IRegisterResolver] to get the register. * @see MethodFingerprint */ abstract class IntegrationsFingerprint( @@ -45,7 +47,7 @@ abstract class AbstractIntegrationsPatch( opcodes: Iterable? = null, strings: Iterable? = null, customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null, - private val contextRegisterResolver: (Method) -> Int = object : RegisterResolver {} + private val contextRegisterResolver: (Method) -> Int = object : IRegisterResolver {} ) : MethodFingerprint( returnType, accessFlags, @@ -66,7 +68,7 @@ abstract class AbstractIntegrationsPatch( } ?: throw PatchException("Could not find hook target fingerprint.") } - interface RegisterResolver : (Method) -> Int { + interface IRegisterResolver : (Method) -> Int { override operator fun invoke(method: Method) = method.implementation!!.registerCount - 1 } } diff --git a/src/main/kotlin/app/revanced/patches/shared/mapping/misc/ResourceMappingPatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/mapping/ResourceMappingPatch.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/shared/mapping/misc/ResourceMappingPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/mapping/ResourceMappingPatch.kt index c80a6b0c5b..c3b1ef20a7 100644 --- a/src/main/kotlin/app/revanced/patches/shared/mapping/misc/ResourceMappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/mapping/ResourceMappingPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.mapping.misc +package app.revanced.patches.shared.misc.mapping import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch.kt similarity index 51% rename from src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch.kt index 73226fefd2..d54601dae1 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch.kt @@ -1,16 +1,14 @@ -package app.revanced.patches.shared.settings +package app.revanced.patches.shared.misc.settings import app.revanced.patcher.PatchClass import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patcher.util.DomFileEditor import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.impl.IntentPreference +import app.revanced.patches.shared.misc.settings.preference.BasePreference +import app.revanced.patches.shared.misc.settings.preference.IntentPreference import app.revanced.util.ResourceGroup import app.revanced.util.copyResources import app.revanced.util.getNode -import app.revanced.util.copyStrings import org.w3c.dom.Node import java.io.Closeable @@ -21,14 +19,13 @@ import java.io.Closeable * If null, no preference will be added. * @param dependencies Additional dependencies of this patch. */ -abstract class AbstractSettingsResourcePatch( +abstract class BaseSettingsResourcePatch( private val rootPreference: Pair? = null, dependencies: Set = emptySet() ) : ResourcePatch( dependencies = setOf(AddResourcesPatch::class) + dependencies -), Closeable { - private lateinit var revancedPreferencesEditor: DomFileEditor - private lateinit var revancedPreferenceScreenNode: Node +), MutableSet by mutableSetOf(), Closeable { + private lateinit var context: ResourceContext override fun execute(context: ResourceContext) { context.copyResources( @@ -36,34 +33,31 @@ abstract class AbstractSettingsResourcePatch( ResourceGroup("xml", "revanced_prefs.xml") ) + this.context = context + + AddResourcesPatch(BaseSettingsResourcePatch::class) + } + + override fun close() { + fun Node.addPreference(preference: BasePreference) { + preference.serialize(ownerDocument) { resource -> + // TODO: Currently, resources can only be added to "values", which may not be the correct place. + // It may be necessary to ask for the desired resourceValue in the future. + AddResourcesPatch("values", resource) + }.let(this::appendChild) + } + + // Add the root preference to an existing fragment if needed. rootPreference?.let { (intentPreference, fragment) -> context.xmlEditor["res/xml/$fragment.xml"].use { it.getNode("PreferenceScreen").addPreference(intentPreference) } } - revancedPreferencesEditor = context.xmlEditor["res/xml/revanced_prefs.xml"] - revancedPreferenceScreenNode = revancedPreferencesEditor.getNode("PreferenceScreen") - - context.copyStrings("settings/host/values/strings.xml") - } - - /** - * Add a preference to the settings fragment file. - * - * @param preference The preference to add. - */ - fun addPreference(preference: BasePreference) { - revancedPreferenceScreenNode.addPreference(preference) - } - - private fun Node.addPreference(preference: BasePreference) { - preference.serialize(ownerDocument) { resource -> - AddResourcesPatch += resource - }.let(this::appendChild) - } - - override fun close() { - revancedPreferencesEditor.close() + // Add all preferences to the ReVanced fragment. + context.xmlEditor["res/xml/revanced_prefs.xml"].use { editor -> + val revancedPreferenceScreenNode = editor.getNode("PreferenceScreen") + forEach { revancedPreferenceScreenNode.addPreference(it) } + } } } diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreference.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreference.kt new file mode 100644 index 0000000000..bad3d49be0 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreference.kt @@ -0,0 +1,62 @@ +package app.revanced.patches.shared.misc.settings.preference + +import app.revanced.util.resource.BaseResource +import org.w3c.dom.Document +import org.w3c.dom.Element + +/** + * Base preference class for all preferences. + * + * @param key The key of the preference. If null, other parameters must be specified. + * @param titleKey The key of the preference title. + * @param summaryKey The key of the preference summary. + * @param tag The tag or full class name of the preference. + */ +@Suppress("MemberVisibilityCanBePrivate") +abstract class BasePreference( + val key: String? = null, + val titleKey: String = "${key}_title", + val summaryKey: String? = "${key}_summary", + val tag: String +) { + /** + * Serialize preference element to XML. + * Overriding methods should invoke super and operate on its return value. + * + * @param resourceCallback A callback for additional resources. + * @param ownerDocument Target document to create elements from. + * + * @return The serialized element. + */ + open fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit): Element = + ownerDocument.createElement(tag).apply { + setAttribute("android:key", key) + setAttribute("android:title", "@string/${titleKey}") + summaryKey?.let { addSummary(it) } + } + + override fun hashCode(): Int { + var result = key?.hashCode() ?: 0 + result = 31 * result + titleKey.hashCode() + result = 31 * result + tag.hashCode() + return result + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as BasePreference + + if (key != other.key) return false + if (titleKey != other.titleKey) return false + if (tag != other.tag) return false + + return true + } + + companion object { + fun Element.addSummary(summaryKey: String, summaryType: SummaryType = SummaryType.DEFAULT) = + setAttribute("android:${summaryType.type}", "@string/$summaryKey") + } +} diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt new file mode 100644 index 0000000000..29bf976a8b --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen.kt @@ -0,0 +1,93 @@ +package app.revanced.patches.shared.misc.settings.preference + +import java.io.Closeable + +abstract class BasePreferenceScreen( + private val root: MutableSet = mutableSetOf() +) : Closeable { + + override fun close() { + if (root.isEmpty()) return + + root.forEach { preference -> + commit(preference.transform()) + } + } + + /** + * Finalize and insert root preference into resource patch + */ + abstract fun commit(screen: PreferenceScreen) + + open inner class Screen( + key: String? = null, + titleKey: String = "${key}_title", + private val summaryKey: String? = "${key}_summary", + preferences: MutableSet = mutableSetOf(), + val categories: MutableSet = mutableSetOf() + ) : BasePreferenceCollection(key, titleKey, preferences) { + + /** + * Initialize using title and summary keys with suffix "_title" and "_summary". + */ + constructor( + key: String? = null, + preferences: MutableSet = mutableSetOf(), + categories: MutableSet = mutableSetOf() + ) : this(key, key + "_title", key + "_summary", preferences, categories) + + override fun transform(): PreferenceScreen { + return PreferenceScreen( + key, + titleKey, + summaryKey, + // Screens and preferences are sorted at runtime by integrations code, + // so they appear in alphabetical order for the localized language in use. + preferences = preferences + categories.map { it.transform() } + ) + } + + private fun ensureScreenInserted() { + // Add to screens if not yet done + if (!root.contains(this)) + root.add(this) + } + + fun addPreferences(vararg preferences: BasePreference) { + ensureScreenInserted() + this.preferences.addAll(preferences) + } + + open inner class Category( + key: String? = null, + titleKey: String = "${key}_title", + preferences: MutableSet = mutableSetOf() + ) : BasePreferenceCollection(key, titleKey, preferences) { + override fun transform(): PreferenceCategory { + return PreferenceCategory( + key, + titleKey, + preferences = preferences + ) + } + + fun addPreferences(vararg preferences: BasePreference) { + ensureScreenInserted() + + // Add to the categories if not done yet. + if (!categories.contains(this)) + categories.add(this) + + this.preferences.addAll(preferences) + } + } + } + + abstract class BasePreferenceCollection( + val key: String? = null, + val titleKey: String = "${key}_title", + val preferences: MutableSet = mutableSetOf() + ) { + abstract fun transform(): BasePreference + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/InputType.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/InputType.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/InputType.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/InputType.kt index 7d3ec982da..e5142d92ee 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/InputType.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/InputType.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.settings.preference.impl +package app.revanced.patches.shared.misc.settings.preference enum class InputType(val type: String) { TEXT("text"), diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt new file mode 100644 index 0000000000..3c933a7299 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/IntentPreference.kt @@ -0,0 +1,56 @@ +package app.revanced.patches.shared.misc.settings.preference + +import app.revanced.patches.shared.misc.settings.preference.IntentPreference.Intent +import app.revanced.util.resource.BaseResource +import org.w3c.dom.Document + +/** + * A preference that opens an intent. + * + * @param key The preference key. If null, other parameters must be specified. + * @param titleKey The preference title key. + * @param summaryKey The preference summary key. + * @param tag The preference tag. + * @param intent The intent to open. + * + * @see Intent + */ +class IntentPreference( + key: String? = null, + titleKey: String = "${key}_title", + summaryKey: String? = "${key}_summary", + tag: String = "Preference", + val intent: Intent, +) : BasePreference(null, titleKey, summaryKey, tag) { + + override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = + super.serialize(ownerDocument, resourceCallback).apply { + appendChild(ownerDocument.createElement("intent").also { intentNode -> + intentNode.setAttribute("android:data", intent.data) + intentNode.setAttribute("android:targetClass", intent.targetClass) + intentNode.setAttribute("android:targetPackage", intent.targetPackageSupplier()) + }) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + if (!super.equals(other)) return false + + other as IntentPreference + + return intent == other.intent + } + + override fun hashCode(): Int { + var result = super.hashCode() + result = 31 * result + intent.hashCode() + return result + } + + data class Intent( + internal val data: String, + internal val targetClass: String, + internal val targetPackageSupplier: () -> String, + ) +} diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/ListPreference.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/ListPreference.kt new file mode 100644 index 0000000000..e0338d29c7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/ListPreference.kt @@ -0,0 +1,72 @@ +package app.revanced.patches.shared.misc.settings.preference + +import app.revanced.util.resource.ArrayResource +import app.revanced.util.resource.BaseResource +import org.w3c.dom.Document + +/** + * List preference. + * + * @param key The preference key. If null, other parameters must be specified. + * @param titleKey The preference title key. + * @param summaryKey The preference summary key. + * @param tag The preference tag. + * @param entriesKey The entries array key. + * @param entryValuesKey The entry values array key. + */ +@Suppress("MemberVisibilityCanBePrivate") +class ListPreference( + key: String? = null, + titleKey: String = "${key}_title", + summaryKey: String? = "${key}_summary", + tag: String = "ListPreference", + val entriesKey: String? = "${key}_entries", + val entryValuesKey: String? = "${key}_entry_values" +) : BasePreference(key, titleKey, summaryKey, tag) { + var entries: ArrayResource? = null + private set + var entryValues: ArrayResource? = null + private set + + /** + * List preference. + * + * @param key The preference key. If null, other parameters must be specified. + * @param titleKey The preference title key. + * @param summaryKey The preference summary key. + * @param tag The preference tag. + * @param entries The entries array. + * @param entryValues The entry values array. + */ + constructor( + key: String? = null, + titleKey: String = "${key}_title", + summaryKey: String? = "${key}_summary", + tag: String = "ListPreference", + entries: ArrayResource, + entryValues: ArrayResource + ) : this(key, titleKey, summaryKey, tag, entries.name, entryValues.name) { + this.entries = entries + this.entryValues = entryValues + } + + override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = + super.serialize(ownerDocument, resourceCallback).apply { + val entriesArrayName = entries?.also { resourceCallback.invoke(it) }?.name ?: entriesKey + val entryValuesArrayName = entryValues?.also { resourceCallback.invoke(it) }?.name ?: entryValuesKey + + entriesArrayName?.let { + setAttribute( + "android:entries", + "@array/$it" + ) + } + + entryValuesArrayName?.let { + setAttribute( + "android:entryValues", + "@array/$it" + ) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/NonInteractivePreference.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/NonInteractivePreference.kt new file mode 100644 index 0000000000..b4b9155a65 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/NonInteractivePreference.kt @@ -0,0 +1,26 @@ +package app.revanced.patches.shared.misc.settings.preference + +import app.revanced.util.resource.BaseResource +import org.w3c.dom.Document + +/** + * A non-interactive preference. + * + * @param key The preference key. + * @param summaryKey The preference summary key. + * @param tag The preference tag. + * @param selectable Whether the preference is selectable. + */ +@Suppress("MemberVisibilityCanBePrivate") +class NonInteractivePreference( + key: String, + summaryKey: String? = "${key}_summary", + tag: String = "Preference", + val selectable: Boolean = false +) : BasePreference(null, "${key}_title", summaryKey, tag) { + + override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = + super.serialize(ownerDocument, resourceCallback).apply { + setAttribute("android:selectable", selectable.toString()) + } +} diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceCategory.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceCategory.kt new file mode 100644 index 0000000000..67e82208f2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceCategory.kt @@ -0,0 +1,28 @@ +package app.revanced.patches.shared.misc.settings.preference + +import app.revanced.util.resource.BaseResource +import org.w3c.dom.Document + +/** + * A preference category. + * + * @param key The key of the preference. If null, other parameters must be specified. + * @param titleKey The key of the preference title. + * @param tag The tag or full class name of the preference. + * @param preferences The preferences in this category. + */ +@Suppress("MemberVisibilityCanBePrivate") +open class PreferenceCategory( + key: String? = null, + titleKey: String = "${key}_title", + tag: String = "PreferenceCategory", + val preferences: Set +) : BasePreference(key, titleKey, null, tag) { + + override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = + super.serialize(ownerDocument, resourceCallback).apply { + preferences.forEach { + appendChild(it.serialize(ownerDocument, resourceCallback)) + } + } +} diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceScreen.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceScreen.kt new file mode 100644 index 0000000000..f03dd23a94 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/PreferenceScreen.kt @@ -0,0 +1,30 @@ +package app.revanced.patches.shared.misc.settings.preference + +import app.revanced.util.resource.BaseResource +import org.w3c.dom.Document + +/** + * A preference screen. + * + * @param key The key of the preference. If null, other parameters must be specified. + * @param titleKey The key of the preference title. + * @param summaryKey The key of the preference summary. + * @param tag The tag or full class name of the preference. + * @param preferences The preferences in this screen. + */ +@Suppress("MemberVisibilityCanBePrivate") +open class PreferenceScreen( + key: String? = null, + titleKey: String = "${key}_title", + summaryKey: String? = "${key}_summary", + tag: String = "PreferenceScreen", + val preferences: Set +) : BasePreference(key, titleKey, summaryKey, tag) { + + override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = + super.serialize(ownerDocument, resourceCallback).apply { + preferences.forEach { + appendChild(it.serialize(ownerDocument, resourceCallback)) + } + } +} diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/SummaryType.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SummaryType.kt similarity index 63% rename from src/main/kotlin/app/revanced/patches/shared/settings/preference/SummaryType.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SummaryType.kt index 006f6986cf..ccf547b223 100644 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/SummaryType.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SummaryType.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.settings.preference +package app.revanced.patches.shared.misc.settings.preference enum class SummaryType(val type: String) { DEFAULT("summary"), ON("summaryOn"), OFF("summaryOff") diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SwitchPreference.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SwitchPreference.kt new file mode 100644 index 0000000000..e09d813a36 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/SwitchPreference.kt @@ -0,0 +1,28 @@ +package app.revanced.patches.shared.misc.settings.preference + +import app.revanced.util.resource.BaseResource +import org.w3c.dom.Document + +/** + * A switch preference. + * + * @param key The preference key. If null, other parameters must be specified. + * @param titleKey The preference title key. + * @param tag The preference tag. + * @param summaryOnKey The preference summary-on key. + * @param summaryOffKey The preference summary-off key. + */ +@Suppress("MemberVisibilityCanBePrivate") +class SwitchPreference( + key: String? = null, + titleKey: String = "${key}_title", + tag: String = "SwitchPreference", + val summaryOnKey: String = "${key}_summary_on", + val summaryOffKey: String = "${key}_summary_off" +) : BasePreference(key, titleKey, null, tag) { + override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = + super.serialize(ownerDocument, resourceCallback).apply { + addSummary(summaryOnKey, SummaryType.ON) + addSummary(summaryOffKey, SummaryType.OFF) + } +} diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/TextPreference.kt b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/TextPreference.kt new file mode 100644 index 0000000000..d329a91778 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/misc/settings/preference/TextPreference.kt @@ -0,0 +1,28 @@ +package app.revanced.patches.shared.misc.settings.preference + +import app.revanced.util.resource.BaseResource +import org.w3c.dom.Document + +/** + * A text preference. + * + * @param key The preference key. If null, other parameters must be specified. + * @param titleKey The preference title key. + * @param summaryKey The preference summary key. + * @param tag The preference tag. + * @param inputType The preference input type. + */ +@Suppress("MemberVisibilityCanBePrivate") +class TextPreference( + key: String? = null, + titleKey: String = "${key}_title", + summaryKey: String? = "${key}_summary", + tag: String = "app.revanced.integrations.shared.settings.preference.ResettableEditTextPreference", + val inputType: InputType = InputType.TEXT +) : BasePreference(key, titleKey, summaryKey, tag) { + + override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = + super.serialize(ownerDocument, resourceCallback).apply { + setAttribute("android:inputType", inputType.type) + } +} diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/BasePreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/BasePreference.kt deleted file mode 100644 index a6a19806c3..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/BasePreference.kt +++ /dev/null @@ -1,35 +0,0 @@ -package app.revanced.patches.shared.settings.preference - -import app.revanced.util.resource.BaseResource -import app.revanced.util.resource.StringResource -import org.w3c.dom.Document -import org.w3c.dom.Element - -/** - * Base preference class for all preferences. - * - * @param key The key of the preference. - * @param title The title of the preference. - * @param tag The full class name for the preference. - * @param summary The summary of the preference. - */ -abstract class BasePreference( - val key: String?, - val title: StringResource, - val summary: StringResource? = null, - val tag: String -) { - /** - * Serialize preference element to XML. - * Overriding methods should invoke super and operate on its return value. - * @param ownerDocument Target document to create elements from. - * @param resourceCallback Called when a resource has been processed. - * @return The serialized element. - */ - open fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit): Element = - ownerDocument.createElement(tag).apply { - if (key != null) setAttribute("android:key", key) - setAttribute("android:title", "@string/${title.also { resourceCallback.invoke(it) }.name}") - addSummary(summary?.also { resourceCallback.invoke(it) }) - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/ComponentsExtensions.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/ComponentsExtensions.kt deleted file mode 100644 index fdb8c2547a..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/ComponentsExtensions.kt +++ /dev/null @@ -1,27 +0,0 @@ -package app.revanced.patches.shared.settings.preference - -import app.revanced.util.resource.StringResource -import org.w3c.dom.Element - -internal fun Element.addSummary(summaryResource: StringResource?, summaryType: SummaryType = SummaryType.DEFAULT) = - summaryResource?.let { summary -> - setAttribute("android:${summaryType.type}", "@string/${summary.name}") - } - -internal fun Element.addDefault(default: T) { - if (default is Boolean && !(default as Boolean)) return // No need to include the default, as no value already means 'false' - default?.let { - setAttribute( - "android:defaultValue", when (it) { - is Boolean -> it.toString() - is String -> it - else -> throw IllegalArgumentException("Unsupported default value type: ${it::class.java.name}") - } - ) - } -} - -internal fun CharSequence.removePunctuation(): String { - val punctuation = "\\p{P}+".toRegex() - return this.replace(punctuation, "") -} diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/IntentPreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/IntentPreference.kt deleted file mode 100644 index 919d09b681..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/IntentPreference.kt +++ /dev/null @@ -1,42 +0,0 @@ -package app.revanced.patches.shared.settings.preference.impl - -import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.util.resource.BaseResource -import app.revanced.util.resource.StringResource -import org.w3c.dom.Document - -/** - * A preference that opens an intent. - * - * @param key The key of the preference. - * @param title The title of the preference. - * @param summary The summary of the text preference. - * @param intent The intent of the preference. - */ -class IntentPreference( - key: String, - title: StringResource, - summary: StringResource, - val intent: Intent -) : BasePreference(key, title, summary, "Preference") { - constructor( - title: StringResource, - summary: StringResource, - intent: Intent - ) : this("", title, summary, intent) - - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - this.appendChild(ownerDocument.createElement("intent").also { intentNode -> - intentNode.setAttribute("android:data", intent.data) - intentNode.setAttribute("android:targetClass", intent.targetClass) - intentNode.setAttribute("android:targetPackage", intent.targetPackageSupplier()) - }) - } - - class Intent( - internal val data: String, - internal val targetClass: String, - internal val targetPackageSupplier: () -> String, - ) -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ListPreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ListPreference.kt deleted file mode 100644 index 0533bcef55..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/ListPreference.kt +++ /dev/null @@ -1,32 +0,0 @@ -package app.revanced.patches.shared.settings.preference.impl - -import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.addSummary -import app.revanced.util.resource.ArrayResource -import app.revanced.util.resource.BaseResource -import app.revanced.util.resource.StringResource -import org.w3c.dom.Document - -/** - * List preference. - * - * @param key The key of the list preference. - * @param title The title of the list preference. - * @param entries The human-readable entries of the list preference. - * @param entryValues The entry values of the list preference. - * @param summary The summary of the list preference. - */ -class ListPreference( - key: String, - title: StringResource, - private val entries: ArrayResource, - private val entryValues: ArrayResource, - summary: StringResource? = null -) : BasePreference(key, title, summary, "ListPreference") { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - setAttribute("android:entries", "@array/${entries.also { resourceCallback.invoke(it) }.name}") - setAttribute("android:entryValues", "@array/${entryValues.also { resourceCallback.invoke(it) }.name}") - addSummary(summary) - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt deleted file mode 100644 index 26e8e6a717..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/NonInteractivePreference.kt +++ /dev/null @@ -1,36 +0,0 @@ -package app.revanced.patches.shared.settings.preference.impl - -import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.util.resource.BaseResource -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.addSummary -import org.w3c.dom.Document -import org.w3c.dom.Element - -/** - * A non interactive preference. - * - * Not backed by any preference key/value, - * and cannot be changed by or interacted with by the user. - * - * @param title The title of the preference. - * @param summary The summary of the text preference. - * @param selectable If this preference responds to tapping. - * Setting to 'true' restores the horizontal dividers on the top and bottom, - * but tapping will still do nothing since this Preference has no key. - */ -class NonInteractivePreference( - title: StringResource, - summary: StringResource?, - tag: String = "Preference", - // If androidx.preference is later used, this can be changed to the show top/bottom dividers feature. - val selectable: Boolean = false -) : BasePreference(null, title, summary, tag) { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit): Element { - return super.serialize(ownerDocument, resourceCallback).apply { - addSummary(summary?.also { resourceCallback.invoke(it) - setAttribute("android:selectable", selectable.toString()) - }) - } - } -} diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceCategory.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceCategory.kt deleted file mode 100644 index 90d0139c23..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceCategory.kt +++ /dev/null @@ -1,27 +0,0 @@ -package app.revanced.patches.shared.settings.preference.impl - -import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.util.resource.BaseResource -import app.revanced.util.resource.StringResource -import org.w3c.dom.Document - -/** - * A preference category. - * - * @param key The key of the preference. - * @param title The title of the preference. - * @param preferences Child preferences of this category. - */ -open class PreferenceCategory( - key: String, - title: StringResource, - var preferences: List, - tag: String = "PreferenceCategory" -) : BasePreference(key, title, null, tag) { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - for (childPreference in preferences) { - this.appendChild(childPreference.serialize(ownerDocument, resourceCallback)) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceScreen.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceScreen.kt deleted file mode 100644 index 2c12dc66d0..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/PreferenceScreen.kt +++ /dev/null @@ -1,30 +0,0 @@ -package app.revanced.patches.shared.settings.preference.impl - -import app.revanced.util.resource.BaseResource -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.addSummary -import org.w3c.dom.Document - -/** - * A preference screen. - * - * @param key The key of the preference. - * @param title The title of the preference. - * @param preferences Child preferences of this screen. - * @param summary The summary of the text preference. - */ -open class PreferenceScreen( - key: String, - title: StringResource, - var preferences: List, - summary: StringResource? = null -) : BasePreference(key, title, summary, "PreferenceScreen") { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - addSummary(summary?.also { resourceCallback.invoke(it) }) - - for (childPreference in preferences) - this.appendChild(childPreference.serialize(ownerDocument, resourceCallback)) - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/SwitchPreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/SwitchPreference.kt deleted file mode 100644 index c10b977c0d..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/SwitchPreference.kt +++ /dev/null @@ -1,34 +0,0 @@ -package app.revanced.patches.shared.settings.preference.impl - -import app.revanced.patches.shared.settings.preference.SummaryType -import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.addSummary -import org.w3c.dom.Document -import app.revanced.util.resource.BaseResource -import app.revanced.util.resource.StringResource -import org.w3c.dom.Element - -/** - * A switch preference. - * - * @param key The key of the switch. - * @param title The title of the switch. - * @param summaryOn The summary to show when the preference is enabled. - * @param summaryOff The summary to show when the preference is disabled. - * @param userDialogMessage The message to show in a dialog when the user toggles the preference. - */ -class SwitchPreference( - key: String, title: StringResource, - val summaryOn: StringResource, - val summaryOff: StringResource, - val userDialogMessage: StringResource? = null, -) : BasePreference(key, title, null, "SwitchPreference") { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit): Element { - userDialogMessage?.let(resourceCallback::invoke) - - return super.serialize(ownerDocument, resourceCallback).apply { - addSummary(summaryOn.also { resourceCallback.invoke(it) }, SummaryType.ON) - addSummary(summaryOff.also { resourceCallback.invoke(it) }, SummaryType.OFF) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/TextPreference.kt b/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/TextPreference.kt deleted file mode 100644 index 6c93e75f73..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/settings/preference/impl/TextPreference.kt +++ /dev/null @@ -1,27 +0,0 @@ -package app.revanced.patches.shared.settings.preference.impl - -import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.util.resource.BaseResource -import app.revanced.util.resource.StringResource -import org.w3c.dom.Document - -/** - * A text preference. - * - * @param key The key of the text preference. - * @param title The title of the text preference. - * @param inputType The input type of the text preference. - * @param summary The summary of the text preference. - */ -class TextPreference( - key: String?, - title: StringResource, - summary: StringResource?, - val inputType: InputType = InputType.TEXT, - tag: String = "app.revanced.integrations.shared.settings.preference.ResettableEditTextPreference" -) : BasePreference(key, title, summary, tag) { - override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = - super.serialize(ownerDocument, resourceCallback).apply { - setAttribute("android:inputType", inputType.type) - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/util/AbstractPreferenceScreen.kt b/src/main/kotlin/app/revanced/patches/shared/settings/util/AbstractPreferenceScreen.kt deleted file mode 100644 index f5b9d5a8ff..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/settings/util/AbstractPreferenceScreen.kt +++ /dev/null @@ -1,99 +0,0 @@ -package app.revanced.patches.shared.settings.util - -import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.impl.IntentPreference -import app.revanced.patches.shared.settings.preference.impl.PreferenceCategory -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.removePunctuation -import app.revanced.util.resource.StringResource -import java.io.Closeable - -abstract class AbstractPreferenceScreen( - private val root: MutableList = mutableListOf() -) : Closeable { - override fun close() { - if (root.isEmpty()) - return - - for (preference in root.sortedBy { it.title }) { - commit(preference.transform()) - } - } - - /** - * Finalize and insert root preference into resource patch - */ - abstract fun commit(screen: PreferenceScreen) - - open inner class Screen( - key: String, - title: String, - val summary: String? = null, - preferences: MutableList = mutableListOf(), - val categories: MutableList = mutableListOf() - ) : BasePreferenceCollection(key, title, preferences) { - override fun transform() = PreferenceScreen( - key, - StringResource( - "${key}_title", title - ), - preferences.sortedWith( - compareBy( - { it is IntentPreference }, - { it is PreferenceScreen }, - { it.title.value.removePunctuation().lowercase() }, - ) - ) + categories.sortedBy { - it.title.removePunctuation().lowercase() - }.map { - it.transform() - }, - summary?.let { summary -> - StringResource("${key}_summary", summary) - } - ) - - private fun ensureScreenInserted() { - // Add to screens if not yet done - if (!this@AbstractPreferenceScreen.root.contains(this)) - this@AbstractPreferenceScreen.root.add(this) - } - - fun addPreferences(vararg preferences: BasePreference) { - ensureScreenInserted() - this.preferences.addAll(preferences) - } - - open inner class Category( - key: String, - title: String, - preferences: MutableList = mutableListOf() - ) : BasePreferenceCollection(key, title, preferences) { - override fun transform(): PreferenceCategory { - return PreferenceCategory( - key, - StringResource("${key}_title", title), - preferences.sortedBy { it.title.value.removePunctuation().lowercase() } - ) - } - - fun addPreferences(vararg preferences: BasePreference) { - ensureScreenInserted() - - // Add to categories if not yet done - if (!this@Screen.categories.contains(this)) - this@Screen.categories.add(this) - - this.preferences.addAll(preferences) - } - } - } - - abstract class BasePreferenceCollection( - val key: String, - val title: String, - val preferences: MutableList = mutableListOf() - ) { - abstract fun transform(): BasePreference - } -} diff --git a/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabResourcePatch.kt b/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabResourcePatch.kt index d1093325d4..5f2ac4b22e 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/navbar/PremiumNavbarTabResourcePatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.spotify.navbar import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch @Patch(dependencies = [ResourceMappingPatch::class]) object PremiumNavbarTabResourcePatch : ResourcePatch() { diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/IntegrationsPatch.kt index 824e5df8bc..775a674773 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/IntegrationsPatch.kt @@ -1,10 +1,10 @@ package app.revanced.patches.tiktok.misc.integrations import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch import app.revanced.patches.tiktok.misc.integrations.fingerprints.InitFingerprint @Patch(requiresIntegrations = true) -object IntegrationsPatch : AbstractIntegrationsPatch( +object IntegrationsPatch : BaseIntegrationsPatch( setOf(InitFingerprint) ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/fingerprints/InitFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/fingerprints/InitFingerprint.kt index 03b12c2149..f61e36bc12 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/fingerprints/InitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/integrations/fingerprints/InitFingerprint.kt @@ -1,6 +1,6 @@ package app.revanced.patches.tiktok.misc.integrations.fingerprints -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint internal object InitFingerprint : IntegrationsFingerprint( customFingerprint = { methodDef, _ -> diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt index 0ba8147c55..75f9df43d3 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/audio/AudioAdsPatch.kt @@ -7,8 +7,8 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.twitch.ad.audio.fingerprints.AudioAdsPresenterPlayFingerprint import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch import app.revanced.patches.twitch.misc.settings.SettingsPatch @@ -16,7 +16,7 @@ import app.revanced.patches.twitch.misc.settings.SettingsPatch @Patch( name = "Block audio ads", description = "Blocks audio ads in streams and VODs.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])], ) @Suppress("unused") @@ -24,6 +24,10 @@ object AudioAdsPatch : BytecodePatch( setOf(AudioAdsPresenterPlayFingerprint) ) { override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(SwitchPreference("revanced_block_audio_ads")) + // Block playAds call with(AudioAdsPresenterPlayFingerprint.result!!) { mutableMethod.addInstructionsWithLabels( @@ -37,23 +41,5 @@ object AudioAdsPatch : BytecodePatch( ExternalLabel("show_audio_ads", mutableMethod.getInstruction(0)) ) } - - SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences( - SwitchPreference( - "revanced_block_audio_ads", - StringResource( - "revanced_block_audio_ads", - "Block audio ads" - ), - StringResource( - "revanced_block_audio_ads_on", - "Audio ads are blocked" - ), - StringResource( - "revanced_block_audio_ads_off", - "Audio ads are unblocked" - ) - ) - ) } } diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt index 17d794a3da..afc2e367d6 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/embedded/EmbeddedAdsPatch.kt @@ -6,15 +6,12 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.all.misc.resources.AddResourcesPatch.addString -import app.revanced.patches.shared.settings.preference.impl.ListPreference +import app.revanced.patches.shared.misc.settings.preference.ListPreference import app.revanced.patches.twitch.ad.embedded.fingerprints.CreateUsherClientFingerprint import app.revanced.patches.twitch.ad.video.VideoAdsPatch import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch import app.revanced.patches.twitch.misc.settings.SettingsPatch import app.revanced.util.exception -import app.revanced.util.resource.ArrayResource -import app.revanced.util.resource.StringResource @Patch( name = "Block embedded ads", @@ -23,7 +20,7 @@ import app.revanced.util.resource.StringResource VideoAdsPatch::class, IntegrationsPatch::class, SettingsPatch::class, - AddResourcesPatch::class, + AddResourcesPatch::class ], compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])] ) @@ -32,6 +29,12 @@ object EmbeddedAdsPatch : BytecodePatch( setOf(CreateUsherClientFingerprint) ) { override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.ADS.SURESTREAM.addPreferences( + ListPreference("revanced_block_embedded_ads") + ) + val result = CreateUsherClientFingerprint.result ?: throw CreateUsherClientFingerprint.exception // Inject OkHttp3 application interceptor @@ -43,40 +46,5 @@ object EmbeddedAdsPatch : BytecodePatch( invoke-virtual {v0, v2}, Lokhttp3/OkHttpClient${"$"}Builder;->addInterceptor(Lokhttp3/Interceptor;)Lokhttp3/OkHttpClient${"$"}Builder; """ ) - - SettingsPatch.PreferenceScreen.ADS.SURESTREAM.addPreferences( - ListPreference( - "revanced_block_embedded_ads", - StringResource( - "revanced_block_embedded_ads", - "Block embedded video ads" - ), - ArrayResource( - "revanced_hls_proxies", - listOf( - StringResource("revanced_proxy_disabled", "Disabled"), - StringResource("revanced_proxy_luminous", "Luminous proxy"), - StringResource("revanced_proxy_purpleadblock", "PurpleAdBlock proxy"), - ) - ), - ArrayResource( - "revanced_hls_proxies_values", - listOf( - StringResource("key_revanced_proxy_disabled", "disabled"), - StringResource("key_revanced_proxy_luminous", "luminous"), - StringResource("key_revanced_proxy_purpleadblock", "purpleadblock") - ) - ) - ) - ) - - addString( - "revanced_embedded_ads_service_unavailable", - "%s is unavailable. Ads may show. Try switching to another ad block service in settings." - ) - addString( - "revanced_embedded_ads_service_failed", - "%s server returned an error. Ads may show. Try switching to another ad block service in settings." - ) } } diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/BaseAdPatch.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch.kt rename to src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/BaseAdPatch.kt index 7f92651bf6..776b338fbb 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/AbstractAdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/shared/util/BaseAdPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.util.smali.ExternalLabel -abstract class AbstractAdPatch( +abstract class BaseAdPatch( val conditionCall: String, val skipLabelName: String, internal val fingerprints: Set = emptySet(), diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt index d70ada305d..ab00fe79af 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/video/VideoAdsPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.twitch.ad.video -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels @@ -8,22 +7,23 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference -import app.revanced.patches.twitch.ad.shared.util.AbstractAdPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference +import app.revanced.patches.twitch.ad.shared.util.BaseAdPatch import app.revanced.patches.twitch.ad.video.fingerprints.CheckAdEligibilityLambdaFingerprint import app.revanced.patches.twitch.ad.video.fingerprints.ContentConfigShowAdsFingerprint import app.revanced.patches.twitch.ad.video.fingerprints.GetReadyToShowAdFingerprint import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch import app.revanced.patches.twitch.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Block video ads", description = "Blocks video ads in streams and VODs.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])] ) -object VideoAdsPatch : AbstractAdPatch( +object VideoAdsPatch : BaseAdPatch( "Lapp/revanced/integrations/twitch/patches/VideoAdsPatch;->shouldBlockVideoAds()Z", "show_video_ads", setOf( @@ -33,6 +33,10 @@ object VideoAdsPatch : AbstractAdPatch( ) ) { override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(SwitchPreference("revanced_block_video_ads")) + /* Amazon ads SDK */ context.blockMethods( "Lcom/amazon/ads/video/player/AdsManagerImpl;", @@ -120,23 +124,5 @@ object VideoAdsPatch : AbstractAdPatch( """ ) } ?: throw ContentConfigShowAdsFingerprint.exception - - SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences( - SwitchPreference( - "revanced_block_video_ads", - StringResource( - "revanced_block_video_ads", - "Block video ads" - ), - StringResource( - "revanced_block_video_ads_on", - "Video ads are blocked" - ), - StringResource( - "revanced_block_video_ads_off", - "Video ads are unblocked" - ) - ) - ) } } diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt index 50224d4232..7cf83924be 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/ShowDeletedMessagesPatch.kt @@ -9,15 +9,13 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.settings.preference.impl.ListPreference +import app.revanced.patches.shared.misc.settings.preference.ListPreference import app.revanced.patches.twitch.chat.antidelete.fingerprints.ChatUtilCreateDeletedSpanFingerprint import app.revanced.patches.twitch.chat.antidelete.fingerprints.DeletedMessageClickableSpanCtorFingerprint import app.revanced.patches.twitch.chat.antidelete.fingerprints.SetHasModAccessFingerprint import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch import app.revanced.patches.twitch.misc.settings.SettingsPatch import app.revanced.util.exception -import app.revanced.util.resource.ArrayResource -import app.revanced.util.resource.StringResource @Patch( name = "Show deleted messages", @@ -44,6 +42,15 @@ object ShowDeletedMessagesPatch : BytecodePatch( """ override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences( + ListPreference( + key = "revanced_show_deleted_messages", + summaryKey = null, + ) + ) + // Spoiler mode: Force set hasModAccess member to true in constructor DeletedMessageClickableSpanCtorFingerprint.result?.mutableMethod?.apply { addInstructionsWithLabels( @@ -74,36 +81,5 @@ object ShowDeletedMessagesPatch : BytecodePatch( ExternalLabel("no_reformat", getInstruction(0)) ) } ?: throw ChatUtilCreateDeletedSpanFingerprint.exception - - SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences( - ListPreference( - "revanced_show_deleted_messages", - StringResource( - "revanced_show_deleted_messages_title", - "Show deleted messages" - ), - ArrayResource( - "revanced_deleted_messages", - listOf( - StringResource("revanced_deleted_messages_hide", "Do not show deleted messages"), - StringResource("revanced_deleted_messages_spoiler", "Hide deleted messages behind a spoiler"), - StringResource( - "revanced_deleted_messages_cross_out", - "Show deleted messages as crossed-out text" - ) - ) - ), - ArrayResource( - "revanced_deleted_messages_values", - listOf( - StringResource("key_revanced_deleted_messages_hide", "hide"), - StringResource("key_revanced_deleted_messages_spoiler", "spoiler"), - StringResource("key_revanced_deleted_messages_cross_out", "cross-out") - ) - ) - ) - ) - - AddResourcesPatch.addString("revanced_deleted_msg", "message deleted") } } diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt index f397f49a26..740f8cedf8 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/AutoClaimChannelPointsPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.twitch.chat.autoclaim -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -8,38 +7,27 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.twitch.chat.autoclaim.fingerprints.CommunityPointsButtonViewDelegateFingerprint import app.revanced.patches.twitch.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Auto claim channel points", description = "Automatically claim Channel Points.", - dependencies = [SettingsPatch::class], + dependencies = [SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])] ) @Suppress("unused") -object AutoClaimChannelPointPatch : BytecodePatch( +object AutoClaimChannelPointsPatch : BytecodePatch( setOf(CommunityPointsButtonViewDelegateFingerprint) ) { override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences( - SwitchPreference( - "revanced_auto_claim_channel_points", - StringResource( - "revanced_auto_claim_channel_points", - "Automatically claim Channel Points" - ), - StringResource( - "revanced_auto_claim_channel_points_on", - "Channel Points are claimed automatically" - ), - StringResource( - "revanced_auto_claim_channel_points_off", - "Channel Points are not claimed automatically" - ) - ) + SwitchPreference("revanced_auto_claim_channel_points") ) CommunityPointsButtonViewDelegateFingerprint.result?.mutableMethod?.apply { diff --git a/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt b/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt index 996fdfbc2e..644b614c9b 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/debug/DebugModePatch.kt @@ -1,23 +1,23 @@ package app.revanced.patches.twitch.debug -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.twitch.debug.fingerprints.IsDebugConfigEnabledFingerprint import app.revanced.patches.twitch.debug.fingerprints.IsOmVerificationEnabledFingerprint import app.revanced.patches.twitch.debug.fingerprints.ShouldShowDebugOptionsFingerprint import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch import app.revanced.patches.twitch.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Debug mode", description = "Enables Twitch's internal debugging mode.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [CompatiblePackage("tv.twitch.android.app")], use = false ) @@ -30,6 +30,10 @@ object DebugModePatch : BytecodePatch( ) ) { override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.MISC.OTHER.addPreferences(SwitchPreference("revanced_twitch_debug_mode")) + listOf( IsDebugConfigEnabledFingerprint, IsOmVerificationEnabledFingerprint, @@ -46,23 +50,5 @@ object DebugModePatch : BytecodePatch( ) } ?: throw it.exception } - - SettingsPatch.PreferenceScreen.MISC.OTHER.addPreferences( - SwitchPreference( - "revanced_twitch_debug_mode", - StringResource( - "revanced_twitch_debug_mode_title", - "Enable Twitch debug mode" - ), - StringResource( - "revanced_twitch_debug_mode_summary_on", - "Twitch debug mode is enabled (not recommended)" - ), - StringResource( - "revanced_twitch_debug_mode_summary_off", - "Twitch debug mode is disabled" - ) - ) - ) } } diff --git a/src/main/kotlin/app/revanced/patches/twitch/misc/integrations/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/misc/integrations/IntegrationsPatch.kt index 6e0dd2459d..0158adc64b 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/misc/integrations/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/misc/integrations/IntegrationsPatch.kt @@ -1,10 +1,10 @@ package app.revanced.patches.twitch.misc.integrations import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch import app.revanced.patches.twitch.misc.integrations.fingerprints.InitFingerprint @Patch(requiresIntegrations = true) -object IntegrationsPatch : AbstractIntegrationsPatch( +object IntegrationsPatch : BaseIntegrationsPatch( setOf(InitFingerprint) ) diff --git a/src/main/kotlin/app/revanced/patches/twitch/misc/integrations/fingerprints/InitFingerprint.kt b/src/main/kotlin/app/revanced/patches/twitch/misc/integrations/fingerprints/InitFingerprint.kt index 6ae7150d82..10ca2039be 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/misc/integrations/fingerprints/InitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/misc/integrations/fingerprints/InitFingerprint.kt @@ -1,6 +1,6 @@ package app.revanced.patches.twitch.misc.integrations.fingerprints -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint internal object InitFingerprint : IntegrationsFingerprint( customFingerprint = { methodDef, _ -> diff --git a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt index b59a3e05a4..e8ec635c8c 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsPatch.kt @@ -12,17 +12,15 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.all.misc.resources.AddResourcesPatch.addString -import app.revanced.patches.shared.settings.preference.impl.PreferenceCategory -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference -import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference +import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch import app.revanced.patches.twitch.misc.settings.fingerprints.MenuGroupsOnClickFingerprint import app.revanced.patches.twitch.misc.settings.fingerprints.MenuGroupsUpdatedFingerprint import app.revanced.patches.twitch.misc.settings.fingerprints.SettingsActivityOnCreateFingerprint import app.revanced.patches.twitch.misc.settings.fingerprints.SettingsMenuItemEnumFingerprint import app.revanced.util.exception -import app.revanced.util.resource.StringResource import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.immutable.ImmutableField import java.io.Closeable @@ -34,7 +32,7 @@ import java.io.Closeable dependencies = [ IntegrationsPatch::class, SettingsResourcePatch::class, - AddResourcesPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"]) @@ -54,13 +52,18 @@ object SettingsPatch : BytecodePatch( private const val REVANCED_SETTINGS_MENU_ITEM_ICON_RES = "ic_settings" private const val MENU_ITEM_ENUM_CLASS_DESCRIPTOR = "Ltv/twitch/android/feature/settings/menu/SettingsMenuItem;" - private const val MENU_DISMISS_EVENT_CLASS_DESCRIPTOR = "Ltv/twitch/android/feature/settings/menu/SettingsMenuViewDelegate\$Event\$OnDismissClicked;" + private const val MENU_DISMISS_EVENT_CLASS_DESCRIPTOR = + "Ltv/twitch/android/feature/settings/menu/SettingsMenuViewDelegate\$Event\$OnDismissClicked;" private const val INTEGRATIONS_PACKAGE = "app/revanced/integrations/twitch" private const val ACTIVITY_HOOKS_CLASS_DESCRIPTOR = "L$INTEGRATIONS_PACKAGE/settings/AppCompatActivityHook;" private const val UTILS_CLASS_DESCRIPTOR = "L$INTEGRATIONS_PACKAGE/Utils;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + + PreferenceScreen.MISC.OTHER.addPreferences(SwitchPreference("revanced_debug")) + // Hook onCreate to handle fragment creation SettingsActivityOnCreateFingerprint.result?.apply { val insertIndex = mutableMethod.implementation!!.instructions.size - 2 @@ -114,17 +117,6 @@ object SettingsPatch : BytecodePatch( ExternalLabel("no_rv_settings_onclick", mutableMethod.getInstruction(insertIndex)) ) } ?: throw MenuGroupsOnClickFingerprint.exception - - addString("revanced_settings", "ReVanced Settings", false) - - PreferenceScreen.MISC.OTHER.addPreferences( - SwitchPreference( - "revanced_debug", - StringResource("revanced_debug_title", "Debug logging"), - StringResource("revanced_debug_summary_on", "Debug logs are enabled"), - StringResource("revanced_debug_summary_off", "Debug logs are disabled") - ), - ) } private fun MethodFingerprintResult.injectMenuItem( @@ -168,33 +160,33 @@ object SettingsPatch : BytecodePatch( /** * Preference screens patches should add their settings to. */ - internal object PreferenceScreen : AbstractPreferenceScreen() { - val ADS = CustomScreen("ads", "Ads", "Ad blocking settings") - val CHAT = CustomScreen("chat", "Chat", "Chat settings") - val MISC = CustomScreen("misc", "Misc", "Miscellaneous patches") + internal object PreferenceScreen : BasePreferenceScreen() { + val ADS = CustomScreen("revanced_ads_screen") + val CHAT = CustomScreen("revanced_chat_screen") + val MISC = CustomScreen("revanced_misc_screen") - internal class CustomScreen(key: String, title: String, summary: String) : Screen(key, title, summary) { + internal class CustomScreen(key: String) : Screen(key) { /* Categories */ - val GENERAL = CustomCategory("general", "General settings") - val OTHER = CustomCategory("other", "Other settings") - val CLIENT_SIDE = CustomCategory("client_ads", "Client-side ads") - val SURESTREAM = CustomCategory("surestream_ads", "Server-side surestream ads") + val GENERAL = CustomCategory("revanced_general_category") + val OTHER = CustomCategory("revanced_other_category") + val CLIENT_SIDE = CustomCategory("revanced_client_ads_category") + val SURESTREAM = CustomCategory("revanced_surestream_ads_category") - internal inner class CustomCategory(key: String, title: String) : Screen.Category(key, title) { + internal inner class CustomCategory(key: String) : Screen.Category(key) { /* For Twitch, we need to load our CustomPreferenceCategory class instead of the default one. */ override fun transform(): PreferenceCategory { return PreferenceCategory( key, - StringResource("${key}_title", title), - preferences.sortedBy { it.title.value }, - "app.revanced.integrations.twitch.settings.preference.CustomPreferenceCategory" + preferences = preferences, + tag = "app.revanced.integrations.twitch.settings.preference.CustomPreferenceCategory" ) } } } - override fun commit(screen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) = - SettingsResourcePatch.addPreference(screen) + override fun commit(screen: app.revanced.patches.shared.misc.settings.preference.PreferenceScreen) { + SettingsResourcePatch += screen + } } override fun close() = PreferenceScreen.close() diff --git a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsResourcePatch.kt index e9ad24dbcb..f547f4b77d 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/SettingsResourcePatch.kt @@ -1,5 +1,5 @@ package app.revanced.patches.twitch.misc.settings -import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch +import app.revanced.patches.shared.misc.settings.BaseSettingsResourcePatch -object SettingsResourcePatch : AbstractSettingsResourcePatch() \ No newline at end of file +object SettingsResourcePatch : BaseSettingsResourcePatch() \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/BaseHookPatchPatch.kt b/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/BaseHookPatch.kt similarity index 78% rename from src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/BaseHookPatchPatch.kt rename to src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/BaseHookPatch.kt index 39d5c296ce..74c83fb185 100644 --- a/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/BaseHookPatchPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/BaseHookPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.patch.BytecodePatch import app.revanced.patches.twitter.misc.hook.json.JsonHookPatch -abstract class BaseHookPatchPatch(private val hookClassDescriptor: String) : BytecodePatch() { +abstract class BaseHookPatch(private val hookClassDescriptor: String) : BytecodePatch() { override fun execute(context: BytecodeContext) = JsonHookPatch.hooks.addHook(JsonHookPatch.Hook(context, hookClassDescriptor)) } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/ads/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/ads/HideAdsHookPatch.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/ads/HideAdsPatch.kt rename to src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/ads/HideAdsHookPatch.kt index 15a8f3b22d..8b12b64c0e 100644 --- a/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/ads/HideAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/ads/HideAdsHookPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.twitter.misc.hook.patch.ads import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.twitter.misc.hook.json.JsonHookPatch -import app.revanced.patches.twitter.misc.hook.patch.BaseHookPatchPatch +import app.revanced.patches.twitter.misc.hook.patch.BaseHookPatch @Patch( name = "Hide ads", @@ -12,4 +12,4 @@ import app.revanced.patches.twitter.misc.hook.patch.BaseHookPatchPatch compatiblePackages = [CompatiblePackage("com.twitter.android")] ) @Suppress("unused") -object HideAdsPatch : BaseHookPatchPatch("Lapp/revanced/integrations/twitter/patches/hook/patch/ads/AdsHook;") \ No newline at end of file +object HideAdsHookPatch : BaseHookPatch("Lapp/revanced/integrations/twitter/patches/hook/patch/ads/AdsHook;") \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/recommendation/HideRecommendedUsersPatch.kt b/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/recommendation/HideRecommendedUsersPatch.kt index 211e0f7c87..1897ce0f96 100644 --- a/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/recommendation/HideRecommendedUsersPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitter/misc/hook/patch/recommendation/HideRecommendedUsersPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.twitter.misc.hook.patch.recommendation import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.twitter.misc.hook.json.JsonHookPatch -import app.revanced.patches.twitter.misc.hook.patch.BaseHookPatchPatch +import app.revanced.patches.twitter.misc.hook.patch.BaseHookPatch @Patch( name = "Hide recommended users", @@ -11,6 +11,6 @@ import app.revanced.patches.twitter.misc.hook.patch.BaseHookPatchPatch compatiblePackages = [CompatiblePackage("com.twitter.android")] ) @Suppress("unused") -object HideRecommendedUsersPatch : BaseHookPatchPatch( +object HideRecommendedUsersPatch : BaseHookPatch( "Lapp/revanced/integrations/twitter/patches/hook/patch/recommendation/RecommendedUsersHook;" ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt index 06f89b1633..d7c3a359c1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsResourcePatch.kt @@ -3,9 +3,9 @@ package app.revanced.patches.youtube.ad.general import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch.PreferenceScreen @@ -14,7 +14,8 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch.PreferenceScreen dependencies = [ LithoFilterPatch::class, SettingsPatch::class, - ResourceMappingPatch::class + ResourceMappingPatch::class, + AddResourcesPatch::class ] ) object HideAdsResourcePatch : ResourcePatch() { @@ -24,61 +25,18 @@ object HideAdsResourcePatch : ResourcePatch() { internal var adAttributionId: Long = -1 override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + PreferenceScreen.ADS.addPreferences( - SwitchPreference( - "revanced_hide_general_ads", - StringResource("revanced_hide_general_ads_title", "Hide general ads"), - StringResource("revanced_hide_general_ads_summary_on", "General ads are hidden"), - StringResource("revanced_hide_general_ads_summary_off", "General ads are shown") - ), - SwitchPreference( - "revanced_hide_fullscreen_ads", - StringResource("revanced_hide_fullscreen_ads_title", "Hide fullscreen ads"), - StringResource("revanced_hide_fullscreen_ads_summary_on", "Fullscreen ads are hidden"), - StringResource("revanced_hide_fullscreen_ads_summary_off", "Fullscreen ads are shown") - ), - SwitchPreference( - "revanced_hide_buttoned_ads", - StringResource("revanced_hide_buttoned_ads_title", "Hide buttoned ad"), - StringResource("revanced_hide_buttoned_ads_summary_on", "Buttoned ads are hidden"), - StringResource("revanced_hide_buttoned_ads_summary_off", "Buttoned ads are shown") - ), - SwitchPreference( - "revanced_hide_paid_content_ads", - StringResource("revanced_hide_paid_content_ads_title", "Hide paid content"), - StringResource("revanced_hide_paid_content_ads_summary_on", "Paid content is hidden"), - StringResource("revanced_hide_paid_content_ads_summary_off", "Paid content is shown") - ), - SwitchPreference( - "revanced_hide_self_sponsor_ads", - StringResource("revanced_hide_self_sponsor_ads_title", "Hide self sponsored cards"), - StringResource("revanced_hide_self_sponsor_ads_summary_on", "Self sponsored cards are hidden"), - StringResource("revanced_hide_self_sponsor_ads_summary_off", "Self sponsored cards are shown") - ), - SwitchPreference( - "revanced_hide_products_banner", - StringResource("revanced_hide_products_banner_title", "Hide banner to view products"), - StringResource("revanced_hide_products_banner_summary_on", "Banner is hidden"), - StringResource("revanced_hide_products_banner_summary_off", "Banner is shown") - ), - SwitchPreference( - "revanced_hide_shopping_links", - StringResource("revanced_hide_shopping_links_title", "Hide shopping links in video description"), - StringResource("revanced_hide_shopping_links_summary_on", "Shopping links are hidden"), - StringResource("revanced_hide_shopping_links_summary_off", "Shopping links are shown") - ), - SwitchPreference( - "revanced_hide_web_search_results", - StringResource("revanced_hide_web_search_results_title", "Hide web search results"), - StringResource("revanced_hide_web_search_results_summary_on", "Web search results are hidden"), - StringResource("revanced_hide_web_search_results_summary_off", "Web search results are shown") - ), - SwitchPreference( - "revanced_hide_merchandise_banners", - StringResource("revanced_hide_merchandise_banners_title", "Hide merchandise banners"), - StringResource("revanced_hide_merchandise_banners_summary_on", "Merchandise banners are hidden"), - StringResource("revanced_hide_merchandise_banners_summary_off", "Merchandise banners are shown") - ) + SwitchPreference("revanced_hide_general_ads"), + SwitchPreference("revanced_hide_fullscreen_ads"), + SwitchPreference("revanced_hide_buttoned_ads"), + SwitchPreference("revanced_hide_paid_content_ads"), + SwitchPreference("revanced_hide_self_sponsor_ads"), + SwitchPreference("revanced_hide_products_banner"), + SwitchPreference("revanced_hide_shopping_links"), + SwitchPreference("revanced_hide_web_search_results"), + SwitchPreference("revanced_hide_merchandise_banners") ) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt index 377fe73691..3f59ad17da 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/HideGetPremiumPatch.kt @@ -1,22 +1,22 @@ package app.revanced.patches.youtube.ad.getpremium -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.ad.getpremium.fingerprints.GetPremiumViewFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @Patch( description = "Hides YouTube Premium signup promotions under the video player.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -40,23 +40,9 @@ object HideGetPremiumPatch : BytecodePatch(setOf(GetPremiumViewFingerprint)) { "Lapp/revanced/integrations/youtube/patches/HideGetPremiumPatch;" override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.ADS.addPreferences( - SwitchPreference( - "revanced_hide_get_premium", - StringResource( - "revanced_hide_get_premium_title", - "Hide YouTube Premium promotions" - ), - StringResource( - "revanced_hide_get_premium_summary_on", - "YouTube Premium promotions under video player are hidden" - ), - StringResource( - "revanced_hide_get_premium_summary_off", - "YouTube Premium promotions under video player are shown" - ) - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.ADS.addPreferences(SwitchPreference("revanced_hide_get_premium")) GetPremiumViewFingerprint.result?.let { it.mutableMethod.apply { diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt index 0d64c05a1c..81215d6198 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/VideoAdsPatch.kt @@ -7,8 +7,8 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.ad.video.fingerprints.LoadVideoAdsFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch @@ -18,7 +18,8 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch description = "Adds an option to remove ads in the video player.", dependencies = [ IntegrationsPatch::class, - SettingsPatch::class + SettingsPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -44,14 +45,9 @@ object VideoAdsPatch : BytecodePatch( setOf(LoadVideoAdsFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.ADS.addPreferences( - SwitchPreference( - "revanced_hide_video_ads", - StringResource("revanced_hide_video_ads_title", "Hide video ads"), - StringResource("revanced_hide_video_ads_summary_on", "Video ads are hidden"), - StringResource("revanced_hide_video_ads_summary_off", "Video ads are shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.ADS.addPreferences(SwitchPreference("revanced_hide_video_ads")) val loadVideoAdsFingerprintMethod = LoadVideoAdsFingerprint.result!!.mutableMethod diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt index d98b271c90..83a4456828 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/copyvideourl/CopyVideoUrlResourcePatch.kt @@ -4,51 +4,30 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.playercontrols.BottomControlsResourcePatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.ResourceGroup import app.revanced.util.copyResources -import app.revanced.util.copyStrings -import app.revanced.util.resource.StringResource @Patch( dependencies = [ SettingsPatch::class, BottomControlsResourcePatch::class, - AddResourcesPatch::class, + AddResourcesPatch::class ] ) internal object CopyVideoUrlResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( PreferenceScreen( "revanced_copy_video_url_preference_screen", - StringResource("revanced_copy_video_url_preference_screen_title", "Copy video URL settings"), - listOf( - SwitchPreference( - "revanced_copy_video_url", - StringResource("revanced_copy_video_url_title", "Show copy video URL button"), - StringResource( - "revanced_copy_video_url_summary_on", - "Button is shown. Tap to copy video URL. Tap and hold to copy video URL with timestamp" - ), - StringResource("revanced_copy_video_url_summary_off", "Button is not shown") - ), - SwitchPreference( - "revanced_copy_video_url_timestamp", - StringResource("revanced_copy_video_url_timestamp_title", "Show copy timestamp URL button"), - StringResource( - "revanced_copy_video_url_timestamp_summary_on", - "Button is shown. Tap to copy video URL with timestamp. Tap and hold to copy video without timestamp" - ), - StringResource("revanced_copy_video_url_timestamp_summary_off", "Button is not shown") - ) - ), - StringResource( - "revanced_copy_video_url_preference_screen_summary", - "Settings related to copy URL buttons in video player" + preferences = setOf( + SwitchPreference("revanced_copy_video_url"), + SwitchPreference("revanced_copy_video_url_timestamp") ) ) ) @@ -61,7 +40,7 @@ internal object CopyVideoUrlResourcePatch : ResourcePatch() { ) ) - context.copyStrings("copyvideourl/host/values/strings.xml") + AddResourcesPatch(this::class) BottomControlsResourcePatch.addControls("copyvideourl") } diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt index 62b656e784..df6d45a48f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/dialog/RemoveViewerDiscretionDialogPatch.kt @@ -6,8 +6,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.interaction.dialog.fingerprints.CreateDialogFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch @@ -18,7 +18,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction name = "Remove viewer discretion dialog", description = "Adds an option to remove the dialog that appears when opening a video that has been age-restricted " + "by accepting it automatically. This does not bypass the age restriction.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -46,27 +46,9 @@ object RemoveViewerDiscretionDialogPatch : BytecodePatch( "confirmDialog(Landroid/app/AlertDialog;)V" override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( - SwitchPreference( - "revanced_remove_viewer_discretion_dialog", - StringResource( - "revanced_remove_viewer_discretion_dialog_title", - "Remove viewer discretion dialog" - ), - StringResource( - "revanced_remove_viewer_discretion_dialog_summary_on", - "Dialog will be removed" - ), - StringResource( - "revanced_remove_viewer_discretion_dialog_summary_off", - "Dialog will be shown" - ), - StringResource( - "revanced_remove_viewer_discretion_dialog_user_dialog_message", - "This does not bypass the age restriction. It just accepts it automatically." - ) - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(SwitchPreference("revanced_remove_viewer_discretion_dialog")) CreateDialogFingerprint.result?.mutableMethod?.apply { val showDialogIndex = implementation!!.instructions.lastIndex - 2 diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt index 3bba3c1c93..656eb13de6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/downloads/ExternalDownloadsResourcePatch.kt @@ -4,60 +4,36 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.settings.preference.impl.InputType -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference -import app.revanced.patches.shared.settings.preference.impl.TextPreference +import app.revanced.patches.shared.misc.settings.preference.InputType +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference +import app.revanced.patches.shared.misc.settings.preference.TextPreference import app.revanced.patches.youtube.misc.playercontrols.BottomControlsResourcePatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.ResourceGroup import app.revanced.util.copyResources -import app.revanced.util.copyStrings -import app.revanced.util.resource.StringResource @Patch( dependencies = [ BottomControlsResourcePatch::class, SettingsPatch::class, - AddResourcesPatch::class + AddResourcesPatch::class, ] ) internal object ExternalDownloadsResourcePatch : ResourcePatch() { - override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( PreferenceScreen( "revanced_external_downloader_preference_screen", - StringResource("revanced_external_downloader_preference_screen_title", "External download settings"), - listOf( - SwitchPreference( - "revanced_external_downloader", - StringResource("revanced_external_downloader_title", "Show external download button"), - StringResource("revanced_external_downloader_summary_on", "Download button shown in player"), - StringResource( - "revanced_external_downloader_summary_off", - "Download button not shown in player" - ) - ), - TextPreference( - "revanced_external_downloader_name", - StringResource("revanced_external_downloader_name_title", "Downloader package name"), - StringResource( - "revanced_external_downloader_name_summary", - "Package name of your installed external downloader app, such as NewPipe or Seal" - ), - InputType.TEXT - ) + preferences = setOf( + SwitchPreference("revanced_external_downloader"), + TextPreference("revanced_external_downloader_name", inputType = InputType.TEXT) ), - StringResource( - "revanced_external_downloader_preference_screen_summary", - "Settings for using an external downloader" - ) ) ) - context.copyStrings("downloads/host/values/strings.xml") - context.copyResources( "downloads", ResourceGroup("drawable", "revanced_yt_download_button.xml") diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt index d3640fc431..b7b43d86ba 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt @@ -1,23 +1,23 @@ package app.revanced.patches.youtube.interaction.seekbar -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.interaction.seekbar.fingerprints.IsSwipingUpFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction @Patch( name = "Disable precise seeking gesture", description = "Adds an option to disable precise seeking when swiping up on the seekbar.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", @@ -46,13 +46,10 @@ object DisablePreciseSeekingGesturePatch : BytecodePatch( "disableGesture(Landroid/view/VelocityTracker;Landroid/view/MotionEvent;)V" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( - SwitchPreference( - "revanced_disable_precise_seeking_gesture", - StringResource("revanced_disable_precise_seeking_gesture_title", "Disable precise seeking gesture"), - StringResource("revanced_disable_precise_seeking_gesture_summary_on", "Gesture is disabled"), - StringResource("revanced_disable_precise_seeking_gesture_summary_off", "Gesture is enabled"), - ) + SwitchPreference("revanced_disable_precise_seeking_gesture") ) IsSwipingUpFingerprint.result?.let { diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt index c677676c72..86bc196732 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSeekbarTappingPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.interaction.seekbar -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -8,12 +7,13 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.interaction.seekbar.fingerprints.OnTouchEventHandlerFingerprint import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c import com.android.tools.smali.dexlib2.iface.reference.MethodReference @@ -22,7 +22,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference name = "Seekbar tapping", description = "Adds an option to enable tap-to-seek on the seekbar of the video player.", dependencies = [ - IntegrationsPatch::class, SettingsPatch::class], + IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", @@ -47,14 +47,9 @@ object EnableSeekbarTappingPatch : BytecodePatch( ) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( - SwitchPreference( - "revanced_seekbar_tapping", - StringResource("revanced_seekbar_tapping_title", "Enable seekbar tapping"), - StringResource("revanced_seekbar_tapping_summary_on", "Seekbar tapping is enabled"), - StringResource("revanced_seekbar_tapping_summary_off", "Seekbar tapping is disabled") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(SwitchPreference("revanced_seekbar_tapping")) // Find the required methods to tap the seekbar. val seekbarTappingMethods = OnTouchEventHandlerFingerprint.result?.let { diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt index 9cd019209b..cc95388a00 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt @@ -1,24 +1,24 @@ package app.revanced.patches.youtube.interaction.seekbar -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.interaction.seekbar.fingerprints.DoubleSpeedSeekNoticeFingerprint import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SlideToSeekFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( name = "Enable slide to seek", description = "Adds an option to enable slide to seek instead of playing at 2x speed when pressing and holding in the video player. Including this patch may cause issues with tapping or double tapping the video player overlay.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", @@ -46,23 +46,9 @@ object EnableSlideToSeekPatch : BytecodePatch( private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/SlideToSeekPatch;" override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( - SwitchPreference( - "revanced_slide_to_seek", - StringResource( - "revanced_slide_to_seek_title", - "Enable slide to seek" - ), - StringResource( - "revanced_slide_to_seek_summary_on", - "Slide to seek is enabled" - ), - StringResource( - "revanced_slide_to_seek_summary_off", - "Slide to seek is not enabled" - ), - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(SwitchPreference("revanced_slide_to_seek")) arrayOf( // Restore the behaviour to slide to seek. diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt index eb7949fd44..de61545681 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsResourcePatch.kt @@ -3,93 +3,36 @@ package app.revanced.patches.youtube.interaction.swipecontrols import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.* +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.InputType +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference +import app.revanced.patches.shared.misc.settings.preference.TextPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.ResourceGroup import app.revanced.util.copyResources @Patch( - dependencies = [SettingsPatch::class] + dependencies = [SettingsPatch::class, AddResourcesPatch::class] ) internal object SwipeControlsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( PreferenceScreen( - "revanced_swipe_controls_preference_screen", - StringResource("revanced_swipe_controls_preference_screen_title", "Swipe controls"), - listOf( - SwitchPreference( - "revanced_swipe_brightness", - StringResource("revanced_swipe_brightness_title", "Enable brightness gesture"), - StringResource("revanced_swipe_brightness_summary_on", "Brightness swipe is enabled"), - StringResource("revanced_swipe_brightness_summary_off", "Brightness swipe is disabled") - ), - SwitchPreference( - "revanced_swipe_volume", - StringResource("revanced_swipe_volume_title", "Enable volume gesture"), - StringResource("revanced_swipe_volume_summary_on", "Volume swipe is enabled"), - StringResource("revanced_swipe_volume_summary_off", "Volume swipe is disabled") - ), - SwitchPreference( - "revanced_swipe_press_to_engage", - StringResource("revanced_swipe_press_to_engage_title", "Enable press-to-swipe gesture"), - StringResource("revanced_swipe_press_to_engage_summary_on", "Press-to-swipe is enabled"), - StringResource("revanced_swipe_press_to_engage_summary_off", "Press-to-swipe is disabled") - ), - SwitchPreference( - "revanced_swipe_haptic_feedback", - StringResource("revanced_swipe_haptic_feedback_title", "Enable haptic feedback"), - StringResource("revanced_swipe_haptic_feedback_summary_on", "Haptic feedback is enabled"), - StringResource("revanced_swipe_haptic_feedback_summary_off", "Haptic feedback is disabled") - ), - SwitchPreference( - "revanced_swipe_save_and_restore_brightness", - StringResource("revanced_swipe_save_and_restore_brightness_title", "Save and restore brightness"), - StringResource( - "revanced_swipe_save_and_restore_brightness_summary_on", - "Save and restore brightness when exiting or entering fullscreen" - ), - StringResource( - "revanced_swipe_save_and_restore_brightness_summary_off", - "Do not save and restore brightness when exiting or entering fullscreen" - ) - ), - TextPreference( - "revanced_swipe_overlay_timeout", - StringResource("revanced_swipe_overlay_timeout_title", "Swipe overlay timeout"), - StringResource( - "revanced_swipe_overlay_timeout_summary", - "The amount of milliseconds the overlay is visible" - ), - InputType.NUMBER - ), - TextPreference( - "revanced_swipe_text_overlay_size", - StringResource("revanced_swipe_text_overlay_size_title", "Swipe overlay text size"), - StringResource("revanced_swipe_text_overlay_size_summary", "The text size for swipe overlay"), - InputType.NUMBER - ), - TextPreference( - "revanced_swipe_overlay_background_alpha", - StringResource("revanced_swipe_overlay_background_alpha_title", "Swipe background visibility"), - StringResource( - "revanced_swipe_overlay_background_alpha_summary", - "The visibility of swipe overlay background" - ), - InputType.NUMBER - ), - TextPreference( - "revanced_swipe_threshold", - StringResource("revanced_swipe_threshold_title", "Swipe magnitude threshold"), - StringResource( - "revanced_swipe_threshold_summary", - "The amount of threshold for swipe to occur" - ), - InputType.NUMBER - ) + key = "revanced_swipe_controls_preference_screen", + preferences = setOf( + SwitchPreference("revanced_swipe_brightness"), + SwitchPreference("revanced_swipe_volume"), + SwitchPreference("revanced_swipe_press_to_engage"), + SwitchPreference("revanced_swipe_haptic_feedback"), + SwitchPreference("revanced_swipe_save_and_restore_brightness"), + TextPreference("revanced_swipe_overlay_timeout", inputType = InputType.NUMBER), + TextPreference("revanced_swipe_text_overlay_size", inputType = InputType.NUMBER), + TextPreference("revanced_swipe_overlay_background_alpha", inputType = InputType.NUMBER), + TextPreference("revanced_swipe_threshold", inputType = InputType.NUMBER) ), - StringResource("revanced_swipe_controls_preference_screen_summary","Control volume and brightness") ) ) @@ -97,10 +40,10 @@ internal object SwipeControlsResourcePatch : ResourcePatch() { "swipecontrols", ResourceGroup( "drawable", - "ic_sc_brightness_auto.xml", - "ic_sc_brightness_manual.xml", - "ic_sc_volume_mute.xml", - "ic_sc_volume_normal.xml" + "revanced_ic_sc_brightness_auto.xml", + "revanced_ic_sc_brightness_manual.xml", + "revanced_ic_sc_volume_mute.xml", + "revanced_ic_sc_volume_normal.xml" ) ) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt index 40b01955f7..d5a77124a9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt @@ -1,25 +1,25 @@ package app.revanced.patches.youtube.layout.autocaptions -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.autocaptions.fingerprints.StartVideoInformerFingerprint import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleButtonControllerFingerprint import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleTrackFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Disable auto captions", description = "Adds an option to disable captions from being automatically enabled.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", @@ -44,14 +44,9 @@ object AutoCaptionsPatch : BytecodePatch( setOf(StartVideoInformerFingerprint, SubtitleButtonControllerFingerprint, SubtitleTrackFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_auto_captions", - StringResource("revanced_auto_captions_title", "Disable auto captions"), - StringResource("revanced_auto_captions_summary_on", "Auto captions are disabled"), - StringResource("revanced_auto_captions_summary_off", "Auto captions are enabled") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_auto_captions")) mapOf( StartVideoInformerFingerprint to 0, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt index 86c78106af..928f3d7a1f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/action/HideButtonsPatch.kt @@ -4,10 +4,10 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch @@ -16,7 +16,8 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch description = "Adds options to hide action buttons (such as the Download button) under videos.", dependencies = [ ResourceMappingPatch::class, - LithoFilterPatch::class + LithoFilterPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -43,73 +44,23 @@ object HideButtonsPatch : ResourcePatch() { "Lapp/revanced/integrations/youtube/patches/components/ButtonsFilter;" override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( PreferenceScreen( "revanced_hide_buttons_preference_screen", - StringResource("revanced_hide_buttons_preference_screen_title", "Hide action buttons"), - listOf( - SwitchPreference( - "revanced_hide_like_dislike_button", - StringResource("revanced_hide_like_dislike_button_title", "Hide like and dislike buttons"), - StringResource("revanced_hide_like_dislike_button_summary_on", "Like and dislike buttons are hidden"), - StringResource("revanced_hide_like_dislike_button_summary_off", "Like and dislike buttons are shown") - ), - SwitchPreference( - "revanced_hide_live_chat_button", - StringResource("revanced_hide_live_chat_button_title", "Hide live chat button"), - StringResource("revanced_hide_live_chat_button_summary_on", "Live chat button is hidden"), - StringResource("revanced_hide_live_chat_button_summary_off", "Live chat button is shown") - ), - SwitchPreference( - "revanced_hide_share_button", - StringResource("revanced_hide_share_button_title", "Hide share button"), - StringResource("revanced_hide_share_button_summary_on", "Share button is hidden"), - StringResource("revanced_hide_share_button_summary_off", "Share button is shown") - ), - SwitchPreference( - "revanced_hide_report_button", - StringResource("revanced_hide_report_button_title", "Hide report button"), - StringResource("revanced_hide_report_button_summary_on", "Report button is hidden"), - StringResource("revanced_hide_report_button_summary_off", "Report button is shown") - ), - SwitchPreference( - "revanced_hide_remix_button", - StringResource("revanced_hide_remix_button_title", "Hide remix button"), - StringResource("revanced_hide_remix_button_summary_on", "Remix button is hidden"), - StringResource("revanced_hide_remix_button_summary_off", "Remix button is shown") - ), - SwitchPreference( - "revanced_hide_download_button", - StringResource("revanced_hide_download_button_title", "Hide download button"), - StringResource("revanced_hide_download_button_summary_on", "Download button is hidden"), - StringResource("revanced_hide_download_button_summary_off", "Download button is shown") - ), - SwitchPreference( - "revanced_hide_thanks_button", - StringResource("revanced_hide_thanks_button_title", "Hide thanks button"), - StringResource("revanced_hide_thanks_button_summary_on", "Thanks button is hidden"), - StringResource("revanced_hide_thanks_button_summary_off", "Thanks button is shown") - ), - SwitchPreference( - "revanced_hide_clip_button", - StringResource("revanced_hide_clip_button_title", "Hide clip button"), - StringResource("revanced_hide_clip_button_summary_on", "Clip button is hidden"), - StringResource("revanced_hide_clip_button_summary_off", "Clip button is shown"), - ), - SwitchPreference( - "revanced_hide_playlist_button", - StringResource("revanced_hide_playlist_button_title", "Hide save to playlist button"), - StringResource("revanced_hide_playlist_button_summary_on", "Save button is hidden"), - StringResource("revanced_hide_playlist_button_summary_off", "Save button is shown") - ), - SwitchPreference( - "revanced_hide_shop_button", - StringResource("revanced_hide_shop_button_title", "Hide shop button"), - StringResource("revanced_hide_shop_button_summary_on", "Shop button is hidden"), - StringResource("revanced_hide_shop_button_summary_off", "Shop button is shown") - ) + preferences = setOf( + SwitchPreference("revanced_hide_like_dislike_button"), + SwitchPreference("revanced_hide_live_chat_button"), + SwitchPreference("revanced_hide_share_button"), + SwitchPreference("revanced_hide_report_button"), + SwitchPreference("revanced_hide_remix_button"), + SwitchPreference("revanced_hide_download_button"), + SwitchPreference("revanced_hide_thanks_button"), + SwitchPreference("revanced_hide_clip_button"), + SwitchPreference("revanced_hide_playlist_button"), + SwitchPreference("revanced_hide_shop_button") ), - StringResource("revanced_hide_buttons_preference_screen_summary", "Hide or show buttons under videos") ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt index 9414f2f8f5..676eb5365a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt @@ -1,7 +1,5 @@ package app.revanced.patches.youtube.layout.buttons.autoplay -import app.revanced.util.exception -import app.revanced.util.findIndexForIdResource import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -9,12 +7,14 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.shared.fingerprints.LayoutConstructorFingerprint +import app.revanced.util.exception +import app.revanced.util.findIndexForIdResource import com.android.tools.smali.dexlib2.iface.instruction.Instruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction @@ -26,7 +26,8 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference dependencies = [ IntegrationsPatch::class, SettingsPatch::class, - ResourceMappingPatch::class + ResourceMappingPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -52,14 +53,9 @@ object HideAutoplayButtonPatch : BytecodePatch( setOf(LayoutConstructorFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_autoplay_button", - StringResource("revanced_hide_autoplay_button_title", "Hide autoplay button"), - StringResource("revanced_hide_autoplay_button_summary_on", "Autoplay button is hidden"), - StringResource("revanced_hide_autoplay_button_summary_off", "Autoplay button is shown") - ), - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_autoplay_button")) LayoutConstructorFingerprint.result?.mutableMethod?.apply { val layoutGenMethodInstructions = implementation!!.instructions diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt index 7867e6afea..60e4d51b75 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleButtonControllerFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch @@ -17,7 +17,8 @@ import com.android.tools.smali.dexlib2.Opcode description = "Adds an option to hide the captions button in the video player.", dependencies = [ IntegrationsPatch::class, - SettingsPatch::class + SettingsPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -43,14 +44,9 @@ object HideCaptionsButtonPatch : BytecodePatch( setOf(SubtitleButtonControllerFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_captions_button", - StringResource("revanced_hide_captions_button_title", "Hide captions button"), - StringResource("revanced_hide_captions_button_summary_on", "Captions button is hidden"), - StringResource("revanced_hide_captions_button_summary_off", "Captions button is shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_captions_button")) val subtitleButtonControllerMethod = SubtitleButtonControllerFingerprint.result!!.mutableMethod diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt index b5f6255962..ee1f6943a6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt @@ -6,8 +6,8 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch @@ -16,7 +16,8 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch description = "Adds an option to hide the cast button in the video player.", dependencies = [ IntegrationsPatch::class, - SettingsPatch::class + SettingsPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage("com.google.android.youtube") @@ -24,14 +25,9 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch ) object HideCastButtonPatch : BytecodePatch() { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_cast_button", - StringResource("revanced_hide_cast_button_title", "Hide cast button"), - StringResource("revanced_hide_cast_button_summary_on", "Cast button is hidden"), - StringResource("revanced_hide_cast_button_summary_off", "Cast button is shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_cast_button")) val buttonClass = context.findClass("MediaRouteButton") ?: throw PatchException("MediaRouteButton class not found.") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt index 3b2de83f6d..de6304792a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/NavigationButtonsPatch.kt @@ -1,20 +1,20 @@ package app.revanced.patches.youtube.layout.buttons.navigation -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.* import app.revanced.patches.youtube.layout.buttons.navigation.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT import app.revanced.patches.youtube.layout.buttons.navigation.utils.InjectionUtils.injectHook import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( @@ -23,7 +23,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction dependencies = [ IntegrationsPatch::class, SettingsPatch::class, - ResolvePivotBarFingerprintsPatch::class + ResolvePivotBarFingerprintsPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -52,58 +53,18 @@ object NavigationButtonsPatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/NavigationButtonsPatch;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( PreferenceScreen( - "revanced_navigation_buttons_preference_screen", - StringResource("revanced_navigation_buttons_preference_screen_title", "Navigation buttons"), - listOf( - SwitchPreference( - "revanced_hide_home_button", - StringResource("revanced_hide_home_button_title", "Hide home button"), - StringResource("revanced_hide_home_button_summary_on", "Home button is hidden"), - StringResource("revanced_hide_home_button_summary_off", "Home button is shown") - ), - SwitchPreference( - "revanced_hide_shorts_button", - StringResource("revanced_hide_shorts_button_title", "Hide Shorts button"), - StringResource("revanced_hide_shorts_button_summary_on", "Shorts button is hidden"), - StringResource("revanced_hide_shorts_button_summary_off", "Shorts button is shown") - ), - SwitchPreference( - "revanced_hide_subscriptions_button", - StringResource("revanced_hide_subscriptions_button_title", "Hide subscriptions button"), - StringResource( - "revanced_hide_subscriptions_button_summary_on", - "Home subscriptions is hidden" - ), - StringResource("revanced_hide_subscriptions_button_summary_off", "Home subscriptions is shown") - ), - SwitchPreference( - "revanced_hide_create_button", - StringResource("revanced_hide_create_button_title", "Hide create button"), - StringResource("revanced_hide_create_button_summary_on", "Create button is hidden"), - StringResource("revanced_hide_create_button_summary_off", "Create button is shown") - ), - SwitchPreference( - "revanced_switch_create_with_notifications_button", - StringResource( - "revanced_switch_create_with_notifications_button_title", - "Switch create with notifications button" - ), - StringResource( - "revanced_switch_create_with_notifications_button_summary_on", - "Create button is switched with notifications" - ), - StringResource( - "revanced_switch_create_with_notifications_button_summary_off", - "Create button is not switched with notifications" - ), - ), + key = "revanced_navigation_buttons_preference_screen", + preferences = setOf( + SwitchPreference("revanced_hide_home_button"), + SwitchPreference("revanced_hide_shorts_button"), + SwitchPreference("revanced_hide_subscriptions_button"), + SwitchPreference("revanced_hide_create_button"), + SwitchPreference("revanced_switch_create_with_notifications_button"), ), - StringResource( - "revanced_navigation_buttons_preference_screen_summary", - "Hide or change buttons in the navigation bar" - ) ) ) @@ -156,8 +117,8 @@ object NavigationButtonsPatch : BytecodePatch( AddCreateButtonViewFingerprint.result?.let { it.mutableMethod.apply { - val stringIndex = it.scanResult.stringsScanResult!!.matches.find { - match -> match.string == ANDROID_AUTOMOTIVE_STRING + val stringIndex = it.scanResult.stringsScanResult!!.matches.find { match -> + match.string == ANDROID_AUTOMOTIVE_STRING }!!.index val conditionalCheckIndex = stringIndex - 1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/ResolvePivotBarFingerprintsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/ResolvePivotBarFingerprintsPatch.kt index 393f65a8a0..eacab72b45 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/ResolvePivotBarFingerprintsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/ResolvePivotBarFingerprintsPatch.kt @@ -5,7 +5,7 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.InitializeButtonsFingerprint import app.revanced.patches.youtube.layout.buttons.navigation.fingerprints.PivotBarConstructorFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt index 2d97008dc4..70b040a47c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt @@ -1,19 +1,19 @@ package app.revanced.patches.youtube.layout.buttons.player.hide -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.buttons.player.hide.HidePlayerButtonsPatch.ParameterOffsets.HAS_NEXT import app.revanced.patches.youtube.layout.buttons.player.hide.HidePlayerButtonsPatch.ParameterOffsets.HAS_PREVIOUS import app.revanced.patches.youtube.layout.buttons.player.hide.fingerprints.PlayerControlsVisibilityModelFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction3rc @Patch( @@ -21,7 +21,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction3rc description = "Adds an option to hide the previous and next buttons in the video player.", dependencies = [ IntegrationsPatch::class, - SettingsPatch::class + SettingsPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -47,23 +48,9 @@ object HidePlayerButtonsPatch : BytecodePatch( setOf(PlayerControlsVisibilityModelFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_player_buttons", - StringResource( - "revanced_hide_player_buttons_title", - "Hide previous & next video buttons" - ), - StringResource( - "revanced_hide_player_buttons_summary_on", - "Buttons are hidden" - ), - StringResource( - "revanced_hide_player_buttons_summary_off", - "Buttons are shown" - ) - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_player_buttons")) PlayerControlsVisibilityModelFingerprint.result?.apply { val callIndex = scanResult.patternScanResult!!.endIndex diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt index 515fa98ba3..e05b3e8b61 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/AlbumCardsResourcePatch.kt @@ -3,29 +3,25 @@ package app.revanced.patches.youtube.layout.hide.albumcards import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( dependencies = [ SettingsPatch::class, - ResourceMappingPatch::class + ResourceMappingPatch::class, + AddResourcesPatch::class ], ) internal object AlbumCardsResourcePatch : ResourcePatch() { internal var albumCardId: Long = -1 override fun execute(context: ResourceContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_album_cards", - StringResource("revanced_hide_album_cards_title", "Hide album cards"), - StringResource("revanced_hide_album_cards_summary_on", "Album cards are hidden"), - StringResource("revanced_hide_album_cards_summary_off", "Album cards are shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_album_cards")) albumCardId = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "album_card" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt index 22cc5a2977..31fb0b4a56 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsResourcePatch.kt @@ -3,29 +3,25 @@ package app.revanced.patches.youtube.layout.hide.breakingnews import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( dependencies = [ SettingsPatch::class, - ResourceMappingPatch::class + ResourceMappingPatch::class, + AddResourcesPatch::class ], ) internal object BreakingNewsResourcePatch : ResourcePatch() { internal var horizontalCardListId: Long = -1 override fun execute(context: ResourceContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_breaking_news", - StringResource("revanced_hide_breaking_news_title", "Hide breaking news"), - StringResource("revanced_hide_breaking_news_summary_on", "Breaking news are hidden"), - StringResource("revanced_hide_breaking_news_summary_off", "Breaking news are shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_breaking_news")) horizontalCardListId = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "horizontal_card_list" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt index 199bcc86e1..8e4c891c80 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/comments/CommentsPatch.kt @@ -4,9 +4,9 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch @@ -15,7 +15,8 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch description = "Adds options to hide components related to comments.", dependencies = [ SettingsPatch::class, - LithoFilterPatch::class + LithoFilterPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -42,28 +43,18 @@ object CommentsPatch : ResourcePatch() { "Lapp/revanced/integrations/youtube/patches/components/CommentsFilter;" override fun execute(context: ResourceContext) { - LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) - + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( PreferenceScreen( "revanced_comments_preference_screen", - StringResource("revanced_comments_preference_screen_title", "Comments"), - listOf( - SwitchPreference( - "revanced_hide_comments_section", - StringResource("revanced_hide_comments_section_title", "Hide comments section"), - StringResource("revanced_hide_comments_section_summary_on", "Comment section is hidden"), - StringResource("revanced_hide_comments_section_summary_off", "Comment section is shown") - ), - SwitchPreference( - "revanced_hide_preview_comment", - StringResource("revanced_hide_preview_comment_title", "Hide preview comment"), - StringResource("revanced_hide_preview_comment_on", "Preview comment is hidden"), - StringResource("revanced_hide_preview_comment_off", "Preview comment is shown") - ) - ), - StringResource("revanced_comments_preference_screen_summary", "Manage the visibility of comments section components") + preferences = setOf( + SwitchPreference("revanced_hide_comments_section"), + SwitchPreference("revanced_hide_preview_comment") + ) ) ) + + LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt index a57ae52c80..0ce74f7f02 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/CrowdfundingBoxResourcePatch.kt @@ -3,29 +3,25 @@ package app.revanced.patches.youtube.layout.hide.crowdfundingbox import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( dependencies = [ SettingsPatch::class, - ResourceMappingPatch::class + ResourceMappingPatch::class, + AddResourcesPatch::class ], ) internal object CrowdfundingBoxResourcePatch : ResourcePatch() { internal var crowdfundingBoxId: Long = -1 override fun execute(context: ResourceContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_crowdfunding_box", - StringResource("revanced_hide_crowdfunding_box_title", "Hide crowdfunding box"), - StringResource("revanced_hide_crowdfunding_box_summary_on", "Crowdfunding box is hidden"), - StringResource("revanced_hide_crowdfunding_box_summary_off", "Crowdfunding box is shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_crowdfunding_box")) crowdfundingBoxId = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "donation_companion" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt index 715daed4cd..6f601391ef 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/HideEndscreenCardsResourcePatch.kt @@ -3,15 +3,16 @@ package app.revanced.patches.youtube.layout.hide.endscreencards import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( dependencies = [ SettingsPatch::class, - ResourceMappingPatch::class + ResourceMappingPatch::class, + AddResourcesPatch::class ], ) internal object HideEndscreenCardsResourcePatch : ResourcePatch() { @@ -20,14 +21,9 @@ internal object HideEndscreenCardsResourcePatch : ResourcePatch() { internal var layoutVideo: Long = -1 override fun execute(context: ResourceContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_endscreen_cards", - StringResource("revanced_hide_endscreen_cards_title", "Hide end screen cards"), - StringResource("revanced_hide_endscreen_cards_summary_on", "End screen cards are hidden"), - StringResource("revanced_hide_endscreen_cards_summary_off", "End screen cards are shown") - ), - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_endscreen_cards")) fun findEndscreenResourceId(name: String) = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "endscreen_element_layout_$name" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt index ffb56b14fb..70ef188f5a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/HideFilterBarResourcePatch.kt @@ -3,76 +3,28 @@ package app.revanced.patches.youtube.layout.hide.filterbar import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch -@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class]) +@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class]) internal object HideFilterBarResourcePatch : ResourcePatch() { internal var filterBarHeightId = -1L internal var relatedChipCloudMarginId = -1L internal var barContainerHeightId = -1L override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( PreferenceScreen( - "revanced_hide_filter_bar_preference", - StringResource( - "revanced_hide_filter_bar_preference_title", - "Hide filter bar" - ), - listOf( - SwitchPreference( - "revanced_hide_filter_bar_feed_in_feed", - StringResource( - "revanced_hide_filter_bar_feed_in_feed_title", - "Hide in feed" - ), - StringResource( - "revanced_hide_filter_bar_feed_in_feed_summary_on", - "Hidden in feed" - ), - StringResource( - "revanced_hide_filter_bar_feed_in_feed_summary_off", - "Shown in feed" - ) - ), - SwitchPreference( - "revanced_hide_filter_bar_feed_in_search", - StringResource( - "revanced_hide_filter_bar_feed_in_search_title", - "Hide in search" - ), - StringResource( - "revanced_hide_filter_bar_feed_in_search_summary_on", - "Hidden in search" - ), - StringResource( - "revanced_hide_filter_bar_feed_in_search_summary_off", - "Shown in search" - ) - ), - SwitchPreference( - "revanced_hide_filter_bar_feed_in_related_videos", - StringResource( - "revanced_hide_filter_bar_feed_in_related_videos_title", - "Hide in related videos" - ), - StringResource( - "revanced_hide_filter_bar_feed_in_related_videos_summary_on", - "Hidden in related videos" - ), - StringResource( - "revanced_hide_filter_bar_feed_in_related_videos_summary_off", - "Shown in related videos" - ) - ), - ), - StringResource( - "revanced_hide_filter_bar_preference_summary", - "Manage the visibility of the filter bar in the feed, search and related videos" + key = "revanced_hide_filter_bar_preference", + preferences = setOf( + SwitchPreference("revanced_hide_filter_bar_feed_in_feed"), + SwitchPreference("revanced_hide_filter_bar_feed_in_search"), + SwitchPreference("revanced_hide_filter_bar_feed_in_related_videos"), ) ) ) @@ -82,6 +34,6 @@ internal object HideFilterBarResourcePatch : ResourcePatch() { barContainerHeightId = "bar_container_height".layoutResourceId() } - private fun String.layoutResourceId(type: String = "dimen") = - ResourceMappingPatch.resourceMappings.single { it.type == type && it.name == this }.id + private fun String.layoutResourceId(type: String = "dimen") = + ResourceMappingPatch.resourceMappings.single { it.type == type && it.name == this }.id } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt index 27d72c154e..92f8f42347 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/HideFloatingMicrophoneButtonResourcePatch.kt @@ -4,32 +4,25 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( dependencies = [ SettingsPatch::class, - ResourceMappingPatch::class + ResourceMappingPatch::class, + AddResourcesPatch::class ] ) internal object HideFloatingMicrophoneButtonResourcePatch : ResourcePatch() { internal var fabButtonId: Long = -1 override fun execute(context: ResourceContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_floating_microphone_button", - StringResource( - "revanced_hide_floating_microphone_button_enabled_title", - "Hide floating microphone button" - ), - StringResource("revanced_hide_floating_microphone_button_summary_on", "Microphone button hidden"), - StringResource("revanced_hide_floating_microphone_button_summary_off", "Microphone button shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_floating_microphone_button")) fabButtonId = ResourceMappingPatch.resourceMappings.find { it.type == "id" && it.name == "fab" }?.id ?: throw PatchException("Can not find required fab button resource id") diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt index 4f18f790cf..421b123498 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/fullscreenambientmode/DisableFullscreenAmbientModePatch.kt @@ -1,21 +1,21 @@ package app.revanced.patches.youtube.layout.hide.fullscreenambientmode -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.hide.fullscreenambientmode.fingerprints.InitializeAmbientModeFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Disable fullscreen ambient mode", description = "Adds an option to disable the ambient mode when in fullscreen.", - dependencies = [SettingsPatch::class, IntegrationsPatch::class], + dependencies = [SettingsPatch::class, IntegrationsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -41,22 +41,10 @@ object DisableFullscreenAmbientModePatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/DisableFullscreenAmbientModePatch;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_disable_fullscreen_ambient_mode", - StringResource( - "revanced_disable_fullscreen_ambient_mode_title", - "Disable ambient mode in fullscreen" - ), - StringResource( - "revanced_disable_fullscreen_ambient_mode_summary_on", - "Ambient mode disabled" - ), - StringResource( - "revanced_disable_fullscreen_ambient_mode_summary_off", - "Ambient mode enabled" - ), - ) + SwitchPreference("revanced_disable_fullscreen_ambient_mode") ) InitializeAmbientModeFingerprint.result?.let { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index 1f4dd94c0e..5d8c261a50 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -10,8 +10,10 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.* +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.InputType +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference +import app.revanced.patches.shared.misc.settings.preference.TextPreference import app.revanced.patches.youtube.layout.hide.general.fingerprints.ParseElementFromBufferFingerprint import app.revanced.patches.youtube.layout.hide.general.fingerprints.PlayerOverlayFingerprint import app.revanced.patches.youtube.layout.hide.general.fingerprints.ShowWatermarkFingerprint @@ -28,7 +30,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction description = "Adds options to hide general layout components.", dependencies = [ LithoFilterPatch::class, - SettingsPatch::class + SettingsPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -58,383 +61,55 @@ object HideLayoutComponentsPatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/components/DescriptionComponentsFilter;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_gray_separator", - StringResource("revanced_hide_gray_separator_title", "Hide gray separator"), - StringResource("revanced_hide_gray_separator_summary_on", "Gray separators are hidden"), - StringResource("revanced_hide_gray_separator_summary_off", "Gray separators are shown") - ), - SwitchPreference( - "revanced_hide_join_membership_button", - StringResource("revanced_hide_join_membership_button_title", "Hide \\\'Join\\\' button"), - StringResource("revanced_hide_join_membership_button_summary_on", "Button is hidden"), - StringResource("revanced_hide_join_membership_button_summary_off", "Button is shown") - ), - SwitchPreference( - "revanced_hide_channel_watermark_title", - StringResource( - "revanced_hide_channel_watermark_title", - "Hide channel watermark in video player" - ), - StringResource("revanced_hide_channel_watermark_title_summary_on", "Watermark is hidden"), - StringResource("revanced_hide_channel_watermark_title_summary_off", "Watermark is shown") - ), - SwitchPreference( - "revanced_hide_for_you_shelf", - StringResource("revanced_hide_for_you_shelf_title", "Hide \\\'For you\\\' shelf in channel page"), - StringResource("revanced_hide_for_you_shelf_summary_on", "Shelf is hidden"), - StringResource("revanced_hide_for_you_shelf_summary_off", "Shelf is shown") - ), - SwitchPreference( - "revanced_hide_notify_me_button", - StringResource("revanced_hide_notify_me_button_title", "Hide \\\'Notify me\\\' button"), - StringResource("revanced_hide_notify_me_button_summary_on", "Button is hidden"), - StringResource("revanced_hide_notify_me_button_summary_off", "Button is shown") - ), - SwitchPreference( - "revanced_hide_timed_reactions", - StringResource("revanced_hide_timed_reactions_title", "Hide timed reactions"), - StringResource("revanced_hide_timed_reactions_summary_on", "Timed reactions are hidden"), - StringResource("revanced_hide_timed_reactions_summary_off", "Timed reactions are shown") - ), - SwitchPreference( - "revanced_hide_search_result_recommendations", - StringResource( - "revanced_hide_search_result_recommendations_title", - "Hide \\\'People also watched\\\' recommendations" - ), - StringResource( - "revanced_hide_search_result_recommendations_summary_on", - "Recommendations are hidden" - ), - StringResource( - "revanced_hide_search_result_recommendations_summary_off", - "Recommendations are shown" - ) - ), - SwitchPreference( - "revanced_hide_search_result_shelf_header", - StringResource( - "revanced_hide_search_result_shelf_header_title", - "Hide search result shelf header" - ), - StringResource( - "revanced_hide_search_result_shelf_header_summary_on", - "Shelf header is hidden" - ), - StringResource( - "revanced_hide_search_result_shelf_header_summary_off", - "Shelf header is shown" - ) - ), - SwitchPreference( - "revanced_hide_channel_guidelines", - StringResource("revanced_hide_channel_guidelines_title", "Hide channel guidelines"), - StringResource( - "revanced_hide_channel_guidelines_summary_on", - "Channel guidelines are hidden" - ), - StringResource( - "revanced_hide_channel_guidelines_summary_off", - "Channel guidelines are shown" - ) - ), - SwitchPreference( - "revanced_hide_expandable_chip", - StringResource( - "revanced_hide_expandable_chip_title", - "Hide expandable chip under videos" - ), - StringResource( - "revanced_hide_expandable_chip_summary_on", - "Expandable chips are hidden" - ), - StringResource( - "revanced_hide_expandable_chip_summary_off", - "Expandable chips are shown" - ) - ), - SwitchPreference( - "revanced_hide_video_quality_menu_footer", - StringResource( - "revanced_hide_video_quality_menu_footer_title", - "Hide video quality menu footer" - ), - StringResource( - "revanced_hide_video_quality_menu_footer_summary_on", - "Video quality menu footer is hidden" - ), - StringResource( - "revanced_hide_video_quality_menu_footer_summary_off", - "Video quality menu footer is shown" - ) - ), - SwitchPreference( - "revanced_hide_chapters", - StringResource( - "revanced_hide_chapters_title", - "Hide chapters in the video description" - ), - StringResource( - "revanced_hide_chapters_summary_on", - "Chapters are hidden" - ), - StringResource( - "revanced_hide_chapters_summary_off", - "Chapters are shown" - ) - ), - SwitchPreference( - "revanced_hide_community_posts", - StringResource("revanced_hide_community_posts_title", "Hide community posts"), - StringResource("revanced_hide_community_posts_summary_on", "Community posts are hidden"), - StringResource("revanced_hide_community_posts_summary_off", "Community posts are shown") - ), - SwitchPreference( - "revanced_hide_compact_banner", - StringResource("revanced_hide_compact_banner_title", "Hide compact banners"), - StringResource("revanced_hide_compact_banner_summary_on", "Compact banners are hidden"), - StringResource("revanced_hide_compact_banner_summary_off", "Compact banners are shown") - ), - SwitchPreference( - "revanced_hide_movies_section", - StringResource("revanced_hide_movies_section_title", "Hide movies section"), - StringResource("revanced_hide_movies_section_summary_on", "Movies section is hidden"), - StringResource("revanced_hide_movies_section_summary_off", "Movies section is shown") - ), - SwitchPreference( - "revanced_hide_feed_survey", - StringResource("revanced_hide_feed_survey_title", "Hide feed surveys"), - StringResource("revanced_hide_feed_survey_summary_on", "Feed surveys are hidden"), - StringResource("revanced_hide_feed_survey_summary_off", "Feed surveys are shown") - ), - SwitchPreference( - "revanced_hide_community_guidelines", - StringResource("revanced_hide_community_guidelines_title", "Hide community guidelines"), - StringResource( - "revanced_hide_community_guidelines_summary_on", - "Community guidelines are hidden" - ), - StringResource( - "revanced_hide_community_guidelines_summary_off", - "Community guidelines are shown" - ) - ), - SwitchPreference( - "revanced_hide_subscribers_community_guidelines", - StringResource( - "revanced_hide_subscribers_community_guidelines_title", - "Hide subscribers community guidelines" - ), - StringResource( - "revanced_hide_subscribers_community_guidelines_summary_on", - "Subscribers community guidelines are hidden" - ), - StringResource( - "revanced_hide_subscribers_community_guidelines_summary_off", - "Subscribers community guidelines are shown" - ) - ), - SwitchPreference( - "revanced_hide_channel_member_shelf", - StringResource("revanced_hide_channel_member_shelf_title", "Hide channel member shelf"), - StringResource( - "revanced_hide_channel_member_shelf_summary_on", - "Channel member shelf is hidden" - ), - StringResource( - "revanced_hide_channel_member_shelf_summary_off", - "Channel member shelf is shown" - ) - ), - SwitchPreference( - "revanced_hide_emergency_box", - StringResource("revanced_hide_emergency_box_title", "Hide emergency boxes"), - StringResource("revanced_hide_emergency_box_summary_on", "Emergency boxes are hidden"), - StringResource("revanced_hide_emergency_box_summary_off", "Emergency boxes are shown") - ), - SwitchPreference( - "revanced_hide_info_panels", - StringResource("revanced_hide_info_panels_title", "Hide info panels"), - StringResource("revanced_hide_info_panels_summary_on", "Info panels are hidden"), - StringResource("revanced_hide_info_panels_summary_off", "Info panels are shown") - ), - SwitchPreference( - "revanced_hide_medical_panels", - StringResource("revanced_hide_medical_panels_title", "Hide medical panels"), - StringResource("revanced_hide_medical_panels_summary_on", "Medical panels are hidden"), - StringResource("revanced_hide_medical_panels_summary_off", "Medical panels are shown") - ), - SwitchPreference( - "revanced_hide_channel_bar", - StringResource("revanced_hide_channel_bar_title", "Hide channel bar"), - StringResource("revanced_hide_channel_bar_summary_on", "Channel bar is hidden"), - StringResource("revanced_hide_channel_bar_summary_off", "Channel bar is shown") - ), - SwitchPreference( - "revanced_hide_quick_actions", - StringResource("revanced_hide_quick_actions_title", "Hide quick actions in fullscreen"), - StringResource("revanced_hide_quick_actions_summary_on", "Quick actions are hidden"), - StringResource("revanced_hide_quick_actions_summary_off", "Quick actions are shown") - ), - SwitchPreference( - "revanced_hide_related_videos", - StringResource("revanced_hide_related_videos_title", "Hide related videos in quick actions"), - StringResource("revanced_hide_related_videos_summary_on", "Related videos are hidden"), - StringResource("revanced_hide_related_videos_summary_off", "Related videos are shown") - ), - SwitchPreference( - "revanced_hide_image_shelf", - StringResource("revanced_hide_image_shelf", "Hide image shelf in search results"), - StringResource("revanced_hide_image_shelf_summary_on", "Image shelf is hidden"), - StringResource("revanced_hide_image_shelf_summary_off", "Image shelf is shown") - ), - SwitchPreference( - "revanced_hide_latest_posts_ads", - StringResource("revanced_hide_latest_posts_ads_title", "Hide latest posts"), - StringResource("revanced_hide_latest_posts_ads_summary_on", "Latest posts are hidden"), - StringResource("revanced_hide_latest_posts_ads_summary_off", "Latest posts are shown") - ), - SwitchPreference( - "revanced_hide_mix_playlists", - StringResource("revanced_hide_mix_playlists_title", "Hide mix playlists"), - StringResource("revanced_hide_mix_playlists_summary_on", "Mix playlists are hidden"), - StringResource("revanced_hide_mix_playlists_summary_off", "Mix playlists are shown") - ), - SwitchPreference( - "revanced_hide_artist_cards", - StringResource("revanced_hide_artist_cards_title", "Hide artist cards"), - StringResource("revanced_hide_artist_cards_on", "Artist cards are hidden"), - StringResource("revanced_hide_artist_cards_off", "Artist cards are shown") - ), - SwitchPreference( - "revanced_hide_chips_shelf", - StringResource("revanced_hide_chips_shelf_title", "Hide chips shelf"), - StringResource("revanced_hide_chips_shelf_on", "Chips shelf is hidden"), - StringResource("revanced_hide_chips_shelf_off", "Chips shelf is shown") - ), - PreferenceScreen( + SwitchPreference("revanced_hide_gray_separator"), + SwitchPreference("revanced_hide_join_membership_button"), + SwitchPreference("revanced_hide_channel_watermark"), + SwitchPreference("revanced_hide_for_you_shelf"), + SwitchPreference("revanced_hide_notify_me_button"), + SwitchPreference("revanced_hide_timed_reactions"), + SwitchPreference("revanced_hide_search_result_recommendations"), + SwitchPreference("revanced_hide_search_result_shelf_header"), + SwitchPreference("revanced_hide_channel_guidelines"), + SwitchPreference("revanced_hide_expandable_chip"), + SwitchPreference("revanced_hide_video_quality_menu_footer"), + SwitchPreference("revanced_hide_chapters"), + SwitchPreference("revanced_hide_community_posts"), + SwitchPreference("revanced_hide_compact_banner"), + SwitchPreference("revanced_hide_movies_section"), + SwitchPreference("revanced_hide_feed_survey"), + SwitchPreference("revanced_hide_community_guidelines"), + SwitchPreference("revanced_hide_subscribers_community_guidelines"), + SwitchPreference("revanced_hide_channel_member_shelf"), + SwitchPreference("revanced_hide_emergency_box"), + SwitchPreference("revanced_hide_info_panels"), + SwitchPreference("revanced_hide_medical_panels"), + SwitchPreference("revanced_hide_channel_bar"), + SwitchPreference("revanced_hide_quick_actions"), + SwitchPreference("revanced_hide_related_videos"), + SwitchPreference("revanced_hide_image_shelf"), + SwitchPreference("revanced_hide_latest_posts_ads"), + SwitchPreference("revanced_hide_mix_playlists"), + SwitchPreference("revanced_hide_artist_cards"), + SwitchPreference("revanced_hide_chips_shelf"), + app.revanced.patches.shared.misc.settings.preference.PreferenceScreen( "revanced_hide_description_components_preference_screen", - StringResource( - "revanced_hide_description_components_preference_screen_title", - "Hide components in the video description" - ), - listOf( - SwitchPreference( - "revanced_hide_info_cards_section", - StringResource( - "revanced_hide_info_cards_section_title", - "Hide info cards section" - ), - StringResource( - "revanced_hide_info_cards_section_summary_on", - "Info cards section is hidden" - ), - StringResource( - "revanced_hide_info_cards_section_summary_off", - "Info cards section is shown" - ) - ), - SwitchPreference( - "revanced_hide_game_section", - StringResource( - "revanced_hide_game_section_title", - "Hide game section" - ), - StringResource( - "revanced_hide_game_section_summary_on", - "Game section is hidden" - ), - StringResource( - "revanced_hide_game_section_summary_off", - "Game section is shown" - ) - ), - SwitchPreference( - "revanced_hide_music_section", - StringResource( - "revanced_hide_music_section_title", - "Hide music section" - ), - StringResource( - "revanced_hide_music_section_summary_on", - "Music section is hidden" - ), - StringResource( - "revanced_hide_music_section_summary_off", - "Music section is shown" - ) - ), - SwitchPreference( - "revanced_hide_podcast_section", - StringResource( - "revanced_hide_podcast_section_title", - "Hide podcast section" - ), - StringResource( - "revanced_hide_podcast_section_summary_on", - "Podcast section is hidden" - ), - StringResource( - "revanced_hide_podcast_section_summary_off", - "Podcast section is shown" - ) - ), - SwitchPreference( - "revanced_hide_transcript_section", - StringResource( - "revanced_hide_transcript_section_title", - "Hide transcript section" - ), - StringResource( - "revanced_hide_transcript_section_summary_on", - "Transcript section is hidden" - ), - StringResource( - "revanced_hide_transcript_section_summary_off", - "Transcript section is shown" - ) - ), - ), - StringResource( - "revanced_hide_description_components_preference_screen_summary", - "Hide components under the video description" + preferences = setOf( + SwitchPreference("revanced_hide_info_cards_section"), + SwitchPreference("revanced_hide_game_section"), + SwitchPreference("revanced_hide_music_section"), + SwitchPreference("revanced_hide_podcast_section"), + SwitchPreference("revanced_hide_transcript_section"), ) ), - PreferenceScreen( + app.revanced.patches.shared.misc.settings.preference.PreferenceScreen( "revanced_custom_filter_preference_screen", - StringResource("revanced_custom_filter_preference_screen_title", "Custom filter"), - listOf( - SwitchPreference( - "revanced_custom_filter", - StringResource( - "revanced_custom_filter_title", - "Enable custom filter" - ), - StringResource( - "revanced_custom_filter_summary_on", - "Custom filter is enabled" - ), - StringResource( - "revanced_custom_filter_summary_off", - "Custom filter is disabled" - ) - ), + preferences = setOf( + SwitchPreference("revanced_custom_filter"), // TODO: This should be a dynamic ListPreference, which does not exist yet - TextPreference( - "revanced_custom_filter_strings", - StringResource("revanced_custom_filter_strings_title", "Custom filter"), - StringResource( - "revanced_custom_filter_strings_summary", - "List of component path builder strings to filter separated by new line" - ), - inputType = InputType.TEXT_MULTI_LINE - ) - ), - StringResource( - "revanced_custom_filter_preference_screen_summary", - "Hide components using custom filters" + TextPreference("revanced_custom_filter_strings", inputType = InputType.TEXT_MULTI_LINE) ) ) ) @@ -445,24 +120,21 @@ object HideLayoutComponentsPatch : BytecodePatch( // region Mix playlists ParseElementFromBufferFingerprint.result?.let { result -> - val returnEmptyComponentInstruction = result.mutableMethod.getInstructions() - .last { it.opcode == Opcode.INVOKE_STATIC } + val returnEmptyComponentInstruction = + result.mutableMethod.getInstructions().last { it.opcode == Opcode.INVOKE_STATIC } result.mutableMethod.apply { val consumeByteBufferIndex = result.scanResult.patternScanResult!!.startIndex val conversionContextRegister = getInstruction(consumeByteBufferIndex - 2).registerA - val byteBufferRegister = - getInstruction(consumeByteBufferIndex).registerD + val byteBufferRegister = getInstruction(consumeByteBufferIndex).registerD addInstructionsWithLabels( - consumeByteBufferIndex, - """ + consumeByteBufferIndex, """ invoke-static {v$conversionContextRegister, v$byteBufferRegister}, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->filterMixPlaylists(Ljava/lang/Object;[B)Z move-result v0 # Conveniently same register happens to be free. if-nez v0, :return_empty_component - """, - ExternalLabel("return_empty_component", returnEmptyComponentInstruction) + """, ExternalLabel("return_empty_component", returnEmptyComponentInstruction) ) } @@ -479,8 +151,7 @@ object HideLayoutComponentsPatch : BytecodePatch( removeInstruction(index) addInstructions( - index, - """ + index, """ invoke-static {}, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->showWatermark()Z move-result p2 """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt index bc590a97d9..cde96076d7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/infocards/HideInfocardsResourcePatch.kt @@ -3,29 +3,25 @@ package app.revanced.patches.youtube.layout.hide.infocards import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( dependencies = [ SettingsPatch::class, - ResourceMappingPatch::class + ResourceMappingPatch::class, + AddResourcesPatch::class ], ) object HideInfocardsResourcePatch : ResourcePatch() { internal var drawerResourceId: Long = -1 override fun execute(context: ResourceContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_info_cards", - StringResource("revanced_hide_info_cards_title", "Hide info cards"), - StringResource("revanced_hide_info_cards_summary_on", "Info cards are hidden"), - StringResource("revanced_hide_info_cards_summary_off", "Info cards are shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_info_cards")) drawerResourceId = ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == "info_cards_drawer_header" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt index cf75e3f99e..4ab73f3a3b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/HideLoadMoreButtonResourcePatch.kt @@ -3,29 +3,25 @@ package app.revanced.patches.youtube.layout.hide.loadmorebutton import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( dependencies = [ SettingsPatch::class, - ResourceMappingPatch::class + ResourceMappingPatch::class, + AddResourcesPatch::class ] ) internal object HideLoadMoreButtonResourcePatch : ResourcePatch() { internal var expandButtonDownId: Long = -1 override fun execute(context: ResourceContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_load_more_button", - StringResource("revanced_hide_load_more_button_title", "Hide \\\'Load More\\\' button"), - StringResource("revanced_hide_load_more_button_summary_on", "Button is hidden"), - StringResource("revanced_hide_load_more_button_summary_off", "Button is shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_load_more_button")) expandButtonDownId = ResourceMappingPatch.resourceMappings.single { it.type == "layout" && it.name == "expand_button_down" diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/preference/DefaultBasePreference.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressPatch.kt similarity index 100% rename from src/main/kotlin/app/revanced/patches/shared/settings/preference/DefaultBasePreference.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/HideEmailAddressPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt index 24151ec38a..4449fed857 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/flyoutmenupanel/HidePlayerFlyoutMenuPatch.kt @@ -4,9 +4,9 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch @@ -17,7 +17,8 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch dependencies = [ LithoFilterPatch::class, PlayerTypeHookPatch::class, - SettingsPatch::class + SettingsPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -45,73 +46,23 @@ object HidePlayerFlyoutMenuPatch : ResourcePatch() { "Lapp/revanced/integrations/youtube/patches/components/PlayerFlyoutMenuItemsFilter;" override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( PreferenceScreen( - KEY, - StringResource("${KEY}_title", "Player flyout menu items"), - listOf( - SwitchPreference( - "${KEY}_captions", - StringResource("${KEY}_captions_title", "Hide Captions menu"), - StringResource("${KEY}_captions_on", "Captions menu item is hidden"), - StringResource("${KEY}_captions_off", "Captions menu item is shown") - ), - SwitchPreference( - "${KEY}_additional_settings", - StringResource("${KEY}_additional_settings_title", "Hide Additional settings menu"), - StringResource("${KEY}_additional_settings_on", "Additional settings menu item is hidden"), - StringResource("${KEY}_additional_settings_off", "Additional settings menu item is shown") - ), - SwitchPreference( - "${KEY}_loop_video", - StringResource("${KEY}_loop_video_title", "Hide Loop video menu"), - StringResource("${KEY}_loop_video_on", "Loop video menu item is hidden"), - StringResource("${KEY}_loop_video_off", "Loop video menu item is shown") - ), - SwitchPreference( - "${KEY}_ambient_mode", - StringResource("${KEY}_ambient_mode_title", "Hide Ambient mode menu"), - StringResource("${KEY}_ambient_mode_on", "Ambient mode menu item is hidden"), - StringResource("${KEY}_ambient_mode_off", "Ambient mode menu item is shown") - ), - SwitchPreference( - "${KEY}_report", - StringResource("${KEY}_report_title", "Hide Report menu"), - StringResource("${KEY}_report_on", "Report menu item is hidden"), - StringResource("${KEY}_report_off", "Report menu item is shown") - ), - SwitchPreference( - "${KEY}_help", - StringResource("${KEY}_help_title", "Hide Help menu"), - StringResource("${KEY}_help_on", "Help menu item is hidden"), - StringResource("${KEY}_help_off", "Help menu item is shown") - ), - SwitchPreference( - "${KEY}_speed", - StringResource("${KEY}_speed_title", "Hide Speed menu"), - StringResource("${KEY}_speed_on", "Speed menu item is hidden"), - StringResource("${KEY}_speed_off", "Speed menu item is shown") - ), - SwitchPreference( - "${KEY}_more_info", - StringResource("${KEY}_more_info_title", "Hide More info menu"), - StringResource("${KEY}_more_info_on", "More info menu item is hidden"), - StringResource("${KEY}_more_info_off", "More info menu item is shown") - ), - SwitchPreference( - "${KEY}_audio_track", - StringResource("${KEY}_audio_track_title", "Hide Audio track menu"), - StringResource("${KEY}_audio_track_on", "Audio track menu item is hidden"), - StringResource("${KEY}_audio_track_off", "Audio track menu item is shown") - ), - SwitchPreference( - "${KEY}_watch_in_vr", - StringResource("${KEY}_watch_in_vr_title", "Hide Watch in VR menu"), - StringResource("${KEY}_watch_in_vr_on", "Watch in VR menu item is hidden"), - StringResource("${KEY}_watch_in_vr_off", "Watch in VR menu item is shown") - ), + key = KEY, + preferences = setOf( + SwitchPreference("${KEY}_captions"), + SwitchPreference("${KEY}_additional_settings"), + SwitchPreference("${KEY}_loop_video"), + SwitchPreference("${KEY}_ambient_mode"), + SwitchPreference("${KEY}_report"), + SwitchPreference("${KEY}_help"), + SwitchPreference("${KEY}_speed"), + SwitchPreference("${KEY}_more_info"), + SwitchPreference("${KEY}_audio_track"), + SwitchPreference("${KEY}_watch_in_vr"), ), - StringResource("${KEY}_summary", "Manage the visibility of player flyout menu items") ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt index 384bf33a0b..d9cb1c2c4d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/rollingnumber/DisableRollingNumberAnimationPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.layout.hide.rollingnumber -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels @@ -9,17 +8,18 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.shared.fingerprints.RollingNumberTextViewAnimationUpdateFingerprint +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( name = "Disable rolling number animations", description = "Adds an option to disable rolling number animations of video view count, user likes, and upload time.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -45,13 +45,10 @@ object DisableRollingNumberAnimationPatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/DisableRollingNumberAnimationsPatch;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_disable_rolling_number_animations", - StringResource("revanced_disable_rolling_number_animations_title", "Disable rolling number animations"), - StringResource("revanced_disable_rolling_number_animations_summary_on", "Rolling numbers are not animated"), - StringResource("revanced_disable_rolling_number_animations_summary_off", "Rolling numbers are animated") - ) + SwitchPreference("revanced_disable_rolling_number_animations") ) // Animations are disabled by preventing an Image from being applied to the text span, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt index 087fa0e603..92079f3005 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/seekbar/HideSeekbarPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.seekbar.SeekbarColorBytecodePatch import app.revanced.patches.youtube.layout.seekbar.SeekbarPreferencesPatch import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch @@ -21,7 +21,8 @@ import app.revanced.patches.youtube.shared.fingerprints.SeekbarOnDrawFingerprint IntegrationsPatch::class, SettingsPatch::class, SeekbarColorBytecodePatch::class, - SeekbarPreferencesPatch::class + SeekbarPreferencesPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -46,19 +47,11 @@ object HideSeekbarPatch : BytecodePatch( setOf(SeekbarFingerprint) ) { override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SeekbarPreferencesPatch.addPreferences( - SwitchPreference( - "revanced_hide_seekbar", - StringResource("revanced_hide_seekbar_title", "Hide seekbar in video player"), - StringResource("revanced_hide_seekbar_summary_on", "Video player seekbar is hidden"), - StringResource("revanced_hide_seekbar_summary_off", "Video player seekbar is shown") - ), - SwitchPreference( - "revanced_hide_seekbar_thumbnail", - StringResource("revanced_hide_seekbar_thumbnail_title", "Hide seekbar in video thumbnails"), - StringResource("revanced_hide_seekbar_thumbnail_summary_on", "Thumbnail seekbar is hidden"), - StringResource("revanced_hide_seekbar_thumbnail_summary_off", "Thumbnail seekbar is shown") - ) + SwitchPreference("revanced_hide_seekbar"), + SwitchPreference("revanced_hide_seekbar_thumbnail") ) SeekbarFingerprint.result!!.let { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt index 87c371d8be..46a3d23227 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.youtube.layout.hide.shorts.fingerprints.* import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt index 5f213e3b56..b9f411fea1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsResourcePatch.kt @@ -3,97 +3,37 @@ package app.revanced.patches.youtube.layout.hide.shorts import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch -@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class]) +@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class]) object HideShortsComponentsResourcePatch : ResourcePatch() { internal var reelMultipleItemShelfId = -1L internal var reelPlayerRightCellButtonHeight = -1L override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( PreferenceScreen( "revanced_shorts_preference_screen", - StringResource("revanced_shorts_preference_screen_title", "Shorts components"), - listOf( - SwitchPreference( - "revanced_hide_shorts", - StringResource("revanced_hide_shorts_title", "Hide Shorts in feed"), - StringResource("revanced_hide_shorts_on", "Shorts are hidden"), - StringResource("revanced_hide_shorts_off", "Shorts are shown") - ), - SwitchPreference( - "revanced_hide_shorts_join_button", - StringResource("revanced_hide_shorts_join_button_title", "Hide join button"), - StringResource("revanced_hide_shorts_join_button_on", "Join button is hidden"), - StringResource("revanced_hide_shorts_join_button_off", "Join button is shown") - ), - SwitchPreference( - "revanced_hide_shorts_subscribe_button", - StringResource("revanced_hide_shorts_subscribe_button_title", "Hide subscribe button"), - StringResource("revanced_hide_shorts_subscribe_button_on", "Subscribe button is hidden"), - StringResource("revanced_hide_shorts_subscribe_button_off", "Subscribe button is shown") - ), - SwitchPreference( - "revanced_hide_shorts_subscribe_button_paused", - StringResource("revanced_hide_shorts_subscribe_button_paused_title", "Hide subscribe button when paused"), - StringResource("revanced_hide_shorts_subscribe_button_paused_on", "Subscribe button is hidden"), - StringResource("revanced_hide_shorts_subscribe_button_paused_off", "Subscribe button is shown") - ), - SwitchPreference( - "revanced_hide_shorts_thanks_button", - StringResource("revanced_hide_shorts_thanks_button_title", "Hide thanks button"), - StringResource("revanced_hide_shorts_thanks_button_on", "Thanks button is hidden"), - StringResource("revanced_hide_shorts_thanks_button_off", "Thanks button is shown") - ), - SwitchPreference( - "revanced_hide_shorts_comments_button", - StringResource("revanced_hide_shorts_comments_button_title", "Hide comments button"), - StringResource("revanced_hide_shorts_comments_button_on", "Comments button is hidden"), - StringResource("revanced_hide_shorts_comments_button_off", "Comments button is shown") - ), - SwitchPreference( - "revanced_hide_shorts_remix_button", - StringResource("revanced_hide_shorts_remix_button_title", "Hide remix button"), - StringResource("revanced_hide_shorts_remix_button_on", "Remix button is hidden"), - StringResource("revanced_hide_shorts_remix_button_off", "Remix button is shown") - ), - SwitchPreference( - "revanced_hide_shorts_share_button", - StringResource("revanced_hide_shorts_share_button_title", "Hide share button"), - StringResource("revanced_hide_shorts_share_button_on", "Share button is hidden"), - StringResource("revanced_hide_shorts_share_button_off", "Share button is shown") - ), - SwitchPreference( - "revanced_hide_shorts_info_panel", - StringResource("revanced_hide_shorts_info_panel_title", "Hide info panel"), - StringResource("revanced_hide_shorts_info_panel_on", "Info panel is hidden"), - StringResource("revanced_hide_shorts_info_panel_off", "Info panel is shown") - ), - SwitchPreference( - "revanced_hide_shorts_channel_bar", - StringResource("revanced_hide_shorts_channel_bar_title", "Hide channel bar"), - StringResource("revanced_hide_shorts_channel_bar_on", "Channel bar is hidden"), - StringResource("revanced_hide_shorts_channel_bar_off", "Channel bar is shown") - ), - SwitchPreference( - "revanced_hide_shorts_sound_button", - StringResource("revanced_hide_shorts_sound_button_title", "Hide sound button"), - StringResource("revanced_hide_shorts_sound_button_on", "Sound button is hidden"), - StringResource("revanced_hide_shorts_sound_button_off", "Sound button is shown") - ), - SwitchPreference( - "revanced_hide_shorts_navigation_bar", - StringResource("revanced_hide_shorts_navigation_bar_title", "Hide navigation bar"), - StringResource("revanced_hide_shorts_navigation_bar_on", "Navigation bar is hidden"), - StringResource("revanced_hide_shorts_navigation_bar_off", "Navigation bar is shown") - ) - ), - StringResource("revanced_shorts_preference_screen_summary", "Manage the visibility of Shorts components") + preferences = setOf( + SwitchPreference("revanced_hide_shorts"), + SwitchPreference("revanced_hide_shorts_join_button"), + SwitchPreference("revanced_hide_shorts_subscribe_button"), + SwitchPreference("revanced_hide_shorts_subscribe_button_paused"), + SwitchPreference("revanced_hide_shorts_thanks_button"), + SwitchPreference("revanced_hide_shorts_comments_button"), + SwitchPreference("revanced_hide_shorts_remix_button"), + SwitchPreference("revanced_hide_shorts_share_button"), + SwitchPreference("revanced_hide_shorts_info_panel"), + SwitchPreference("revanced_hide_shorts_channel_bar"), + SwitchPreference("revanced_hide_shorts_sound_button"), + SwitchPreference("revanced_hide_shorts_navigation_bar") + ) ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt index a31df001e3..b190b321d3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/suggestedvideoendscreen/DisableSuggestedVideoEndScreenResourcePatch.kt @@ -3,37 +3,26 @@ package app.revanced.patches.youtube.layout.hide.suggestedvideoendscreen import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( dependencies = [ SettingsPatch::class, - ResourceMappingPatch::class + ResourceMappingPatch::class, + AddResourcesPatch::class ], ) internal object DisableSuggestedVideoEndScreenResourcePatch : ResourcePatch() { internal var sizeAdjustableLiteAutoNavOverlay: Long = -1 override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_disable_suggested_video_end_screen", - StringResource( - "revanced_disable_suggested_video_end_screen_title", - "Disable suggested video end screen" - ), - StringResource( - "revanced_disable_suggested_video_end_screen_summary_on", - "Suggested videos will be disabled" - ), - StringResource( - "revanced_disable_suggested_video_end_screen_summary_off", - "Suggested videos will be shown" - ), - ) + SwitchPreference("revanced_disable_suggested_video_end_screen") ) sizeAdjustableLiteAutoNavOverlay = ResourceMappingPatch.resourceMappings.single { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt index 60941680c5..665f5f67bb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch.kt @@ -1,21 +1,21 @@ package app.revanced.patches.youtube.layout.hide.time -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.hide.time.fingerprints.TimeCounterFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Hide timestamp", description = "Adds an option to hide the timestamp in the bottom left of the video player.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -38,14 +38,9 @@ object HideTimestampPatch : BytecodePatch( setOf(TimeCounterFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_timestamp", - StringResource("revanced_hide_timestamp_title", "Hide video timestamp"), - StringResource("revanced_hide_timestamp_summary_on", "Timestamp is hidden"), - StringResource("revanced_hide_timestamp_summary_off", "Timestamp is shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_timestamp")) TimeCounterFingerprint.result?.apply { mutableMethod.addInstructionsWithLabels( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt index 49b19dca41..f4d1acf03a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/PlayerPopupPanelsPatch.kt @@ -1,21 +1,21 @@ package app.revanced.patches.youtube.layout.panels.popup -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.panels.popup.fingerprints.EngagementPanelControllerFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Disable player popup panels", description = "Adds an option to disable panels (such as live chat) from opening automatically.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -39,14 +39,9 @@ object PlayerPopupPanelsPatch : BytecodePatch( setOf(EngagementPanelControllerFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_hide_player_popup_panels", - StringResource("revanced_hide_player_popup_panels_title", "Hide player popup panels"), - StringResource("revanced_hide_player_popup_panels_summary_on", "Player popup panels are hidden"), - StringResource("revanced_hide_player_popup_panels_summary_off", "Player popup panels are shown") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_hide_player_popup_panels")) val engagementPanelControllerMethod = EngagementPanelControllerFingerprint .result?.mutableMethod ?: throw EngagementPanelControllerFingerprint.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt index a724405cb4..a409030c4b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/player/overlay/CustomPlayerOverlayOpacityResourcePatch.kt @@ -3,32 +3,23 @@ package app.revanced.patches.youtube.layout.player.overlay import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.InputType -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.TextPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.InputType +import app.revanced.patches.shared.misc.settings.preference.TextPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( - dependencies = [SettingsPatch::class, ResourceMappingPatch::class] + dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class] ) internal object CustomPlayerOverlayOpacityResourcePatch : ResourcePatch() { internal var scrimOverlayId = -1L override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - TextPreference( - "revanced_player_overlay_opacity", - StringResource( - "revanced_player_overlay_opacity_title", - "Player overlay opacity" - ), - StringResource( - "revanced_player_overlay_opacity_summary", - "Opacity value between 0-100, where 0 is transparent" - ), - InputType.NUMBER - ) + TextPreference("revanced_player_overlay_opacity", inputType = InputType.NUMBER) ) scrimOverlayId = ResourceMappingPatch.resourceMappings.single { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt index fe70b776c4..848b86af6e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/ReturnYouTubeDislikeResourcePatch.kt @@ -4,11 +4,9 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.IntentPreference +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.IntentPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch -import app.revanced.util.copyStrings -import app.revanced.util.resource.StringResource @Patch( dependencies = [ @@ -20,16 +18,16 @@ internal object ReturnYouTubeDislikeResourcePatch : ResourcePatch() { internal var oldUIDislikeId: Long = -1 override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( IntentPreference( - StringResource("revanced_ryd_settings_title", "Return YouTube Dislike"), - StringResource("revanced_ryd_settings_summary", "Settings for Return YouTube Dislike"), - SettingsPatch.newIntent("ryd_settings") + "revanced_ryd_settings", + intent = SettingsPatch.newIntent("revanced_ryd_settings_intent") ) ) - // merge strings - context.copyStrings("returnyoutubedislike/host/values/strings.xml") + AddResourcesPatch(this::class) oldUIDislikeId = ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == "dislike_button" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt index b5f952c242..30b979b57d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/WideSearchbarPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.layout.searchbar -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.MethodFingerprint @@ -8,17 +7,18 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.searchbar.fingerprints.CreateSearchSuggestionsFingerprint import app.revanced.patches.youtube.layout.searchbar.fingerprints.SetWordmarkHeaderFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Wide searchbar", description = "Adds an option to replace the search icon with a wide search bar. This will hide the YouTube logo when active.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -44,14 +44,9 @@ object WideSearchbarPatch : BytecodePatch( ) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_wide_searchbar", - StringResource("revanced_wide_searchbar_enabled_title", "Enable wide search bar"), - StringResource("revanced_wide_searchbar_summary_on", "Wide search bar is enabled"), - StringResource("revanced_wide_searchbar_summary_off", "Wide search bar is disabled") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_wide_searchbar")) val result = CreateSearchSuggestionsFingerprint.result ?: throw CreateSearchSuggestionsFingerprint.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt index 69f3ad2aee..a8f5932d6d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/RestoreOldSeekbarThumbnailsPatch.kt @@ -1,21 +1,21 @@ package app.revanced.patches.youtube.layout.seekbar -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.seekbar.fingerprints.FullscreenSeekbarThumbnailsFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch +import app.revanced.util.exception @Patch( name = "Restore old seekbar thumbnails", description = "Adds an option to restore the old seekbar thumbnails that appear above the seekbar while seeking instead of fullscreen thumbnails.", - dependencies = [IntegrationsPatch::class, SeekbarPreferencesPatch::class], + dependencies = [IntegrationsPatch::class, SeekbarPreferencesPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -41,23 +41,9 @@ object RestoreOldSeekbarThumbnailsPatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/RestoreOldSeekbarThumbnailsPatch;" override fun execute(context: BytecodeContext) { - SeekbarPreferencesPatch.addPreferences( - SwitchPreference( - "revanced_restore_old_seekbar_thumbnails", - StringResource( - "revanced_restore_old_seekbar_thumbnails_title", - "Restore old seekbar thumbnails" - ), - StringResource( - "revanced_restore_old_seekbar_thumbnails_summary_on", - "Seekbar thumbnails will appear above the seekbar" - ), - StringResource( - "revanced_restore_old_seekbar_thumbnails_summary_off", - "Seekbar thumbnails will appear in fullscreen" - ), - ) - ) + AddResourcesPatch(this::class) + + SeekbarPreferencesPatch.addPreferences(SwitchPreference("revanced_restore_old_seekbar_thumbnails")) FullscreenSeekbarThumbnailsFingerprint.result?.mutableMethod?.apply { val moveResultIndex = getInstructions().lastIndex - 1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorResourcePatch.kt index 9f774a60bd..5c7d6272a6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarColorResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import org.w3c.dom.Element diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt index 9bd025934a..0a9f7e27db 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/SeekbarPreferencesPatch.kt @@ -3,31 +3,28 @@ package app.revanced.patches.youtube.layout.seekbar import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.BasePreference -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.util.resource.StringResource +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.BasePreference +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen import app.revanced.patches.youtube.misc.settings.SettingsPatch import java.io.Closeable -@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class]) +@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class]) internal object SeekbarPreferencesPatch : ResourcePatch(), Closeable { - private val seekbarPreferences = mutableListOf() + private val seekbarPreferences = mutableSetOf() override fun execute(context: ResourceContext) { // Nothing to do here. All work is done in close method. } override fun close() { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( PreferenceScreen( "revanced_seekbar_preference_screen", - StringResource("revanced_seekbar_preference_screen_title", "Seekbar"), - seekbarPreferences, - StringResource( - "revanced_seekbar_preference_screen_summary", - "Settings for the seekbar" - ) + preferences = seekbarPreferences, ) ) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt index 382512f32d..e8ce6f193d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockBytecodePatch.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.youtube.layout.sponsorblock.fingerprints.AppendTimeFingerprint import app.revanced.patches.youtube.layout.sponsorblock.fingerprints.ControlsOverlayFingerprint import app.revanced.patches.youtube.layout.sponsorblock.fingerprints.RectangleFieldInvalidatorFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt index 475684bba4..a8c347b2c7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/SponsorBlockResourcePatch.kt @@ -1,60 +1,52 @@ package app.revanced.patches.youtube.layout.sponsorblock import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.IntentPreference +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.IntentPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.util.ResourceGroup import app.revanced.util.copyResources -import app.revanced.util.copyStrings import app.revanced.util.copyXmlNode -import app.revanced.util.resource.StringResource +import app.revanced.util.inputStreamFromBundledResource -@Patch(dependencies = [ - SettingsPatch::class, - ResourceMappingPatch::class, - AddResourcesPatch::class -]) +@Patch( + dependencies = [ + SettingsPatch::class, + ResourceMappingPatch::class, + AddResourcesPatch::class + ] +) internal object SponsorBlockResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( IntentPreference( - StringResource("revanced_sponsorblock_settings_title", "SponsorBlock"), - StringResource("revanced_sponsorblock_settings_summary", "SponsorBlock related settings"), - SettingsPatch.newIntent("sponsorblock_settings") + "revanced_sb_settings", + intent = SettingsPatch.newIntent("revanced_sb_settings_intent") ) ) - val classLoader = this.javaClass.classLoader - - /* - merge SponsorBlock strings to main strings - */ - context.copyStrings("sponsorblock/host/values/strings.xml") - - /* - merge SponsorBlock drawables to main drawables - */ - arrayOf( ResourceGroup( "layout", - "inline_sponsor_overlay.xml", - "new_segment.xml", - "skip_sponsor_button.xml" + "revanced_sb_inline_sponsor_overlay.xml", + "revanced_sb_new_segment.xml", + "revanced_sb_skip_sponsor_button.xml" ), ResourceGroup( // required resource for back button, because when the base APK is used, this resource will not exist "drawable", - "ic_sb_adjust.xml", - "ic_sb_compare.xml", - "ic_sb_edit.xml", - "ic_sb_logo.xml", - "ic_sb_publish.xml", - "ic_sb_voting.xml" + "revanced_sb_adjust.xml", + "revanced_sb_compare.xml", + "revanced_sb_edit.xml", + "revanced_sb_logo.xml", + "revanced_sb_publish.xml", + "revanced_sb_voting.xml" ), ResourceGroup( // required resource for back button, because when the base APK is used, this resource will not exist @@ -64,14 +56,14 @@ internal object SponsorBlockResourcePatch : ResourcePatch() { context.copyResources("sponsorblock", resourceGroup) } - /* - merge xml nodes from the host to their real xml files - */ - // copy nodes from host resources to their real xml files - val hostingResourceStream = - classLoader.getResourceAsStream("sponsorblock/host/layout/youtube_controls_layout.xml")!! + val hostingResourceStream = inputStreamFromBundledResource( + "sponsorblock", + "host/layout/youtube_controls_layout.xml" + )!! + + var modifiedControlsLayout = false val targetXmlEditor = context.xmlEditor["res/layout/youtube_controls_layout.xml"] "RelativeLayout".copyXmlNode( context.xmlEditor[hostingResourceStream], @@ -87,12 +79,15 @@ internal object SponsorBlockResourcePatch : ResourcePatch() { if (!(view.hasAttributes() && view.attributes.getNamedItem("android:id").nodeValue.endsWith("live_chat_overlay_button"))) continue // voting button id from the voting button view from the youtube_controls_layout.xml host file - val votingButtonId = "@+id/sb_voting_button" + val votingButtonId = "@+id/revanced_sb_voting_button" view.attributes.getNamedItem("android:layout_toStartOf").nodeValue = votingButtonId + modifiedControlsLayout = true break } - }.close() // close afterwards + }.close() + + if (!modifiedControlsLayout) throw PatchException("Could not modify controls layout") } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt index 92d19aeebc..efa71607e9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/SpoofAppVersionPatch.kt @@ -1,25 +1,24 @@ package app.revanced.patches.youtube.layout.spoofappversion -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.ArrayResource -import app.revanced.patches.shared.settings.preference.impl.ListPreference -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.ListPreference +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.spoofappversion.fingerprints.SpoofAppVersionFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( name = "Spoof app version", description = "Adds an option to trick YouTube into thinking you are running an older version of the app. " + "This can be used to restore old UI elements and features.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -42,46 +41,17 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction object SpoofAppVersionPatch : BytecodePatch( setOf(SpoofAppVersionFingerprint) ) { - private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/spoof/SpoofAppVersionPatch;" + private const val INTEGRATIONS_CLASS_DESCRIPTOR = + "Lapp/revanced/integrations/youtube/patches/spoof/SpoofAppVersionPatch;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_spoof_app_version", - StringResource("revanced_spoof_app_version_title", "Spoof app version"), - StringResource("revanced_spoof_app_version_summary_on", "Version spoofed"), - StringResource("revanced_spoof_app_version_summary_off", "Version not spoofed"), - StringResource("revanced_spoof_app_version_user_dialog_message", - "App version will be spoofed to an older version of YouTube." - + "\\n\\nThis will change the appearance and features of the app, but unknown side effects may occur." - + "\\n\\nIf later turned off, it is recommended to clear the app data to prevent UI bugs.") - ), + SwitchPreference("revanced_spoof_app_version"), ListPreference( - "revanced_spoof_app_version_target", - StringResource( - "revanced_spoof_app_version_target_title", - "Spoof app version target" - ), - ArrayResource( - "revanced_spoof_app_version_target_entries", - listOf( - StringResource("revanced_spoof_app_version_target_entry_1", "18.33.40 - Restore RYD Shorts incognito mode"), - StringResource("revanced_spoof_app_version_target_entry_2", "18.20.39 - Restore wide video speed & quality menu"), - StringResource("revanced_spoof_app_version_target_entry_3", "17.08.35 - Restore old UI layout"), - StringResource("revanced_spoof_app_version_target_entry_4", "16.08.35 - Restore explore tab"), - StringResource("revanced_spoof_app_version_target_entry_5", "16.01.35 - Restore fewer video player action buttons"), - ) - ), - ArrayResource( - "revanced_spoof_app_version_target_entry_values", - listOf( - StringResource("revanced_spoof_app_version_target_entry_value_1", "18.33.40"), - StringResource("revanced_spoof_app_version_target_entry_value_2", "18.20.39"), - StringResource("revanced_spoof_app_version_target_entry_value_3", "17.08.35"), - StringResource("revanced_spoof_app_version_target_entry_value_4", "16.08.35"), - StringResource("revanced_spoof_app_version_target_entry_value_5", "16.01.35"), - ) - ) + key = "revanced_spoof_app_version_target", + summaryKey = null, ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt index d52b5efa3b..9016385ad6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startpage/ChangeStartPagePatch.kt @@ -5,19 +5,18 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.youtube.shared.fingerprints.HomeActivityFingerprint -import app.revanced.util.resource.ArrayResource -import app.revanced.patches.shared.settings.preference.impl.ListPreference -import app.revanced.util.resource.StringResource +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.ListPreference import app.revanced.patches.youtube.layout.startpage.fingerprints.StartActivityFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.patches.youtube.shared.fingerprints.HomeActivityFingerprint import app.revanced.util.exception @Patch( name = "Change start page", description = "Adds an option to set which page the app opens in instead of the homepage.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube" @@ -32,35 +31,12 @@ object ChangeStartPagePatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/ChangeStartPagePatch;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( ListPreference( - "revanced_start_page", - StringResource( - "revanced_start_page_title", - "Set start page" - ), - ArrayResource( - "revanced_start_page_entries", - listOf( - StringResource("revanced_start_page_home_entry_0", "Default"), - StringResource("revanced_start_page_home_entry_1", "Home"), - StringResource("revanced_start_page_search_entry_2", "Search"), - StringResource("revanced_start_page_subscriptions_entry_3", "Subscriptions"), - StringResource("revanced_start_page_explore_entry_4", "Explore"), - StringResource("revanced_start_page_shorts_entry_5", "Shorts"), - ) - ), - ArrayResource( - "revanced_start_page_values", - listOf( - StringResource("revanced_start_page_home_value_0", ""), - StringResource("revanced_start_page_home_value_1", "MAIN"), - StringResource("revanced_start_page_search_value_2", "open.search"), - StringResource("revanced_start_page_subscriptions_value_3", "open.subscriptions"), - StringResource("revanced_start_page_explore_value_4", "open.explore"), - StringResource("revanced_start_page_shorts_value_5", "open.shorts"), - ) - ) + key = "revanced_start_page", + summaryKey = null, ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt index a5e19026d7..caef4295b8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/startupshortsreset/DisableResumingShortsOnStartupPatch.kt @@ -1,21 +1,21 @@ package app.revanced.patches.youtube.layout.startupshortsreset -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.startupshortsreset.fingerprints.UserWasInShortsFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Disable resuming Shorts on startup", description = "Adds an option to disable the Shorts player from resuming on app startup when Shorts were last being watched.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -43,13 +43,10 @@ object DisableResumingShortsOnStartupPatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/DisableResumingStartupShortsPlayerPatch;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_disable_resuming_shorts_player", - StringResource("revanced_disable_resuming_shorts_player_title", "Disable resuming Shorts player"), - StringResource("revanced_disable_resuming_shorts_player_summary_on", "Shorts player will not resume on app startup"), - StringResource("revanced_disable_resuming_shorts_player_summary_off", "Shorts player will resume on app startup") - ) + SwitchPreference("revanced_disable_resuming_shorts_player") ) UserWasInShortsFingerprint.result?.apply { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt index 549a4d9fb6..10dadae37a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tablet/EnableTabletLayoutPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.layout.tablet -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -9,16 +8,17 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.tablet.fingerprints.GetFormFactorFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Enable tablet layout", description = "Adds an option to spoof the device form factor to a tablet which enables the tablet layout.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [CompatiblePackage("com.google.android.youtube")] ) @Suppress("unused") @@ -26,15 +26,9 @@ object EnableTabletLayoutPatch : BytecodePatch( setOf(GetFormFactorFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_tablet_layout", - StringResource("revanced_tablet_layout_enabled_title", "Enable tablet layout"), - StringResource("revanced_tablet_layout_summary_on", "Tablet layout is enabled"), - StringResource("revanced_tablet_layout_summary_off", "Tablet layout is disabled"), - StringResource("revanced_tablet_layout_user_dialog_message", "Community posts do not show up on tablet layouts") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_tablet_layout")) GetFormFactorFingerprint.result?.let { it.mutableMethod.apply { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt index e01ba4946e..bb96c3a630 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/TabletMiniPlayerPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.layout.tabletminiplayer -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.MethodFingerprint @@ -9,21 +8,22 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerDimensionsCalculatorParentFingerprint import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerOverrideFingerprint import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerOverrideNoContextFingerprint import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerResponseModelSizeCheckFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( name = "Tablet mini player", description = "Adds an option to enable the tablet mini player layout.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", arrayOf( @@ -51,14 +51,9 @@ object TabletMiniPlayerPatch : BytecodePatch( ) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_tablet_miniplayer", - StringResource("revanced_tablet_miniplayer_title", "Enable tablet mini player"), - StringResource("revanced_tablet_miniplayer_summary_on", "Mini player is enabled"), - StringResource("revanced_tablet_miniplayer_summary_off", "Mini player is disabled") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_tablet_miniplayer")) // First resolve the fingerprints via the parent fingerprint. MiniPlayerDimensionsCalculatorParentFingerprint.result diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt index 81605affc0..633efd8bcb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeBytecodePatch.kt @@ -1,7 +1,5 @@ package app.revanced.patches.youtube.layout.theme -import app.revanced.util.exception -import app.revanced.util.indexOfFirstWideLiteralInstructionValue import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -9,12 +7,14 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.seekbar.SeekbarColorBytecodePatch import app.revanced.patches.youtube.layout.theme.fingerprints.UseGradientLoadingScreenFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception +import app.revanced.util.indexOfFirstWideLiteralInstructionValue import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( @@ -25,7 +25,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction SeekbarColorBytecodePatch::class, ThemeResourcePatch::class, IntegrationsPatch::class, - SettingsPatch::class + SettingsPatch::class, + AddResourcesPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -95,20 +96,9 @@ object ThemeBytecodePatch : BytecodePatch( ) override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( - SwitchPreference( - "revanced_gradient_loading_screen", - StringResource("revanced_gradient_loading_screen_title", "Enable gradient loading screen"), - StringResource( - "revanced_gradient_loading_screen_summary_on", - "Loading screen will have a gradient background" - ), - StringResource( - "revanced_gradient_loading_screen_summary_off", - "Loading screen will have a solid background" - ), - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(SwitchPreference("revanced_gradient_loading_screen")) UseGradientLoadingScreenFingerprint.result?.mutableMethod?.apply { val isEnabledIndex = indexOfFirstWideLiteralInstructionValue(GRADIENT_LOADING_SCREEN_AB_CONSTANT) + 3 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt index 3baad14f3e..d379514e2e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemeResourcePatch.kt @@ -4,11 +4,11 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.preference.impl.InputType -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference -import app.revanced.patches.shared.settings.preference.impl.TextPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.InputType +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference +import app.revanced.patches.shared.misc.settings.preference.TextPreference import app.revanced.patches.youtube.layout.seekbar.SeekbarPreferencesPatch import app.revanced.patches.youtube.layout.theme.ThemeBytecodePatch.darkThemeBackgroundColor import app.revanced.patches.youtube.layout.theme.ThemeBytecodePatch.lightThemeBackgroundColor @@ -16,25 +16,22 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch import org.w3c.dom.Element @Patch( - dependencies = [SettingsPatch::class, ResourceMappingPatch::class, SeekbarPreferencesPatch::class] + dependencies = [ + SettingsPatch::class, + ResourceMappingPatch::class, + SeekbarPreferencesPatch::class, + AddResourcesPatch::class + ] ) internal object ThemeResourcePatch : ResourcePatch() { private const val SPLASH_BACKGROUND_COLOR = "revanced_splash_background_color" override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SeekbarPreferencesPatch.addPreferences( - SwitchPreference( - "revanced_seekbar_custom_color", - StringResource("revanced_seekbar_custom_color_title", "Enable custom seekbar color"), - StringResource("revanced_seekbar_custom_color_summary_on", "Custom seekbar color is shown"), - StringResource("revanced_seekbar_custom_color_summary_off", "Original seekbar color is shown") - ), - TextPreference( - "revanced_seekbar_custom_color_value", - StringResource("revanced_seekbar_custom_color_value_title", "Custom seekbar color"), - StringResource("revanced_seekbar_custom_color_value_summary", "The color of the seekbar"), - InputType.TEXT_CAP_CHARACTERS - ) + SwitchPreference("revanced_seekbar_custom_color"), + TextPreference("revanced_seekbar_custom_color_value", inputType = InputType.TEXT_CAP_CHARACTERS) ) // Edit theme colors via resources. @@ -73,9 +70,10 @@ internal object ThemeResourcePatch : ResourcePatch() { if (darkThemeBackgroundColor != null && lightThemeBackgroundColor != null) { val splashScreenResourceFiles = listOf( "res/drawable/quantum_launchscreen_youtube.xml", - "res/drawable-sw600dp/quantum_launchscreen_youtube.xml") + "res/drawable-sw600dp/quantum_launchscreen_youtube.xml" + ) - splashScreenResourceFiles.forEach editSplashScreen@ { resourceFile -> + splashScreenResourceFiles.forEach editSplashScreen@{ resourceFile -> context.xmlEditor[resourceFile].use { val layerList = it.file.getElementsByTagName("layer-list").item(0) as Element diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt index 79c1bef808..075eaa0edd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsPatch.kt @@ -10,9 +10,8 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable -import app.revanced.util.resource.ArrayResource -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.* +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.* import app.revanced.patches.youtube.layout.thumbnails.fingerprints.MessageDigestImageUrlFingerprint import app.revanced.patches.youtube.layout.thumbnails.fingerprints.MessageDigestImageUrlParentFingerprint import app.revanced.patches.youtube.layout.thumbnails.fingerprints.cronet.RequestFingerprint @@ -32,7 +31,12 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableMethod @Patch( name = "Alternative thumbnails", description = "Adds options to replace video thumbnails using the DeArrow API or image captures from the video.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class, AlternativeThumbnailsResourcePatch::class], + dependencies = [ + IntegrationsPatch::class, + SettingsPatch::class, + AlternativeThumbnailsResourcePatch::class, + AddResourcesPatch::class + ], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", @@ -113,114 +117,38 @@ object AlternativeThumbnailsPatch : BytecodePatch( } override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.LAYOUT.addPreferences( PreferenceScreen( "revanced_alt_thumbnail_preference_screen", - StringResource("revanced_alt_thumbnail_preference_screen_title", "Alternative thumbnails"), - listOf( + preferences = setOf( NonInteractivePreference( - StringResource("revanced_alt_thumbnail_about_title", "Thumbnails in use"), + "revanced_alt_thumbnail_about", null, // Summary is dynamically updated based on the current settings. tag = "app.revanced.integrations.youtube.settings.preference.AlternativeThumbnailsStatusPreference" ), - SwitchPreference( - "revanced_alt_thumbnail_dearrow", - StringResource("revanced_alt_thumbnail_dearrow_title", "Enable DeArrow thumbnails"), - StringResource("revanced_alt_thumbnail_dearrow_summary_on", "Using DeArrow thumbnails"), - StringResource("revanced_alt_thumbnail_dearrow_summary_off", "Not using DeArrow thumbnails") - ), - SwitchPreference( - "revanced_alt_thumbnail_dearrow_connection_toast", - StringResource("revanced_alt_thumbnail_dearrow_connection_toast_title", "Show a toast if API is not available"), - StringResource("revanced_alt_thumbnail_dearrow_connection_toast_summary_on", "Toast is shown if DeArrow is not available"), - StringResource("revanced_alt_thumbnail_dearrow_connection_toast_summary_off", "Toast is not shown if DeArrow is not available") - ), - TextPreference( - "revanced_alt_thumbnail_dearrow_api_url", - StringResource( - "revanced_alt_thumbnail_dearrow_api_url_title", - "DeArrow API endpoint" - ), - StringResource( - "revanced_alt_thumbnail_dearrow_api_url_summary", - "The URL of the DeArrow thumbnail cache endpoint. " + - "Do not change this unless you know what you\\\'re doing" - ), - ), + SwitchPreference("revanced_alt_thumbnail_dearrow"), + SwitchPreference("revanced_alt_thumbnail_dearrow_connection_toast"), + TextPreference("revanced_alt_thumbnail_dearrow_api_url"), NonInteractivePreference( - StringResource( - "revanced_alt_thumbnail_dearrow_about_title", - "About DeArrow" - ), - StringResource( - "revanced_alt_thumbnail_dearrow_about_summary", - "DeArrow provides crowd-sourced thumbnails for YouTube videos. " + - "These thumbnails are often more relevant than those provided by YouTube. " + - "If enabled, video URLs will be sent to the API server and no other data is sent" - + "\\n\\nTap here to learn more about DeArrow" - ), + "revanced_alt_thumbnail_dearrow_about", // Custom about preference with link to the DeArrow website. tag = "app.revanced.integrations.youtube.settings.preference.AlternativeThumbnailsAboutDeArrowPreference", selectable = true ), - SwitchPreference( - "revanced_alt_thumbnail_stills", - StringResource("revanced_alt_thumbnail_stills_title", "Enable still video captures"), - StringResource("revanced_alt_thumbnail_stills_summary_on", "Using YouTube still video captures"), - StringResource("revanced_alt_thumbnail_stills_summary_off", "Not using YouTube still video captures") - ), + SwitchPreference("revanced_alt_thumbnail_stills"), ListPreference( "revanced_alt_thumbnail_stills_time", - StringResource("revanced_alt_thumbnail_stills_time_title", "Video time to take the still from"), - ArrayResource( - "revanced_alt_thumbnail_type_entries", - listOf( - StringResource("revanced_alt_thumbnail_stills_time_entry_1", "Beginning of video"), - StringResource("revanced_alt_thumbnail_stills_time_entry_2", "Middle of video"), - StringResource("revanced_alt_thumbnail_stills_time_entry_3", "End of video"), - ) - ), - ArrayResource( - "revanced_alt_thumbnail_stills_time_entry_values", - listOf( - StringResource("revanced_alt_thumbnail_stills_time_entry_value_1", "1"), - StringResource("revanced_alt_thumbnail_stills_time_entry_value_2", "2"), - StringResource("revanced_alt_thumbnail_stills_time_entry_value_3", "3"), - ) - ) - ), - SwitchPreference( - "revanced_alt_thumbnail_stills_fast", - StringResource( - "revanced_alt_thumbnail_stills_fast_title", - "Use fast still captures" - ), - StringResource( - "revanced_alt_thumbnail_stills_fast_summary_on", - "Using medium quality still captures. " + - "Thumbnails will load faster, but live streams, unreleased, " + - "or very old videos may show blank thumbnails" - ), - StringResource( - "revanced_alt_thumbnail_stills_fast_summary_off", - "Using high quality still captures" - ) + summaryKey = null, ), + SwitchPreference("revanced_alt_thumbnail_stills_fast"), NonInteractivePreference( - StringResource( - "revanced_alt_thumbnail_stills_about_title", - "About still video captures" - ), - StringResource( - "revanced_alt_thumbnail_stills_about_summary", - "Still captures are taken from the beginning/middle/end of each video. " + - "These images are built into YouTube and no external API is used" - ), + "revanced_alt_thumbnail_stills_about", // Restore the preference dividers to keep it from looking weird. selectable = true ) - ), - StringResource("revanced_alt_thumbnail_preference_screen_summary", "Video thumbnail settings") + ) ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt index 5cb9e0a03a..d926b4a4d2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/AlternativeThumbnailsResourcePatch.kt @@ -5,7 +5,6 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch -import app.revanced.util.copyStrings @Patch( dependencies = [ @@ -15,6 +14,6 @@ import app.revanced.util.copyStrings ) internal object AlternativeThumbnailsResourcePatch : ResourcePatch() { override fun execute(context: ResourceContext) { - context.copyStrings("alternativethumbnails/host/values/strings.xml") + AddResourcesPatch(this::class) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt index 84ea6def21..66b01d8e4a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/announcements/AnnouncementsPatch.kt @@ -1,23 +1,23 @@ package app.revanced.patches.youtube.misc.announcements -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.shared.fingerprints.MainActivityFingerprint +import app.revanced.util.exception import com.android.tools.smali.dexlib2.Opcode @Patch( name = "Announcements", description = "Adds an option to show announcements from ReVanced on app startup.", compatiblePackages = [CompatiblePackage("com.google.android.youtube")], - dependencies = [SettingsPatch::class] + dependencies = [SettingsPatch::class,AddResourcesPatch::class] ) @Suppress("unused") object AnnouncementsPatch : BytecodePatch( @@ -27,6 +27,10 @@ object AnnouncementsPatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/announcements/AnnouncementsPatch;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.MISC.addPreferences(SwitchPreference("revanced_announcements")) + val onCreateMethod = MainActivityFingerprint.result?.let { it.mutableClass.methods.find { method -> method.name == "onCreate" } } ?: throw MainActivityFingerprint.exception @@ -38,26 +42,5 @@ object AnnouncementsPatch : BytecodePatch( "invoke-static { v1 }, $INTEGRATIONS_CLASS_DESCRIPTOR->showAnnouncement(Landroid/app/Activity;)V" ) - SettingsPatch.PreferenceScreen.MISC.addPreferences( - SwitchPreference( - "revanced_announcements", - StringResource( - "revanced_announcements_title", - "Show ReVanced announcements" - ), - StringResource( - "revanced_announcements_summary_on", - "Announcements are shown on startup" - ), - StringResource( - "revanced_announcements_summary_off", - "Announcements are not shown on startup" - ), - StringResource( - "revanced_announcements_enabled_summary", - "Show announcements on startup" - ), - ) - ) } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt index e0e530dd5a..472fa4db36 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch.kt @@ -7,8 +7,8 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.autorepeat.fingerprints.AutoRepeatFingerprint import app.revanced.patches.youtube.misc.autorepeat.fingerprints.AutoRepeatParentFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch @@ -18,7 +18,7 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( name = "Always repeat", description = "Adds an option to always repeat videos when they end.", - dependencies = [IntegrationsPatch::class], + dependencies = [IntegrationsPatch::class,AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", @@ -43,14 +43,9 @@ object AutoRepeatPatch : BytecodePatch( setOf(AutoRepeatParentFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.MISC.addPreferences( - SwitchPreference( - "revanced_auto_repeat", - StringResource("revanced_auto_repeat_title", "Enable auto-repeat"), - StringResource("revanced_auto_repeat_summary_on", "Auto-repeat is enabled"), - StringResource("revanced_auto_repeat_summary_off", "Auto-repeat is disabled") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.MISC.addPreferences(SwitchPreference("revanced_auto_repeat")) //Get Result from the ParentFingerprint which is the playMethod we need to get. val parentResult = AutoRepeatParentFingerprint.result diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/DebuggingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/DebuggingPatch.kt index 3b71127d8d..01576ee2cb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/DebuggingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/DebuggingPatch.kt @@ -4,64 +4,32 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( name = "Enable debugging", description = "Adds options for debugging.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [CompatiblePackage("com.google.android.youtube")] ) @Suppress("unused") object DebuggingPatch : ResourcePatch() { override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.MISC.addPreferences( - app.revanced.patches.shared.settings.preference.impl.PreferenceScreen( + PreferenceScreen( "revanced_debug_preference_screen", - StringResource("revanced_debug_preference_screen_title", "Debugging"), - listOf( - SwitchPreference( - "revanced_debug", - StringResource("revanced_debug_title", "Debug logging"), - StringResource("revanced_debug_summary_on", "Debug logs are enabled"), - StringResource("revanced_debug_summary_off", "Debug logs are disabled") - ), - SwitchPreference( - "revanced_debug_protobuffer", - StringResource( - "revanced_debug_protobuffer_title", - "Log protocol buffer" - ), - StringResource("revanced_debug_protobuffer_summary_on", "Debug logs include proto buffer"), - StringResource("revanced_debug_protobuffer_summary_off", "Debug logs do not include proto buffer") - ), - SwitchPreference( - "revanced_debug_stacktrace", - StringResource( - "revanced_debug_stacktrace_title", - "Log stack traces" - ), - StringResource("revanced_debug_stacktrace_summary_on", "Debug logs include stack trace"), - StringResource("revanced_debug_stacktrace_summary_off", "Debug logs do not include stack trace") - ), - SwitchPreference( - "revanced_debug_toast_on_error", - StringResource( - "revanced_debug_toast_on_error_title", - "Show toast on ReVanced error" - ), - StringResource("revanced_debug_toast_on_error_summary_on", "Toast shown if error occurs"), - StringResource("revanced_debug_toast_on_error_summary_off", "Toast not shown if error occurs"), - StringResource("revanced_debug_toast_on_error_user_dialog_message", - "Turning off error toasts hides all ReVanced error notifications." - + "\\n\\nYou will not be notified of any unexpected events." - ) - ), - ), - StringResource("revanced_debug_preference_screen_summary", "Enable or disable debugging options") + preferences = setOf( + SwitchPreference("revanced_debug"), + SwitchPreference("revanced_debug_protobuffer"), + SwitchPreference("revanced_debug_stacktrace"), + SwitchPreference("revanced_debug_toast_on_error") + ) ) ) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt index c438804555..4374787d8d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/dimensions/spoof/SpoofDeviceDimensionsPatch.kt @@ -1,21 +1,21 @@ package app.revanced.patches.youtube.misc.dimensions.spoof -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.dimensions.spoof.fingerprints.DeviceDimensionsModelToStringFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception @Patch( name = "Spoof device dimensions", description = "Adds an option to spoof the device dimensions which unlocks higher video qualities if they aren't available on the device.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", @@ -41,18 +41,9 @@ object SpoofDeviceDimensionsPatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/spoof/SpoofDeviceDimensionsPatch;" override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.MISC.addPreferences( - SwitchPreference( - "revanced_spoof_device_dimensions", - StringResource("revanced_spoof_device_dimensions_title", "Spoof device dimensions"), - StringResource("revanced_spoof_device_dimensions_summary_on", "Device dimensions spoofed"), - StringResource( - "revanced_spoof_device_dimensions_summary_off", - "Device dimensions not spoofed\\n\\n" - + "Spoofing the device dimensions can unlock higher video qualities but unknown side effects may occur" - ), - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.MISC.addPreferences(SwitchPreference("revanced_spoof_device_dimensions",)) DeviceDimensionsModelToStringFingerprint.result ?.mutableClass?.methods?.find { method -> method.name == "" } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt index 55f3a8e4f7..0bcfcf2742 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.misc.fix.playback -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels @@ -9,14 +8,15 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.fix.playback.fingerprints.* import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.video.information.VideoInformationPatch import app.revanced.patches.youtube.video.playerresponse.PlayerResponseMethodHookPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction @@ -27,7 +27,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction PlayerTypeHookPatch::class, PlayerResponseMethodHookPatch::class, VideoInformationPatch::class, - SpoofSignatureResourcePatch::class + SpoofSignatureResourcePatch::class, + AddResourcesPatch::class ] ) object SpoofSignaturePatch : BytecodePatch( @@ -46,67 +47,16 @@ object SpoofSignaturePatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/spoof/SpoofSignaturePatch;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.MISC.addPreferences( PreferenceScreen( "revanced_spoof_signature_verification", - StringResource( - "revanced_spoof_signature_verification_title", - "Spoof app signature" + preferences = setOf( + SwitchPreference("revanced_spoof_signature_verification_enabled"), + SwitchPreference("revanced_spoof_signature_in_feed_enabled"), + SwitchPreference("revanced_spoof_storyboard") ), - listOf( - SwitchPreference( - "revanced_spoof_signature_verification_enabled", - StringResource("revanced_spoof_signature_verification_enabled_title", "Spoof app signature"), - StringResource( - "revanced_spoof_signature_verification_enabled_summary_on", - "App signature spoofed\\n\\n" - + "Side effects include:\\n" - + "• Enhanced bitrate is not available\\n" - + "• Videos cannot be downloaded\\n" - + "• No seekbar thumbnails for paid videos" - ), - StringResource( - "revanced_spoof_signature_verification_enabled_summary_off", - "App signature not spoofed\\n\\nVideo playback may not work" - ), - StringResource( - "revanced_spoof_signature_verification_enabled_user_dialog_message", - "Turning off this setting will cause video playback issues." - ) - ), - SwitchPreference( - "revanced_spoof_signature_in_feed_enabled", - StringResource("revanced_spoof_signature_in_feed_enabled_title", "Spoof app signature in feed"), - StringResource( - "revanced_spoof_signature_in_feed_enabled_summary_on", - "App signature spoofed\\n\\n" - + "Side effects include:\\n" - + "• Feed videos are missing subtitles\\n" - + "• Automatically played feed videos will show up in your watch history" - ), - StringResource( - "revanced_spoof_signature_in_feed_enabled_summary_off", - "App signature not spoofed for feed videos\\n\\n" - + "Feed videos will play for less than 1 minute before encountering playback issues" - ) - ), - SwitchPreference( - "revanced_spoof_storyboard", - StringResource("revanced_spoof_storyboard_title", "Spoof storyboard"), - StringResource("revanced_spoof_storyboard_summary_on", "Storyboard spoofed"), - StringResource( - "revanced_spoof_storyboard_summary_off", - "Storyboard not spoofed\\n\\n" - + "Side effects include:\\n" - + "• No ambient mode\\n" - + "• Seekbar thumbnails are hidden" - ) - ) - ), - StringResource( - "revanced_spoof_signature_verification_summary", - "Spoof the app signature to prevent playback issues" - ) ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt index 884d1237bc..54bfa75406 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignatureResourcePatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.misc.fix.playback import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class]) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt index ecf61e2e2a..ff73df5a02 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.misc.gms import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint -import app.revanced.patches.shared.misc.gms.AbstractGmsCoreSupportPatch +import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch import app.revanced.patches.youtube.layout.buttons.cast.HideCastButtonPatch import app.revanced.patches.youtube.misc.fix.playback.ClientSpoofPatch import app.revanced.patches.youtube.misc.gms.Constants.REVANCED_YOUTUBE_PACKAGE_NAME @@ -13,7 +13,7 @@ import app.revanced.patches.youtube.shared.fingerprints.HomeActivityFingerprint @Suppress("unused") -object GmsCoreSupportPatch : AbstractGmsCoreSupportPatch( +object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( fromPackageName = YOUTUBE_PACKAGE_NAME, toPackageName = REVANCED_YOUTUBE_PACKAGE_NAME, primeMethodFingerprint = PrimeMethodFingerprint, @@ -30,7 +30,7 @@ object GmsCoreSupportPatch : AbstractGmsCoreSupportPatch( HideCastButtonPatch::class, ClientSpoofPatch::class ), - abstractGmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, + gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, compatiblePackages = setOf( CompatiblePackage( "com.google.android.youtube", setOf( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt index 5a3ae0bce3..151e1b6c60 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt @@ -1,26 +1,27 @@ package app.revanced.patches.youtube.misc.gms import app.revanced.patcher.data.ResourceContext -import app.revanced.patches.shared.misc.gms.AbstractGmsCoreSupportResourcePatch -import app.revanced.patches.shared.settings.preference.impl.IntentPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportResourcePatch +import app.revanced.patches.shared.misc.settings.preference.IntentPreference import app.revanced.patches.youtube.misc.gms.Constants.REVANCED_YOUTUBE_PACKAGE_NAME import app.revanced.patches.youtube.misc.gms.Constants.YOUTUBE_PACKAGE_NAME import app.revanced.patches.youtube.misc.settings.SettingsPatch -import app.revanced.util.resource.StringResource -object GmsCoreSupportResourcePatch : AbstractGmsCoreSupportResourcePatch( +object GmsCoreSupportResourcePatch : BaseGmsCoreSupportResourcePatch( fromPackageName = YOUTUBE_PACKAGE_NAME, toPackageName = REVANCED_YOUTUBE_PACKAGE_NAME, spoofedPackageSignature = "24bb24c05e47e0aefa68a58a766179d9b613a600", - dependencies = setOf(SettingsPatch::class) + dependencies = setOf(SettingsPatch::class, AddResourcesPatch::class) ) { override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.MISC.addPreferences( IntentPreference( - StringResource("microg_settings", "GmsCore Settings"), - StringResource("microg_settings_summary", "Settings for GmsCore"), - IntentPreference.Intent("", "org.microg.gms.ui.SettingsActivity") { + "microg_settings", + intent = IntentPreference.Intent("", "org.microg.gms.ui.SettingsActivity") { "$gmsCoreVendor.android.gms" } ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/IntegrationsPatch.kt index 7a1d842d8b..ed161b2540 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/IntegrationsPatch.kt @@ -1,11 +1,11 @@ package app.revanced.patches.youtube.misc.integrations import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch import app.revanced.patches.youtube.misc.integrations.fingerprints.* @Patch(requiresIntegrations = true) -object IntegrationsPatch : AbstractIntegrationsPatch( +object IntegrationsPatch : BaseIntegrationsPatch( setOf( ApplicationInitFingerprint, StandalonePlayerActivityFingerprint, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/APIPlayerServiceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/APIPlayerServiceFingerprint.kt index 5249509177..ca4ad846e6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/APIPlayerServiceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/APIPlayerServiceFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/ApplicationInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/ApplicationInitFingerprint.kt index 346fb9168f..0cc958cb8c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/ApplicationInitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/ApplicationInitFingerprint.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint /** * Hooks the context when the app is launched as a regular application (and is not an embedded video playback). diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt index 65b7d08977..1b57540675 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerFingerprint.kt index 0e6ddaf6bd..fbc2ab0dbf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/EmbeddedPlayerFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt index 4079d7e3c5..77eeec32dc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt index 6b3961d547..196994f49b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt index dbe1d9bc01..9148f5fdb5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.misc.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt index f0e4f466ef..663c72fdd3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/links/BypassURLRedirectsPatch.kt @@ -1,24 +1,24 @@ package app.revanced.patches.youtube.misc.links -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.links.fingerprints.ABUriParserFingerprint import app.revanced.patches.youtube.misc.links.fingerprints.HTTPUriParserFingerprint import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction @Patch( name = "Bypass URL redirects", description = "Adds an option to bypass URL redirects and open the original URL directly.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", @@ -40,14 +40,9 @@ object BypassURLRedirectsPatch : BytecodePatch( setOf(ABUriParserFingerprint, HTTPUriParserFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.MISC.addPreferences( - SwitchPreference( - "revanced_bypass_url_redirects", - StringResource("revanced_bypass_url_redirects_title", "Bypass URL redirects"), - StringResource("revanced_bypass_url_redirects_summary_on", "URL redirects are bypassed"), - StringResource("revanced_bypass_url_redirects_summary_off", "URL redirects are not bypassed"), - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.MISC.addPreferences(SwitchPreference("revanced_bypass_url_redirects" )) mapOf( ABUriParserFingerprint to 7, // Offset to Uri.parse. diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt index f05c071206..2fa9f8236f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/links/OpenLinksExternallyPatch.kt @@ -5,10 +5,10 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.all.misc.transformation.BaseTransformInstructionsPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch -import app.revanced.patches.all.misc.transformation.AbstractTransformInstructionsPatch import com.android.tools.smali.dexlib2.iface.ClassDef import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.instruction.Instruction @@ -19,6 +19,7 @@ import com.android.tools.smali.dexlib2.iface.reference.StringReference @Patch( name = "Open links externally", description = "Adds an option to always open links in your browser instead of in the in-app-browser.", + dependencies = [SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", @@ -39,7 +40,7 @@ import com.android.tools.smali.dexlib2.iface.reference.StringReference ] ) @Suppress("unused") -object OpenLinksExternallyPatch : AbstractTransformInstructionsPatch>( +object OpenLinksExternallyPatch : BaseTransformInstructionsPatch>( ) { override fun filterMap( classDef: ClassDef, method: Method, instruction: Instruction, instructionIndex: Int @@ -66,14 +67,9 @@ object OpenLinksExternallyPatch : AbstractTransformInstructionsPatch Background" - ) + "revanced_minimized_playback_enabled", + "revanced_minimized_playback_summary_on", + // Use horizontal dividers to keep the settings from looking weird. + // If PreferenceCategories are added, then this should be removed. + selectable = true ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/BottomControlsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/BottomControlsResourcePatch.kt index 23afdbb0cf..6dcc92c7dd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/BottomControlsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/BottomControlsResourcePatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.DomFileEditor -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import java.io.Closeable @Patch(dependencies = [ResourceMappingPatch::class]) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt index 82a27964c7..811836d4b8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.misc.privacy -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -10,20 +9,21 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.privacy.fingerprints.CopyTextFingerprint import app.revanced.patches.youtube.misc.privacy.fingerprints.SystemShareSheetFingerprint import app.revanced.patches.youtube.misc.privacy.fingerprints.YouTubeShareSheetFingerprint import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @Patch( name = "Remove tracking query parameter", description = "Adds an option to remove the tracking info from links you share.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", @@ -47,23 +47,9 @@ object RemoveTrackingQueryParameterPatch : BytecodePatch( private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/RemoveTrackingQueryParameterPatch;" override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.MISC.addPreferences( - SwitchPreference( - "revanced_remove_tracking_query_parameter", - StringResource( - "revanced_remove_tracking_query_parameter_title", - "Remove tracking query parameter" - ), - StringResource( - "revanced_remove_tracking_query_parameter_summary_on", - "Tracking query parameter is removed from links" - ), - StringResource( - "revanced_remove_tracking_query_parameter_summary_off", - "Tracking query parameter is not removed from links" - ), - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.MISC.addPreferences(SwitchPreference("revanced_remove_tracking_query_parameter")) fun MethodFingerprint.hook( getInsertIndex: PatternScanResult.() -> Int, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt index 2406671cc0..d2360b8f1c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt @@ -8,15 +8,15 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch -import app.revanced.patches.shared.settings.preference.impl.InputType -import app.revanced.patches.shared.settings.preference.impl.IntentPreference -import app.revanced.patches.shared.settings.preference.impl.TextPreference -import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.InputType +import app.revanced.patches.shared.misc.settings.preference.IntentPreference +import app.revanced.patches.shared.misc.settings.preference.TextPreference +import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.fingerprints.LicenseActivityOnCreateFingerprint import app.revanced.patches.youtube.misc.settings.fingerprints.SetThemeFingerprint import app.revanced.util.exception -import app.revanced.util.resource.StringResource import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.util.MethodUtil @@ -24,7 +24,12 @@ import java.io.Closeable @Patch( description = "Adds settings for ReVanced to YouTube.", - dependencies = [IntegrationsPatch::class, SettingsResourcePatch::class] + dependencies = [ + ChangePackageNamePatch::class, + IntegrationsPatch::class, + SettingsResourcePatch::class, + AddResourcesPatch::class + ] ) object SettingsPatch : BytecodePatch( setOf(LicenseActivityOnCreateFingerprint, SetThemeFingerprint) @@ -36,6 +41,18 @@ object SettingsPatch : BytecodePatch( private const val SET_THEME_METHOD_NAME: String = "setTheme" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + + PreferenceScreen.MISC.addPreferences( + TextPreference( + key = null, + titleKey = "revanced_pref_import_export_title", + summaryKey = "revanced_pref_import_export_summary", + inputType = InputType.TEXT_MULTI_LINE, + tag = "app.revanced.integrations.shared.settings.preference.ImportExportPreference" + ) + ) + SetThemeFingerprint.result?.mutableMethod?.let { setThemeMethod -> setThemeMethod.implementation!!.instructions.mapIndexedNotNull { i, instruction -> if (instruction.opcode == Opcode.RETURN_OBJECT) i else null @@ -74,16 +91,6 @@ object SettingsPatch : BytecodePatch( methods.removeIf { it.name != "onCreate" && !MethodUtil.isConstructor(it) } } } ?: throw LicenseActivityOnCreateFingerprint.exception - - PreferenceScreen.MISC.addPreferences( - TextPreference( - key = null, - title = StringResource("revanced_pref_import_export_title", "Import / Export"), - summary = StringResource("revanced_pref_import_export_summary", "Import / Export ReVanced settings"), - inputType = InputType.TEXT_MULTI_LINE, - tag = "app.revanced.integrations.shared.settings.preference.ImportExportPreference" - ) - ) } /** @@ -97,15 +104,16 @@ object SettingsPatch : BytecodePatch( ChangePackageNamePatch.setOrGetFallbackPackageName("com.google.android.apps.youtube") } - object PreferenceScreen : AbstractPreferenceScreen() { - val ADS = Screen("ads", "Ads", "Ad related settings") - val INTERACTIONS = Screen("interactions", "Interaction", "Settings related to interactions") - val LAYOUT = Screen("layout", "Layout", "Settings related to the layout") - val VIDEO = Screen("video", "Video", "Settings related to the video player") - val MISC = Screen("misc", "Misc", "Miscellaneous patches") + object PreferenceScreen : BasePreferenceScreen() { + val ADS = Screen("revanced_ads_screen") + val INTERACTIONS = Screen("revanced_interactions_screen") + val LAYOUT = Screen("revanced_layout_screen") + val VIDEO = Screen("revanced_video_screen") + val MISC = Screen("revanced_misc_screen") - override fun commit(screen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) = - SettingsResourcePatch.addPreference(screen) + override fun commit(screen: app.revanced.patches.shared.misc.settings.preference.PreferenceScreen) { + SettingsResourcePatch += screen + } } override fun close() = PreferenceScreen.close() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt index a7200b9607..b4b50461aa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsResourcePatch.kt @@ -2,19 +2,17 @@ package app.revanced.patches.youtube.misc.settings import app.revanced.patcher.data.ResourceContext import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch -import app.revanced.patches.shared.settings.preference.impl.IntentPreference +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.BaseSettingsResourcePatch +import app.revanced.patches.shared.misc.settings.preference.IntentPreference import app.revanced.util.ResourceGroup import app.revanced.util.copyResources -import app.revanced.util.resource.StringResource import org.w3c.dom.Element -object SettingsResourcePatch : AbstractSettingsResourcePatch( +object SettingsResourcePatch : BaseSettingsResourcePatch( IntentPreference( - StringResource("revanced_settings", "ReVanced"), - StringResource("revanced_settings_summary", "Settings for ReVanced"), - SettingsPatch.newIntent("revanced_settings") + "revanced_settings", + intent = SettingsPatch.newIntent("revanced_settings_intent") ) to "settings_fragment", dependencies = setOf( ResourceMappingPatch::class, @@ -27,6 +25,8 @@ object SettingsResourcePatch : AbstractSettingsResourcePatch( override fun execute(context: ResourceContext) { super.execute(context) + AddResourcesPatch(this::class) + // Used for a fingerprint from SettingsPatch. appearanceStringId = ResourceMappingPatch.resourceMappings.find { it.type == "string" && it.name == "app_theme_appearance_dark" diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt index 2c306b1594..aadee4ab84 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/zoomhaptics/ZoomHapticsPatch.kt @@ -7,15 +7,15 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.misc.zoomhaptics.fingerprints.ZoomHapticsFingerprint @Patch( name = "Disable zoom haptics", description = "Adds an option to disable haptics when zooming.", - dependencies = [SettingsPatch::class], + dependencies = [SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [CompatiblePackage("com.google.android.youtube")] ) @Suppress("unused") @@ -23,14 +23,9 @@ object ZoomHapticsPatch : BytecodePatch( setOf(ZoomHapticsFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.MISC.addPreferences( - SwitchPreference( - "revanced_disable_zoom_haptics", - StringResource("revanced_disable_zoom_haptics_title", "Disable zoom haptics"), - StringResource("revanced_disable_zoom_haptics_summary_on", "Haptics are disabled"), - StringResource("revanced_disable_zoom_haptics_summary_off", "Haptics are enabled") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.MISC.addPreferences(SwitchPreference("revanced_disable_zoom_haptics")) val zoomHapticsFingerprintMethod = ZoomHapticsFingerprint.result!!.mutableMethod diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/HDRBrightnessPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/HDRBrightnessPatch.kt index 6ecb54e144..f777c10a2f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/HDRBrightnessPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/hdrbrightness/HDRBrightnessPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.video.hdrbrightness.fingerprints.HDRBrightnessFingerprint @@ -17,7 +17,7 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference @Patch( name = "HDR auto brightness", description = "Adds an option to make the brightness of HDR videos follow the system default.", - dependencies = [IntegrationsPatch::class, SettingsPatch::class], + dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -41,14 +41,9 @@ object HDRBrightnessPatch : BytecodePatch( setOf(HDRBrightnessFingerprint) ) { override fun execute(context: BytecodeContext) { - SettingsPatch.PreferenceScreen.VIDEO.addPreferences( - SwitchPreference( - "revanced_hdr_auto_brightness", - StringResource("revanced_hdr_auto_brightness_title", "Enable auto HDR brightness"), - StringResource("revanced_hdr_auto_brightness_summary_on", "Auto HDR brightness is enabled"), - StringResource("revanced_hdr_auto_brightness_summary_off", "Auto HDR brightness is disabled") - ) - ) + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.VIDEO.addPreferences(SwitchPreference("revanced_hdr_auto_brightness")) val method = HDRBrightnessFingerprint.result!!.mutableMethod diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt index 1a24c838f3..8be8537e4b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/RememberVideoQualityPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.video.quality -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -9,10 +8,9 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.util.resource.ArrayResource -import app.revanced.patches.shared.settings.preference.impl.ListPreference -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.ListPreference +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.video.information.VideoInformationPatch @@ -20,6 +18,7 @@ import app.revanced.patches.youtube.video.quality.fingerprints.NewVideoQualityCh import app.revanced.patches.youtube.video.quality.fingerprints.SetQualityByIndexMethodClassFieldReferenceFingerprint import app.revanced.patches.youtube.video.quality.fingerprints.VideoQualityItemOnClickParentFingerprint import app.revanced.patches.youtube.video.quality.fingerprints.VideoQualitySetterFingerprint +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.FieldReference @@ -27,7 +26,12 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference @Patch( name = "Remember video quality", description = "Adds an option to remember the last video quality selected.", - dependencies = [IntegrationsPatch::class, VideoInformationPatch::class, SettingsPatch::class], + dependencies = [ + IntegrationsPatch::class, + VideoInformationPatch::class, + SettingsPatch::class, + AddResourcesPatch::class + ], compatiblePackages = [ CompatiblePackage( "com.google.android.youtube", [ @@ -49,68 +53,24 @@ object RememberVideoQualityPatch : BytecodePatch( ) ) { private const val INTEGRATIONS_CLASS_DESCRIPTOR = - "Lapp/revanced/integrations/youtube/patches/playback/quality/RememberVideoQualityPatch;" + "Lapp/revanced/integrations/youtube/patches/playback/quality/RememberVideoQualityPatch;" override fun execute(context: BytecodeContext) { - // This is bloated as each value has it's own String key/value - // ideally the entries would be raw values (and not a key to a String resource) - val entries = listOf( - StringResource("revanced_video_quality_default_entry_1", "Automatic quality"), - StringResource("revanced_video_quality_default_entry_2", "2160p"), - StringResource("revanced_video_quality_default_entry_3", "1440p"), - StringResource("revanced_video_quality_default_entry_4", "1080p"), - StringResource("revanced_video_quality_default_entry_5", "720p"), - StringResource("revanced_video_quality_default_entry_6", "480p"), - StringResource("revanced_video_quality_default_entry_7", "360p"), - StringResource("revanced_video_quality_default_entry_8", "240p"), - StringResource("revanced_video_quality_default_entry_9", "144p"), - ) - val entryValues = listOf( - StringResource("revanced_video_quality_default_entry_value_1", "-2"), - StringResource("revanced_video_quality_default_entry_value_2", "2160"), - StringResource("revanced_video_quality_default_entry_value_3", "1440"), - StringResource("revanced_video_quality_default_entry_value_4", "1080"), - StringResource("revanced_video_quality_default_entry_value_5", "720"), - StringResource("revanced_video_quality_default_entry_value_6", "480"), - StringResource("revanced_video_quality_default_entry_value_7", "360"), - StringResource("revanced_video_quality_default_entry_value_8", "240"), - StringResource("revanced_video_quality_default_entry_value_9", "144"), - ) + AddResourcesPatch(this::class) SettingsPatch.PreferenceScreen.VIDEO.addPreferences( - SwitchPreference( - "revanced_remember_video_quality_last_selected", - StringResource( - "revanced_remember_video_quality_last_selected_title", - "Remember video quality changes" - ), - StringResource( - "revanced_remember_video_quality_last_selected_summary_on", - "Quality changes apply to all videos" - ), - StringResource( - "revanced_remember_video_quality_last_selected_summary_off", - "Quality changes only apply to the current video" - ) - ), + SwitchPreference("revanced_remember_video_quality_last_selected"), ListPreference( - "revanced_video_quality_default_wifi", - StringResource( - "revanced_video_quality_default_wifi_title", - "Default video quality on Wi-Fi network" - ), - ArrayResource("revanced_video_quality_default_wifi_entry", entries), - ArrayResource("revanced_video_quality_default_wifi_entry_values", entryValues) - // default value and summary are set by integrations after loading + key = "revanced_video_quality_default_wifi", + summaryKey = null, + entriesKey = "revanced_video_quality_default_entries", + entryValuesKey = "revanced_video_quality_default_entry_values" ), ListPreference( - "revanced_video_quality_default_mobile", - StringResource( - "revanced_video_quality_default_mobile_title", - "Default video quality on mobile network" - ), - ArrayResource("revanced_video_quality_default_mobile_entries", entries), - ArrayResource("revanced_video_quality_default_mobile_values", entryValues) + key = "revanced_video_quality_default_mobile", + summaryKey = null, + entriesKey = "revanced_video_quality_default_entries", + entryValuesKey = "revanced_video_quality_default_entry_values" ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt index aaccdc7480..061207c085 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedPatch.kt @@ -1,6 +1,5 @@ package app.revanced.patches.youtube.video.speed.custom -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -11,14 +10,15 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable -import app.revanced.patches.shared.settings.preference.impl.InputType -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.TextPreference -import app.revanced.patches.youtube.misc.recyclerviewtree.hook.RecyclerViewTreeHookPatch +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.InputType +import app.revanced.patches.shared.misc.settings.preference.TextPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch +import app.revanced.patches.youtube.misc.recyclerviewtree.hook.RecyclerViewTreeHookPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.video.speed.custom.fingerprints.* +import app.revanced.util.exception import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @@ -34,7 +34,8 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableField LithoFilterPatch::class, SettingsPatch::class, RecyclerViewTreeHookPatch::class, - CustomPlaybackSpeedResourcePatch::class + CustomPlaybackSpeedResourcePatch::class, + AddResourcesPatch::class ] ) object CustomPlaybackSpeedPatch : BytecodePatch( @@ -52,19 +53,10 @@ object CustomPlaybackSpeedPatch : BytecodePatch( "Lapp/revanced/integrations/youtube/patches/playback/speed/CustomPlaybackSpeedPatch;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.VIDEO.addPreferences( - TextPreference( - key = "revanced_custom_playback_speeds", - title = StringResource( - "revanced_custom_playback_speeds_title", - "Custom playback speeds" - ), - inputType = InputType.TEXT_MULTI_LINE, - summary = StringResource( - "revanced_custom_playback_speeds_summary", - "Add or change the available playback speeds" - ) - ) + TextPreference("revanced_custom_playback_speeds", inputType = InputType.TEXT_MULTI_LINE) ) val arrayGenMethod = SpeedArrayGeneratorFingerprint.result?.mutableMethod!! diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedResourcePatch.kt index 93aaf552af..2fc51faaa8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/CustomPlaybackSpeedResourcePatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.youtube.video.speed.custom import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch internal object CustomPlaybackSpeedResourcePatch : ResourcePatch() { var speedUnavailableId: Long = -1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt index 3cf36b8b74..cc30d0de4c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/RememberPlaybackSpeedPatch.kt @@ -1,72 +1,55 @@ package app.revanced.patches.youtube.video.speed.remember -import app.revanced.util.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.util.resource.ArrayResource -import app.revanced.patches.shared.settings.preference.impl.ListPreference -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.ListPreference +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.video.information.VideoInformationPatch import app.revanced.patches.youtube.video.speed.custom.CustomPlaybackSpeedPatch import app.revanced.patches.youtube.video.speed.remember.fingerprint.InitializePlaybackSpeedValuesFingerprint +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction @Patch( - dependencies = [IntegrationsPatch::class, SettingsPatch::class, VideoInformationPatch::class, CustomPlaybackSpeedPatch::class] + dependencies = [ + IntegrationsPatch::class, + SettingsPatch::class, + VideoInformationPatch::class, + CustomPlaybackSpeedPatch::class, + AddResourcesPatch::class + ] ) object RememberPlaybackSpeedPatch : BytecodePatch( setOf(InitializePlaybackSpeedValuesFingerprint) -){ +) { private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/playback/speed/RememberPlaybackSpeedPatch;" override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.VIDEO.addPreferences( - SwitchPreference( - "revanced_remember_playback_speed_last_selected", - StringResource( - "revanced_remember_playback_speed_last_selected_title", - "Remember playback speed changes" - ), - StringResource( - "revanced_remember_playback_speed_last_selected_summary_on", - "Playback speed changes apply to all videos" - ), - StringResource( - "revanced_remember_playback_speed_last_selected_summary_off", - "Playback speed changes only apply to the current video" - ) - ), + SwitchPreference("revanced_remember_playback_speed_last_selected"), ListPreference( - "revanced_playback_speed_default", - StringResource( - "revanced_playback_speed_default_title", - "Default playback speed" - ), - // Dummy data: - // Entries and values are set by Integrations code based on the actual speeds available, - // and the values set here are ignored and do nothing. - ArrayResource( - "revanced_playback_speed_default_entries", - listOf(StringResource("revanced_playback_speed_default_entries", "1.0x")) - ), - ArrayResource( - "revanced_playback_speed_default_entry_values", - listOf(StringResource("revanced_playback_speed_default_entry_value", "1.0")) - ) + key = "revanced_playback_speed_default", + summaryKey = null, + // Entries and values are set by Integrations code based on the actual speeds available. + entriesKey = null, + entryValuesKey = null ) ) VideoInformationPatch.onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "newVideoStarted") VideoInformationPatch.userSelectedPlaybackSpeedHook( - INTEGRATIONS_CLASS_DESCRIPTOR, "userSelectedPlaybackSpeed") + INTEGRATIONS_CLASS_DESCRIPTOR, "userSelectedPlaybackSpeed" + ) /* * Hook the code that is called when the playback speeds are initialized, and sets the playback speed diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt index bbe8152536..7221e80b1d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/RestoreOldVideoQualityMenuResourcePatch.kt @@ -4,25 +4,22 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch -import app.revanced.util.resource.StringResource -import app.revanced.patches.shared.settings.preference.impl.SwitchPreference +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.settings.SettingsPatch @Patch( - dependencies = [SettingsPatch::class, ResourceMappingPatch::class] + dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class] ) object RestoreOldVideoQualityMenuResourcePatch : ResourcePatch() { internal var videoQualityBottomSheetListFragmentTitle = -1L override fun execute(context: ResourceContext) { + AddResourcesPatch(this::class) + SettingsPatch.PreferenceScreen.VIDEO.addPreferences( - SwitchPreference( - "revanced_restore_old_video_quality_menu", - StringResource("revanced_restore_old_video_quality_menu_title", "Restore old video quality menu"), - StringResource("revanced_restore_old_video_quality_menu_summary_on", "Old video quality menu is shown"), - StringResource("revanced_restore_old_video_quality_menu_summary_off", "Old video quality menu is not shown") - ) + SwitchPreference("revanced_restore_old_video_quality_menu") ) fun findResource(name: String) = ResourceMappingPatch.resourceMappings.find { it.name == name }?.id diff --git a/src/main/kotlin/app/revanced/util/BytecodeUtils.kt b/src/main/kotlin/app/revanced/util/BytecodeUtils.kt index ea7e88d14c..f47ae90df3 100644 --- a/src/main/kotlin/app/revanced/util/BytecodeUtils.kt +++ b/src/main/kotlin/app/revanced/util/BytecodeUtils.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.patch.PatchException import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.mapping.misc.ResourceMappingPatch +import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.instruction.Instruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction diff --git a/src/main/kotlin/app/revanced/util/ResourceUtils.kt b/src/main/kotlin/app/revanced/util/ResourceUtils.kt index 8636fbf5a3..c5b502cb16 100644 --- a/src/main/kotlin/app/revanced/util/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/util/ResourceUtils.kt @@ -5,12 +5,30 @@ import app.revanced.patcher.util.DomFileEditor import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.util.resource.BaseResource import org.w3c.dom.Node +import org.w3c.dom.NodeList import java.io.InputStream import java.nio.file.Files import java.nio.file.StandardCopyOption private val classLoader = object {}.javaClass.classLoader +/** + * Returns a sequence for all child nodes. + */ +fun NodeList.asSequence() = (0 until this.length).asSequence().map { this.item(it) } + +/** + * Returns a sequence for all child nodes. + */ +fun Node.childElementsSequence() = this.childNodes.asSequence().filter { it.nodeType == Node.ELEMENT_NODE } + +/** + * Performs the given [action] on each child element. + */ +fun Node.forEachChildElement(action: (Node) -> Unit) = childElementsSequence().forEach { + action(it) +} + /** * Recursively traverse the DOM tree starting from the given root node. * @@ -21,26 +39,6 @@ fun Node.doRecursively(action: (Node) -> Unit) { for (i in 0 until this.childNodes.length) this.childNodes.item(i).doRecursively(action) } -/** - * Add strings from a hosting xml resource. - * - * @param host The hosting xml resource. Needs to be a valid strings.xml resource. - */ -fun ResourceContext.copyStrings(host: String) { - this.iterateXmlNodeChildren(host, "resources") { - // TODO: figure out why this is needed - if (!it.hasAttributes()) return@iterateXmlNodeChildren - - val attributes = it.attributes - val key = attributes.getNamedItem("name")!!.nodeValue!! - val value = it.textContent!! - - val formatted = attributes.getNamedItem("formatted") == null - - AddResourcesPatch.addString(key, value, formatted) - } -} - /** * Copy resources from the current class loader to the resource directory. * diff --git a/src/main/kotlin/app/revanced/util/resource/ArrayResource.kt b/src/main/kotlin/app/revanced/util/resource/ArrayResource.kt index eb4b846b81..190085bd54 100644 --- a/src/main/kotlin/app/revanced/util/resource/ArrayResource.kt +++ b/src/main/kotlin/app/revanced/util/resource/ArrayResource.kt @@ -1,28 +1,37 @@ package app.revanced.util.resource +import app.revanced.util.childElementsSequence import org.w3c.dom.Document +import org.w3c.dom.Node -// TODO: allow specifying an array resource file instead of using a list of StringResources /** * An array resource. * * @param name The name of the array resource. * @param items The items of the array resource. */ +@Suppress("MemberVisibilityCanBePrivate") class ArrayResource( name: String, - val items: List + val items: List, ) : BaseResource(name, "string-array") { override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = super.serialize(ownerDocument, resourceCallback).apply { setAttribute("name", name) items.forEach { item -> - resourceCallback.invoke(item) - - this.appendChild(ownerDocument.createElement("item").also { itemNode -> - itemNode.textContent = "@string/${item.name}" + appendChild(ownerDocument.createElement("item").also { itemNode -> + itemNode.textContent = item }) } } + + companion object { + fun fromNode(node: Node): ArrayResource { + val key = node.attributes.getNamedItem("name").textContent + val items = node.childElementsSequence().map { it.textContent }.toList() + + return ArrayResource(key, items) + } + } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/util/resource/BaseResource.kt b/src/main/kotlin/app/revanced/util/resource/BaseResource.kt index f8b22512fd..7093bffaf3 100644 --- a/src/main/kotlin/app/revanced/util/resource/BaseResource.kt +++ b/src/main/kotlin/app/revanced/util/resource/BaseResource.kt @@ -9,6 +9,7 @@ import org.w3c.dom.Element * @param name The name of the resource. * @param tag The tag of the resource. */ +@Suppress("MemberVisibilityCanBePrivate") abstract class BaseResource( val name: String, val tag: String diff --git a/src/main/kotlin/app/revanced/util/resource/StringResource.kt b/src/main/kotlin/app/revanced/util/resource/StringResource.kt index 9c1b6825c1..c825d67598 100644 --- a/src/main/kotlin/app/revanced/util/resource/StringResource.kt +++ b/src/main/kotlin/app/revanced/util/resource/StringResource.kt @@ -1,25 +1,41 @@ package app.revanced.util.resource +import app.revanced.patcher.patch.PatchException import org.w3c.dom.Document +import org.w3c.dom.Node /** * A string value. - * Represets a string in the strings.xml file. + * Represents a string in the strings.xml file. * * @param name The name of the string. * @param value The value of the string. - * @param formatted If the string is formatted. If false, the attribute will be set. + * @param formatted If the string is formatted. Defaults to `true`. */ class StringResource( name: String, val value: String, - val formatted: Boolean = true + val formatted: Boolean = true, ) : BaseResource(name, "string") { override fun serialize(ownerDocument: Document, resourceCallback: (BaseResource) -> Unit) = super.serialize(ownerDocument, resourceCallback).apply { // if the string is un-formatted, explicitly add the formatted attribute if (!formatted) setAttribute("formatted", "false") + if (value.contains(Regex("(? + + + + @string/revanced_spoof_app_version_target_entry_1 + @string/revanced_spoof_app_version_target_entry_2 + @string/revanced_spoof_app_version_target_entry_3 + @string/revanced_spoof_app_version_target_entry_4 + @string/revanced_spoof_app_version_target_entry_5 + + + 18.33.40 + 18.20.39 + 17.08.35 + 16.08.35 + 16.01.35 + + + + + @string/revanced_start_page_home_entry_0 + @string/revanced_start_page_home_entry_1 + @string/revanced_start_page_search_entry_2 + @string/revanced_start_page_subscriptions_entry_3 + @string/revanced_start_page_explore_entry_4 + @string/revanced_start_page_shorts_entry_5 + + + + MAIN + open.search + open.subscriptions + open.explore + open.shorts + + + + + @string/revanced_alt_thumbnail_stills_time_entry_1 + @string/revanced_alt_thumbnail_stills_time_entry_2 + @string/revanced_alt_thumbnail_stills_time_entry_3 + + + 1 + 2 + 3 + + + + + @string/revanced_video_quality_default_entry_1 + @string/revanced_video_quality_default_entry_2 + @string/revanced_video_quality_default_entry_3 + @string/revanced_video_quality_default_entry_4 + @string/revanced_video_quality_default_entry_5 + @string/revanced_video_quality_default_entry_6 + @string/revanced_video_quality_default_entry_7 + @string/revanced_video_quality_default_entry_8 + @string/revanced_video_quality_default_entry_9 + + + -2 + 2160 + 1440 + 1080 + 720 + 480 + 360 + 240 + 144 + + + + + + + @string/revanced_deleted_messages_entry_1 + @string/revanced_deleted_messages_entry_2 + @string/revanced_deleted_messages_entry_3 + + + hide + spoiler + cross-out + + + + + @string/revanced_hls_proxies_entry_1 + @string/revanced_hls_proxies_entry_2 + @string/revanced_hls_proxies_entry_3 + + + disabled + luminous + purpleadblock + + + + \ No newline at end of file diff --git a/src/main/resources/addresources/values/strings.xml b/src/main/resources/addresources/values/strings.xml new file mode 100644 index 0000000000..9618cb77e4 --- /dev/null +++ b/src/main/resources/addresources/values/strings.xml @@ -0,0 +1,1019 @@ + + + + ReVanced + Do you wish to proceed? + Reset + Refresh and restart + Restart + Import + Copy + ReVanced settings reset to default + Imported %d settings + Import failed: %s + + + GmsCore is not installed. Please install. + GmsCore is failing to run. Please follow the \"Don\'t kill my app\" guide for GmsCore. + + + + + Showing original YouTube thumbnails + Showing still video captures + Showing DeArrow thumbnails. If a video has no DeArrow thumbnails then the original YouTube thumbnails are shown + Showing DeArrow thumbnails. If a video has no DeArrow thumbnails then still video captures are shown + DeArrow temporarily not available (status code: %s) + DeArrow temporarily not available + + + ReVanced + ReVanced specific settings + Import / Export + Import / Export ReVanced settings + + + Ads + Ad related settings + Interactions + Settings related to interactions + Layout + Settings related to the layout + Video + Settings related to the video player + Misc + Miscellaneous patches + + + Debug logging + Debug logs are enabled + Debug logs are disabled + Debugging + Log protocol buffer + Debug logs include proto buffer + Debug logs do not include proto buffer + Log stack traces + Debug logs include stack trace + Debug logs do not include stack trace + Show toast on ReVanced error + Toast shown if error occurs + Toast not shown if error occurs + Turning off error toasts hides all ReVanced error notifications.\n\nYou will not be notified of any unexpected events. + Enable or disable debugging options + + + Ads + Ad related settings + Hide gray separator + Gray separators are hidden + Gray separators are shown + Hide \'Join\' button + Button is hidden + Button is shown + Hide channel watermark in video player + Watermark is hidden + Watermark is shown + Hide \'For you\' shelf in channel page + Shelf is hidden + Shelf is shown + Hide \'Notify me\' button + Button is hidden + Button is shown + Hide timed reactions + Timed reactions are hidden + Timed reactions are shown + Hide \'People also watched\' recommendations + Recommendations are hidden + Recommendations are shown + Hide search result shelf header + Shelf header is hidden + Shelf header is shown + Hide channel guidelines + Channel guidelines are hidden + Channel guidelines are shown + Hide expandable chip under videos + Expandable chips are hidden + Expandable chips are shown + Hide video quality menu footer + Video quality menu footer is hidden + Video quality menu footer is shown + Hide chapters in the video description + Chapters are hidden + Chapters are shown + Hide community posts + Community posts are hidden + Community posts are shown + Hide compact banners + Compact banners are hidden + Compact banners are shown + Hide movies section + Movies section is hidden + Movies section is shown + Hide feed surveys + Feed surveys are hidden + Feed surveys are shown + Hide community guidelines + Community guidelines are hidden + Community guidelines are shown + Hide subscribers community guidelines + Subscribers community guidelines are hidden + Subscribers community guidelines are shown + Hide channel member shelf + Channel member shelf is hidden + Channel member shelf is shown + Hide emergency boxes + Emergency boxes are hidden + Emergency boxes are shown + Hide info panels + Info panels are hidden + Info panels are shown + Hide medical panels + Medical panels are hidden + Medical panels are shown + Hide channel bar + Channel bar is hidden + Channel bar is shown + Hide quick actions in fullscreen + Quick actions are hidden + Quick actions are shown + Hide related videos in quick actions + Related videos are hidden + Related videos are shown + Hide image shelf in search results + Image shelf is hidden + Image shelf is shown + Hide latest posts + Latest posts are hidden + Latest posts are shown + Hide mix playlists + Mix playlists are hidden + Mix playlists are shown + Hide artist cards + Artist cards are hidden + Artist cards are shown + Hide chips shelf + Chips shelf is hidden + Chips shelf is shown + Hide components in the video description + Hide info cards section + Info cards section is hidden + Info cards section is shown + Hide game section + Game section is hidden + Game section is shown + Hide music section + Music section is hidden + Music section is shown + Hide podcast section + Podcast section is hidden + Podcast section is shown + Hide transcript section + Transcript section is hidden + Transcript section is shown + Hide components under the video description + Custom filter + Enable custom filter + Custom filter is enabled + Custom filter is disabled + Custom filter + List of component path builder strings to filter separated by new line + Hide components using custom filters + + + Hide general ads + General ads are hidden + General ads are shown + Hide fullscreen ads + Fullscreen ads are hidden + Fullscreen ads are shown + Hide buttoned ad + Buttoned ads are hidden + Buttoned ads are shown + Hide paid content + Paid content is hidden + Paid content is shown + Hide self sponsored cards + Self sponsored cards are hidden + Self sponsored cards are shown + Hide banner to view products + Banner is hidden + Banner is shown + Hide shopping links in video description + Shopping links are hidden + Shopping links are shown + Hide web search results + Web search results are hidden + Web search results are shown + Hide merchandise banners + Merchandise banners are hidden + Merchandise banners are shown + + + Hide YouTube Premium promotions + YouTube Premium promotions under video player are hidden + YouTube Premium promotions under video player are shown + + + Hide video ads + Video ads are hidden + Video ads are shown + + + URL copied to clipboard + URL with timestamp copied + Copy video URL settings + Show copy video URL button + Button is shown. Tap to copy video URL. Tap and hold to copy video URL with timestamp + Button is not shown + Show copy timestamp URL button + Button is shown. Tap to copy video URL with timestamp. Tap and hold to copy video without timestamp + Button is not shown + Settings related to copy URL buttons in video player + + + Remove viewer discretion dialog + Dialog will be removed + Dialog will be shown + This does not bypass the age restriction. It just accepts it automatically. + + + is not installed. Please install it. + External download settings + Show external download button + Download button shown in player + Download button not shown in player + Downloader package name + Package name of your installed external downloader app, such as NewPipe or Seal + Settings for using an external downloader + + + Disable precise seeking gesture + Gesture is disabled + Gesture is enabled + + + Enable seekbar tapping + Seekbar tapping is enabled + Seekbar tapping is disabled + + + Swipe controls + Enable brightness gesture + Brightness swipe is enabled + Brightness swipe is disabled + Enable volume gesture + Volume swipe is enabled + Volume swipe is disabled + Enable press-to-swipe gesture + Press-to-swipe is enabled + Press-to-swipe is disabled + Enable haptic feedback + Haptic feedback is enabled + Haptic feedback is disabled + Save and restore brightness + Save and restore brightness when exiting or entering fullscreen + Do not save and restore brightness when exiting or entering fullscreen + Swipe overlay timeout + The amount of milliseconds the overlay is visible + Swipe overlay text size + The text size for swipe overlay + Swipe background visibility + The visibility of swipe overlay background + Swipe magnitude threshold + The amount of threshold for swipe to occur + Control volume and brightness + + + Disable auto captions + Auto captions are disabled + Auto captions are enabled + + + Hide action buttons + Hide like and dislike buttons + Like and dislike buttons are hidden + Like and dislike buttons are shown + Hide live chat button + Live chat button is hidden + Live chat button is shown + Hide share button + Share button is hidden + Share button is shown + Hide report button + Report button is hidden + Report button is shown + Hide remix button + Remix button is hidden + Remix button is shown + Hide download button + Download button is hidden + Download button is shown + Hide thanks button + Thanks button is hidden + Thanks button is shown + Hide clip button + Clip button is hidden + Clip button is shown + Hide save to playlist button + Save button is hidden + Save button is shown + Hide shop button + Shop button is hidden + Shop button is shown + Hide or show buttons under videos + + + Hide autoplay button + Autoplay button is hidden + Autoplay button is shown + + + Hide captions button + Captions button is hidden + Captions button is shown + + + Hide cast button + Cast button is hidden + Cast button is shown + + + Navigation buttons + Hide home button + Home button is hidden + Home button is shown + Hide Shorts button + Shorts button is hidden + Shorts button is shown + Hide subscriptions button + Home subscriptions is hidden + Home subscriptions is shown + Hide create button + Create button is hidden + Create button is shown + Switch create with notifications button + Create button is switched with notifications + Create button is not switched with notifications + Hide or change buttons in the navigation bar + + + Player flyout menu items + Manage the visibility of player flyout menu items + Hide Captions menu + Captions menu item is hidden + Captions menu item is shown + Hide Additional settings menu + Additional settings menu item is hidden + Additional settings menu item is shown + Hide Loop video menu + Loop video menu item is hidden + Loop video menu item is shown + Hide Ambient mode menu + Ambient mode menu item is hidden + Ambient mode menu item is shown + Hide Report menu + Report menu item is hidden + Report menu item is shown + Hide Help menu + Help menu item is hidden + Help menu item is shown + Hide Speed menu + Speed menu item is hidden + Speed menu item is shown + Hide More info menu + More info menu item is hidden + More info menu item is shown + Hide Audio track menu + Audio track menu item is hidden + Audio track menu item is shown + Hide Watch in VR menu + Watch in VR menu item is hidden + Watch in VR menu item is shown + + + Hide previous & next video buttons + Buttons are hidden + Buttons are shown + + + Hide album cards + Album cards are hidden + Album cards are shown + + + Hide breaking news + Breaking news are hidden + Breaking news are shown + + + Comments + Hide comments section + Comment section is hidden + Comment section is shown + Hide preview comment + Preview comment is hidden + Preview comment is shown + Manage the visibility of comments section components + + + Hide crowdfunding box + Crowdfunding box is hidden + Crowdfunding box is shown + + + Hide end screen cards + End screen cards are hidden + End screen cards are shown + + + Hide filter bar + Hide in feed + Hidden in feed + Shown in feed + Hide in search + Hidden in search + Shown in search + Hide in related videos + Hidden in related videos + Shown in related videos + Manage the visibility of the filter bar in the feed, search and related videos + + + Hide floating microphone button + Microphone button hidden + Microphone button shown + + + Disable ambient mode in fullscreen + Ambient mode disabled + Ambient mode enabled + + + Hide info cards + Info cards are hidden + Info cards are shown + + + Hide \'Load More\' button + Button is hidden + Button is shown + + + Video + + + Disable rolling number animations + Rolling numbers are not animated + Rolling numbers are animated + + + Hide seekbar in video player + Video player seekbar is hidden + Video player seekbar is shown + Hide seekbar in video thumbnails + Thumbnail seekbar is hidden + Thumbnail seekbar is shown + + + Shorts components + Hide Shorts in feed + Shorts are hidden + Shorts are shown + Hide join button + Join button is hidden + Join button is shown + Hide subscribe button + Subscribe button is hidden + Subscribe button is shown + Hide subscribe button when paused + Subscribe button is hidden + Subscribe button is shown + Hide thanks button + Thanks button is hidden + Thanks button is shown + Hide comments button + Comments button is hidden + Comments button is shown + Hide remix button + Remix button is hidden + Remix button is shown + Hide share button + Share button is hidden + Share button is shown + Hide info panel + Info panel is hidden + Info panel is shown + Hide channel bar + Channel bar is hidden + Channel bar is shown + Hide sound button + Sound button is hidden + Sound button is shown + Hide navigation bar + Navigation bar is hidden + Navigation bar is shown + Manage the visibility of Shorts components + + + Disable suggested video end screen + Suggested videos will be disabled + Suggested videos will be shown + + + Hide video timestamp + Timestamp is hidden + Timestamp is shown + + + Hide player popup panels + Player popup panels are hidden + Player popup panels are shown + + + Player overlay opacity + Opacity value between 0-100, where 0 is transparent + + + Return YouTube Dislike + Settings for Return YouTube Dislike + Hidden + Dislikes temporarily not available (API timed out) + Dislikes not available (status %d) + Dislikes not available (client API limit reached) + Dislikes not available (%s) + + Reload video to vote using ReturnYouTubeDislike + Return YouTube Dislike + Dislikes are shown + Dislikes are not shown + Show dislikes on Shorts + Dislikes shown on Shorts %s + Dislikes hidden on Shorts + Limitation: Dislikes may not appear in incognito mode + Dislikes as percentage + Dislikes shown as percentage + Dislikes shown as number + Compact like button + Like button styled for minimum width + Like button styled for best appearance + Show a toast if API is not available + Toast is shown if Return YouTube Dislike is not available + Toast is not shown if Return YouTube Dislike is not available + About + ReturnYouTubeDislike.com + Data is provided by the Return YouTube Dislike API. Tap here to learn more + ReturnYouTubeDislike API statistics of this device + API response time, average + API response time, minimum + API response time, maximum + API response time, last video + Dislikes temporarily not available - Client API rate limit in effect + API fetch votes, number of calls + No network calls made + %d network calls made + API fetch votes, number of timeouts + No + network calls timed out + %d network calls timed out + API client rate limits + No client rate limits encountered + Client rate limit encountered %d times + %d milliseconds + + + Enable wide search bar + Wide search bar is enabled + Wide search bar is disabled + + + Restore old seekbar thumbnails + Seekbar thumbnails will appear above the seekbar + Seekbar thumbnails will appear in fullscreen + + + Seekbar + Settings for the seekbar + + + SponsorBlock + SponsorBlock related settings + Enable SponsorBlock + SponsorBlock is a crowd-sourced system for skipping annoying parts of YouTube videos + Appearance + Show voting button + Segment voting button is shown + Segment voting button is not shown + Use compact skip button + Skip button styled for minimum width + Skip button styled for best appearance + Automatically hide skip button + Skip button hides after a few seconds + Skip button displayed for entire segment + Show a toast when skipping automatically + Toast is shown when a segment is automatically skipped. Tap here to see an example + Toast is not shown. Tap here to see an example + Show video length without segments + Video length minus all segments, shown in parentheses next to the full video length + Full video length shown + Creating new segments + Show create new segment button + Create new segment button is shown + Create new segment button is not shown + Adjust new segment step + Number of milliseconds the time adjustment buttons move when creating new segments + Value must be a positive number + View guidelines + Guidelines contain rules and tips for creating new segments + Follow the guidelines + Read the SponsorBlock guidelines before creating new segments + Already read + Show me + General + Show a toast if API is not available + Toast is shown if SponsorBlock is not available + Toast is not shown if SponsorBlock is not available + Enable skip count tracking + Lets the SponsorBlock leaderboard know how much time is saved. A message is sent to the leaderboard each time a segment is skipped + Skip count tracking is not enabled + Minimum segment duration + Segments shorter than this value (in seconds) will not be shown or skipped + Your private user id + This should be kept private. This is like a password and should not be shared with anyone. If someone has this, they can impersonate you + Private user id must be at least 30 characters long + Change API URL + The address SponsorBlock uses to make calls to the server. Do not change this unless you know what you\'re doing + API URL reset + API URL is invalid + API URL changed + Import/Export settings + Copy + Your SponsorBlock JSON configuration that can be imported/exported to ReVanced and other SponsorBlock platforms %s + This includes your private user id. Be sure to share this wisely + Settings imported successfully + Failed to import: %s + Failed to export: %s + Your settings contain a private SponsorBlock userid.\n\nYour user id is like a password and it should never be shared.\n + Do not show again + Change segment behavior + Sponsor + Paid promotion, paid referrals and direct advertisements. Not for self-promotion or free shout-outs to causes/creators/websites/products they like + Unpaid/Self Promotion + Similar to \'Sponsor\' except for unpaid or self promotion. Includes sections about merchandise, donations, or information about who they collaborated with + Interaction Reminder (Subscribe) + A short reminder to like, subscribe or follow them in the middle of content. If it is long or about something specific, it should instead be under self promotion + Highlight + The part of the video that most people are looking for + Intermission/Intro Animation + An interval without actual content. Could be a pause, static frame, or repeating animation. Does not include transitions containing information + Endcards/Credits + Credits or when the YouTube endcards appear. Not for conclusions with information + Preview/Recap/Hook + Collection of clips that show what is coming up or what happened in the video or in other videos of a series, where all information is repeated elsewhere + Filler Tangent/Jokes + Tangential scenes added only for filler or humor that are not required to understand the main content of the video. Does not include segments providing context or background details + Music: Non-Music Section + Only for use in music videos. Sections of music videos without music, that aren\'t already covered by another category + Skip + Highlight + Skip sponsor + Skip promo + Skip interact + Skip to highlight + Skip intro + Skip intermission + Skip intermission + Skip outro + Skip preview + Skip preview + Skip recap + Skip filler + Skip non-music + Skip segment + Skipped sponsor + Skipped self promotion + Skipped annoying reminder + Skipped to highlight + Skipped intro + Skipped intermission + Skipped intermission + Skipped outro + Skipped preview + Skipped preview + Skipped recap + Skipped filler + Skipped a non-music section + Skipped unsubmitted segment + Skipped multiple segments + Skip automatically + Skip automatically once + Show a skip button + Show in seek bar + Disable + Unable to submit segment: %s + SponsorBlock is temporarily down + Unable to submit segment (status: %d %s) + Unable to submit segment.\nRate Limited (too many from the same user or IP) + Can\'t submit the segment: %s + Can\'t submit the segment.\nAlready exists + Segment submitted successfully + SponsorBlock temporarily not available + SponsorBlock temporarily not available (status %d) + SponsorBlock temporarily not available (API timed out) + Unable to vote for segment (API timed out) + Unable to vote for segment (status: %d %s) + Unable to vote for segment: %s + Upvote + Downvote + Change category + There are no segments to vote for + Choose the segment category + Category is disabled in settings. Enable category to submit. + New SponsorBlock segment + Set %02d:%02d:%03d as the start or end of a new segment? + start + end + now + Time the segment begins at + Time the segment ends at + Are the times correct? + The segment lasts from %02d:%02d to %02d:%02d (%d minutes %02d seconds)\nIs it ready to submit? + Start must be before the end + Mark two locations on the time bar first + Preview the segment, and ensure it skips smoothly + Edit timing of segment manually + Do you want to edit the timing for the start or end of the segment? + Invalid time given + Stats + Stats temporarily not available (API is down) + Loading... + SponsorBlock is disabled + Your username: <b>%s</b> + Tap here to change your username + Unable to change username: Status: %d %s + Username successfully changed + Your reputation is <b>%.2f</b> + You\'ve created <b>%s</b> segments + SponsorBlock leaderboard + You\'ve saved people from <b>%s</b> segments + Tap here to see the global stats and top contributors + That\'s <b>%s</b> of their lives.<br>Tap here to see the leaderboard + You\'ve skipped <b>%s</b> segments + That\'s <b>%s</b> + Reset skipped segments counter? + %s hours %s minutes + %s minutes %s seconds + %s seconds + Color: + Color changed + Color reset + Invalid color code + Reset color + Reset + About + sponsor.ajay.app + Data is provided by the SponsorBlock API. Tap here to learn more and see downloads for other platforms + + + Spoof app version + Version spoofed + Version not spoofed + App version will be spoofed to an older version of YouTube.\n\nThis will change the appearance and features of the app, but unknown side effects may occur.\n\nIf later turned off, it is recommended to clear the app data to prevent UI bugs. + Spoof app version target + 18.33.40 - Restore RYD Shorts incognito mode + 18.20.39 - Restore wide video speed & quality menu + 17.08.35 - Restore old UI layout + 16.08.35 - Restore explore tab + 16.01.35 - Restore fewer video player action buttons + + + Set start page + Default + Home + Search + Subscriptions + Explore + Shorts + + + Disable resuming Shorts player + Shorts player will not resume on app startup + Shorts player will resume on app startup + + + Enable tablet layout + Settings related to the layout + Tablet layout is enabled + Tablet layout is disabled + Community posts do not show up on tablet layouts + + + Enable tablet mini player + Mini player is enabled + Mini player is disabled + + + Enable gradient loading screen + Loading screen will have a gradient background + Loading screen will have a solid background + + + Enable custom seekbar color + Custom seekbar color is shown + Original seekbar color is shown + Custom seekbar color + The color of the seekbar + Invalid seekbar color value. Using default value. + + + Alternative thumbnails + Thumbnails in use + Enable DeArrow thumbnails + Using DeArrow thumbnails + Not using DeArrow thumbnails + Show a toast if API is not available + Toast is shown if DeArrow is not available + Toast is not shown if DeArrow is not available + DeArrow API endpoint + The URL of the DeArrow thumbnail cache endpoint. Do not change this unless you know what you\'re doing + About DeArrow + DeArrow provides crowd-sourced thumbnails for YouTube videos. These thumbnails are often more relevant than those provided by YouTube. If enabled, video URLs will be sent to the API server and no other data is sent\n\nTap here to learn more about DeArrow + Enable still video captures + Using YouTube still video captures + Not using YouTube still video captures + Video time to take the still from + Beginning of video + Middle of video + End of video + Use fast still captures + Using medium quality still captures. Thumbnails will load faster, but live streams, unreleased, or very old videos may show blank thumbnails + Using high quality still captures + About still video captures + Still captures are taken from the beginning/middle/end of each video. These images are built into YouTube and no external API is used + Video thumbnail settings + + + Show ReVanced announcements + Announcements are shown on startup + Announcements are not shown on startup + Show announcements on startup + Failed connecting to announcements provider + + + Enable auto-repeat + Auto-repeat is enabled + Auto-repeat is disabled + + + Spoof device dimensions + Device dimensions spoofed + Device dimensions not spoofed\n\nSpoofing the device dimensions can unlock higher video qualities but unknown side effects may occur + + + Spoof app signature + Spoof app signature + App signature spoofed\n\nSide effects include:\n• Enhanced bitrate is not available\n• Videos cannot be downloaded\n• No seekbar thumbnails for paid videos + App signature not spoofed\n\nVideo playback may not work + Turning off this setting will cause video playback issues. + Spoof app signature in feed + App signature spoofed\n\nSide effects include:\n• Feed videos are missing subtitles\n• Automatically played feed videos will show up in your watch history + App signature not spoofed for feed videos\n\nFeed videos will play for less than 1 minute beforeencountering playback issues + Spoof storyboard + Storyboard spoofed + Storyboard not spoofed\n\nSide effects include:\n• No ambient mode\n• Seekbar thumbnails are hidden + Spoof the app signature to prevent playback issues + Spoof storyboard temporarily not available (API timed out) + Spoof storyboard temporarily not available: %s + + + GmsCore Settings + Settings for GmsCore + + + Bypass URL redirects + URL redirects are bypassed + URL redirects are not bypassed + + + Open links in browser + Opening links externally + Opening links in app + + + Minimized playback + This setting can be found in Settings -> Background + + + Remove tracking query parameter + Tracking query parameter is removed from links + Tracking query parameter is not removed from links + + + Disable zoom haptics + Haptics are disabled + Haptics are enabled + + + Enable auto HDR brightness + Auto HDR brightness is enabled + Auto HDR brightness is disabled + + + Automatic quality + 2160p + 1440p + 1080p + 720p + 480p + 360p + 240p + 144p + Remember video quality changes + Quality changes apply to all videos + Quality changes only apply to the current video + Default video quality on Wi-Fi network + Default video quality on mobile network + mobile + wifi + Changed default %s quality to: %s + + + Custom playback speeds + Add or change the available playback speeds + Custom speeds must be less than %s Using default values. + Invalid custom playback speeds. Using default values. + + + Remember playback speed changes + Playback speed changes apply to all videos + Playback speed changes only apply to the current video + Default playback speed + Changed default speed to: %s + + + Restore old video quality menu + Old video quality menu is shown + Old video quality menu is not shown + + + Enable slide to seek + Slide to seek is enabled + Slide to seek is not enabled + + + + + Block audio ads + Audio ads are blocked + Audio ads are unblocked + + + %s is unavailable. Ads may show. Try switching to another ad block service in settings. + %s server returned an error. Ads may show. Try switching to another ad block service in settings. + Block embedded video ads + Embedded video ads are blocked + Embedded video ads are unblocked + Disabled + Luminous proxy + PurpleAdBlock proxy + + + Block video ads + Video ads are blocked + Video ads are unblocked + + + message deleted + Show deleted messages + Do not show deleted messages + Hide deleted messages behind a spoiler + Show deleted messages as crossed-out text + + + Automatically claim Channel Points + Channel Points are claimed automatically + Channel Points are not claimed automatically + + + Enable Twitch debug mode + Twitch debug mode is enabled (not recommended) + Twitch debug mode is disabled + + + ReVanced Settings + Debug logging + Debug logs are enabled + Debug logs are disabled + Ads + Ad blocking settings + Chat + Chat settings + Misc + Miscellaneous settings + General settings + Other settings + Client-side ads + Server-side surestream ads + + + \ No newline at end of file diff --git a/src/main/resources/alternativethumbnails/host/values/strings.xml b/src/main/resources/alternativethumbnails/host/values/strings.xml deleted file mode 100644 index 272bbc2f93..0000000000 --- a/src/main/resources/alternativethumbnails/host/values/strings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - Showing original YouTube thumbnails - Showing still video captures - Showing DeArrow thumbnails. If a video has no DeArrow thumbnails then the original YouTube thumbnails are shown - Showing DeArrow thumbnails. If a video has no DeArrow thumbnails then still video captures are shown - - DeArrow temporarily not available (status code: %s) - DeArrow temporarily not available - \ No newline at end of file diff --git a/src/main/resources/copyvideourl/host/layout/youtube_controls_bottom_ui_container.xml b/src/main/resources/copyvideourl/host/layout/youtube_controls_bottom_ui_container.xml index 97ec1740f7..3a7cdd3efa 100644 --- a/src/main/resources/copyvideourl/host/layout/youtube_controls_bottom_ui_container.xml +++ b/src/main/resources/copyvideourl/host/layout/youtube_controls_bottom_ui_container.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/main/resources/copyvideourl/host/values/strings.xml b/src/main/resources/copyvideourl/host/values/strings.xml deleted file mode 100644 index 8452816c3f..0000000000 --- a/src/main/resources/copyvideourl/host/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - URL copied to clipboard - URL with timestamp copied - diff --git a/src/main/resources/downloads/host/layout/youtube_controls_bottom_ui_container.xml b/src/main/resources/downloads/host/layout/youtube_controls_bottom_ui_container.xml index 419845aa9a..b38a30b976 100644 --- a/src/main/resources/downloads/host/layout/youtube_controls_bottom_ui_container.xml +++ b/src/main/resources/downloads/host/layout/youtube_controls_bottom_ui_container.xml @@ -1,4 +1,4 @@ - + diff --git a/src/main/resources/downloads/host/values/strings.xml b/src/main/resources/downloads/host/values/strings.xml deleted file mode 100644 index dcdfd27532..0000000000 --- a/src/main/resources/downloads/host/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - is not installed. Please install it. - diff --git a/src/main/resources/gms/host/values/strings.xml b/src/main/resources/gms/host/values/strings.xml deleted file mode 100644 index 4697165ec5..0000000000 --- a/src/main/resources/gms/host/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - GmsCore is not installed. Please install it. - GmsCore is failing to run. Please follow the "Don't kill my app" guide for GmsCore. - diff --git a/src/main/resources/returnyoutubedislike/host/values/strings.xml b/src/main/resources/returnyoutubedislike/host/values/strings.xml deleted file mode 100644 index b88a579563..0000000000 --- a/src/main/resources/returnyoutubedislike/host/values/strings.xml +++ /dev/null @@ -1,60 +0,0 @@ - - Hidden - - Dislikes temporarily not available (API timed out) - Dislikes not available (status %d) - Dislikes not available (client API limit reached) - Dislikes not available (%s) - - - Reload video to vote using ReturnYouTubeDislike - - Return YouTube Dislike - Dislikes are shown - Dislikes are not shown - - Show dislikes on Shorts - Dislikes shown on Shorts %s - Dislikes hidden on Shorts - Limitation: Dislikes may not appear in incognito mode - - Dislikes as percentage - Dislikes shown as percentage - Dislikes shown as number - - Compact like button - Like button styled for minimum width - Like button styled for best appearance - - Show a toast if API is not available - Toast is shown if Return YouTube Dislike is not available - Toast is not shown if Return YouTube Dislike is not available - - About - ReturnYouTubeDislike.com - Data is provided by the Return YouTube Dislike API. Tap here to learn more - - - ReturnYouTubeDislike API statistics of this device - - API response time, average - API response time, minimum - API response time, maximum - - API response time, last video - Dislikes temporarily not available - Client API rate limit in effect - - API fetch votes, number of calls - No network calls made - %d network calls made - - API fetch votes, number of timeouts - No network calls timed out - %d network calls timed out - - API client rate limits - No client rate limits encountered - Client rate limit encountered %d times - - %d milliseconds - diff --git a/src/main/resources/settings/host/values/strings.xml b/src/main/resources/settings/host/values/strings.xml deleted file mode 100644 index a897f37a86..0000000000 --- a/src/main/resources/settings/host/values/strings.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - ReVanced - Do you wish to proceed? - Reset - - Refresh and restart - Restart - - Import - Copy - ReVanced settings reset to default - Imported %d settings - Import failed: %s - diff --git a/src/main/resources/sponsorblock/drawable/ic_sb_adjust.xml b/src/main/resources/sponsorblock/drawable/revanced_sb_adjust.xml similarity index 100% rename from src/main/resources/sponsorblock/drawable/ic_sb_adjust.xml rename to src/main/resources/sponsorblock/drawable/revanced_sb_adjust.xml diff --git a/src/main/resources/sponsorblock/drawable/ic_sb_compare.xml b/src/main/resources/sponsorblock/drawable/revanced_sb_compare.xml similarity index 100% rename from src/main/resources/sponsorblock/drawable/ic_sb_compare.xml rename to src/main/resources/sponsorblock/drawable/revanced_sb_compare.xml diff --git a/src/main/resources/sponsorblock/drawable/ic_sb_edit.xml b/src/main/resources/sponsorblock/drawable/revanced_sb_edit.xml similarity index 100% rename from src/main/resources/sponsorblock/drawable/ic_sb_edit.xml rename to src/main/resources/sponsorblock/drawable/revanced_sb_edit.xml diff --git a/src/main/resources/sponsorblock/drawable/ic_sb_logo.xml b/src/main/resources/sponsorblock/drawable/revanced_sb_logo.xml similarity index 100% rename from src/main/resources/sponsorblock/drawable/ic_sb_logo.xml rename to src/main/resources/sponsorblock/drawable/revanced_sb_logo.xml diff --git a/src/main/resources/sponsorblock/drawable/ic_sb_publish.xml b/src/main/resources/sponsorblock/drawable/revanced_sb_publish.xml similarity index 100% rename from src/main/resources/sponsorblock/drawable/ic_sb_publish.xml rename to src/main/resources/sponsorblock/drawable/revanced_sb_publish.xml diff --git a/src/main/resources/sponsorblock/drawable/ic_sb_voting.xml b/src/main/resources/sponsorblock/drawable/revanced_sb_voting.xml similarity index 100% rename from src/main/resources/sponsorblock/drawable/ic_sb_voting.xml rename to src/main/resources/sponsorblock/drawable/revanced_sb_voting.xml diff --git a/src/main/resources/sponsorblock/host/layout/youtube_controls_layout.xml b/src/main/resources/sponsorblock/host/layout/youtube_controls_layout.xml index 33a11b83b4..7c2d539183 100644 --- a/src/main/resources/sponsorblock/host/layout/youtube_controls_layout.xml +++ b/src/main/resources/sponsorblock/host/layout/youtube_controls_layout.xml @@ -1,7 +1,7 @@ + android:src="@drawable/revanced_sb_logo" /> + android:src="@drawable/revanced_sb_voting" /> diff --git a/src/main/resources/sponsorblock/host/values/strings.xml b/src/main/resources/sponsorblock/host/values/strings.xml deleted file mode 100644 index 2322f37521..0000000000 --- a/src/main/resources/sponsorblock/host/values/strings.xml +++ /dev/null @@ -1,194 +0,0 @@ - - - Enable SponsorBlock - SponsorBlock is a crowd-sourced system for skipping annoying parts of YouTube videos - - Appearance - Show voting button - Segment voting button is shown - Segment voting button is not shown - Use compact skip button - Skip button styled for minimum width - Skip button styled for best appearance - Automatically hide skip button - Skip button hides after a few seconds - Skip button displayed for entire segment - Show a toast when skipping automatically - Toast is shown when a segment is automatically skipped. Tap here to see an example - Toast is not shown. Tap here to see an example - Show video length without segments - Video length minus all segments, shown in parentheses next to the full video length - Full video length shown - - Creating new segments - Show create new segment button - Create new segment button is shown - Create new segment button is not shown - Adjust new segment step - Number of milliseconds the time adjustment buttons move when creating new segments - Value must be a positive number - View guidelines - Guidelines contain rules and tips for creating new segments - Follow the guidelines - Read the SponsorBlock guidelines before creating new segments - Already read - Show me - - General - Show a toast if API is not available - Toast is shown if SponsorBlock is not available - Toast is not shown if SponsorBlock is not available - Enable skip count tracking - Lets the SponsorBlock leaderboard know how much time is saved. A message is sent to the leaderboard each time a segment is skipped - Skip count tracking is not enabled - Minimum segment duration - Segments shorter than this value (in seconds) will not be shown or skipped - Your private user id - This should be kept private. This is like a password and should not be shared with anyone. If someone has this, they can impersonate you - Private user id must be at least 30 characters long - Change API URL - The address SponsorBlock uses to make calls to the server. Do not change this unless you know what you\'re doing - API URL reset - API URL is invalid - API URL changed - Import/Export settings - Copy - Your SponsorBlock JSON configuration that can be imported/exported to ReVanced and other SponsorBlock platforms %s - This includes your private user id. Be sure to share this wisely - Settings imported successfully - Failed to import: %s - Failed to export: %s - - Your settings contain a private SponsorBlock user id.\n\nYour user id is like a password and it should never be shared.\n - Do not show again - - Change segment behavior - Sponsor - Paid promotion, paid referrals and direct advertisements. Not for self-promotion or free shout-outs to causes/creators/websites/products they like - Unpaid/Self Promotion - Similar to \'Sponsor\' except for unpaid or self promotion. Includes sections about merchandise, donations, or information about who they collaborated with - Interaction Reminder (Subscribe) - A short reminder to like, subscribe or follow them in the middle of content. If it is long or about something specific, it should instead be under self promotion - Highlight - The part of the video that most people are looking for - Intermission/Intro Animation - An interval without actual content. Could be a pause, static frame, or repeating animation. Does not include transitions containing information - Endcards/Credits - Credits or when the YouTube endcards appear. Not for conclusions with information - Preview/Recap/Hook - Collection of clips that show what is coming up or what happened in the video or in other videos of a series, where all information is repeated elsewhere - Filler Tangent/Jokes - Tangential scenes added only for filler or humor that are not required to understand the main content of the video. Does not include segments providing context or background details - Music: Non-Music Section - Only for use in music videos. Sections of music videos without music, that aren\'t already covered by another category - - Skip - Highlight - Skip sponsor - Skip promo - Skip interact - Skip to highlight - Skip intro - Skip intermission - Skip intermission - Skip outro - Skip preview - Skip preview - Skip recap - Skip filler - Skip non-music - Skip segment - - Skipped sponsor - Skipped self promotion - Skipped annoying reminder - Skipped to highlight - Skipped intro - Skipped intermission - Skipped intermission - Skipped outro - Skipped preview - Skipped preview - Skipped recap - Skipped filler - Skipped a non-music section - Skipped unsubmitted segment - Skipped multiple segments - - Skip automatically - Skip automatically once - Show a skip button - Show in seek bar - Disable - - Unable to submit segment: %s - SponsorBlock is temporarily down - Unable to submit segment (status: %d %s) - Unable to submit segment.\nRate Limited (too many from the same user or IP) - Can\'t submit the segment: %s - Can\'t submit the segment.\nAlready exists - Segment submitted successfully - - SponsorBlock temporarily not available - SponsorBlock temporarily not available (status %d) - SponsorBlock temporarily not available (API timed out) - - Unable to vote for segment (API timed out) - Unable to vote for segment (status: %d %s) - Unable to vote for segment: %s - Upvote - Downvote - Change category - There are no segments to vote for - - Choose the segment category - Category is disabled in settings. Enable category to submit. - New SponsorBlock segment - Set %02d:%02d:%03d as the start or end of a new segment? - start - end - now - Time the segment begins at - Time the segment ends at - Are the times correct? - The segment lasts from %02d:%02d to %02d:%02d (%d minutes %02d seconds)\nIs it ready to submit? - Start must be before the end - Mark two locations on the time bar first - Preview the segment, and ensure it skips smoothly - Edit timing of segment manually - Do you want to edit the timing for the start or end of the segment? - Invalid time given - - Stats - Stats temporarily not available (API is down) - Loading... - SponsorBlock is disabled - Your username: <b>%s</b> - Tap here to change your username - Unable to change username: Status: %d %s - Username successfully changed - Your reputation is <b>%.2f</b> - You\'ve created <b>%s</b> segments - SponsorBlock leaderboard - You\'ve saved people from <b>%s</b> segments - Tap here to see the global stats and top contributors - That\'s <b>%s</b> of their lives.<br>Tap here to see the leaderboard - You\'ve skipped <b>%s</b> segments - That\'s <b>%s</b> - Reset skipped segments counter? - %s hours %s minutes - %s minutes %s seconds - %s seconds - - Color: - Color changed - Color reset - Invalid color code - Reset color - - Reset - - About - sponsor.ajay.app - Data is provided by the SponsorBlock API. Tap here to learn more and see downloads for other platforms - diff --git a/src/main/resources/sponsorblock/layout/inline_sponsor_overlay.xml b/src/main/resources/sponsorblock/layout/revanced_sb_inline_sponsor_overlay.xml similarity index 79% rename from src/main/resources/sponsorblock/layout/inline_sponsor_overlay.xml rename to src/main/resources/sponsorblock/layout/revanced_sb_inline_sponsor_overlay.xml index 2e2270a3ee..fb57b72524 100644 --- a/src/main/resources/sponsorblock/layout/inline_sponsor_overlay.xml +++ b/src/main/resources/sponsorblock/layout/revanced_sb_inline_sponsor_overlay.xml @@ -2,8 +2,8 @@ + android:src="@drawable/revanced_sb_adjust" /> + android:src="@drawable/revanced_sb_compare" /> + android:src="@drawable/revanced_sb_edit" /> + android:src="@drawable/revanced_sb_publish" /> \ No newline at end of file diff --git a/src/main/resources/sponsorblock/layout/skip_sponsor_button.xml b/src/main/resources/sponsorblock/layout/revanced_sb_skip_sponsor_button.xml similarity index 82% rename from src/main/resources/sponsorblock/layout/skip_sponsor_button.xml rename to src/main/resources/sponsorblock/layout/revanced_sb_skip_sponsor_button.xml index 185960ec9e..b25987ff14 100644 --- a/src/main/resources/sponsorblock/layout/skip_sponsor_button.xml +++ b/src/main/resources/sponsorblock/layout/revanced_sb_skip_sponsor_button.xml @@ -3,7 +3,7 @@ xmlns:yt="http://schemas.android.com/apk/res-auto">