From 135f8d852dfbe2982423d88ad6c2a1f835b5a27c Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sun, 31 Mar 2024 06:15:20 +0900 Subject: [PATCH] refactor: fix package and code structure --- .../music/ads/general/GeneralAdsPatch.kt | 2 +- .../patches/music/ads/music/MusicAdsPatch.kt | 5 +- .../flyoutpanel/component/FlyoutPanelPatch.kt | 2 +- .../music/general/amoled/AmoledPatch.kt | 6 +- .../general/autocaptions/AutoCaptionsPatch.kt | 2 +- .../buttonshelf/HideButtonShelfPatch.kt | 2 +- .../carouselshelf/HideCarouselShelfPatch.kt | 2 +- .../HideChannelGuidelinesPatch.kt | 2 +- .../general/customfilter/CustomFilterPatch.kt | 2 +- .../RemoveViewerDiscretionDialogPatch.kt | 2 +- .../emojipicker/HideEmojiPickerPatch.kt | 2 +- .../playlistcard/HidePlaylistCardPatch.kt | 2 +- .../sampleshelf/HideSampleShelfPatch.kt | 2 +- .../voicesearch/VoiceSearchButtonPatch.kt | 2 +- .../branding/name/CustomBrandingNamePatch.kt | 2 +- .../DoubleTapOverlayBackgroundPatch.kt | 2 +- .../playeroverlay/PlayerOverlayFilterPatch.kt | 2 +- .../music/misc/codecs/CodecsUnlockPatch.kt | 2 +- .../spoofappversion/SpoofAppVersionPatch.kt | 2 +- .../misc/tracking/SanitizeUrlQueryPatch.kt | 4 +- .../misc/translations/TranslationsPatch.kt | 2 +- .../colormatchplayer/ColorMatchPlayerPatch.kt | 2 +- .../MiniPlayerButtonResourcePatch.kt | 2 +- .../utils/fix/clientspoof/ClientSpoofPatch.kt | 2 +- .../fix/fileprovider/FileProviderPatch.kt | 2 +- .../utils/integrations/IntegrationsPatch.kt | 6 +- .../fingerprints/InitFingerprint.kt | 3 +- .../music/utils/intenthook/IntentHookPatch.kt | 37 -- .../music/utils/litho/LithoFilterPatch.kt | 55 --- .../patches/music/utils/microg/MicroGPatch.kt | 4 +- .../music/utils/microg/MicroGResourcePatch.kt | 8 +- .../OverrideQualityHookPatch.kt | 6 +- .../overridespeed/OverrideSpeedHookPatch.kt | 6 +- .../utils/resourceid/SharedResourceIdPatch.kt | 18 +- .../ReturnYouTubeDislikeBytecodePatch.kt | 2 +- .../utils/settings/SettingsBytecodePatch.kt | 50 ++- .../music/utils/settings/SettingsPatch.kt | 6 +- .../GoogleApiActivityFingerprint.kt | 2 +- .../customspeed/CustomPlaybackSpeedPatch.kt | 2 +- .../reddit/ad/banner/HideBannerPatch.kt | 1 + .../reddit/ad/comments/HideCommentAdsPatch.kt | 16 +- .../patches/reddit/ad/general/HideAdsPatch.kt | 35 +- .../general/fingerprints/AdPostFingerprint.kt | 4 - .../fingerprints/NewAdPostFingerprint.kt | 4 +- .../branding/name/CustomBrandingNamePatch.kt | 66 ++-- .../packagename/ChangePackageNamePatch.kt | 67 ++-- .../navigation/NavigationButtonsPatch.kt | 6 +- .../fingerprints/PremiumIconFingerprint.kt | 3 +- .../RecentlyVisitedShelfPatch.kt | 20 +- .../screenshotpopup/ScreenshotPopupPatch.kt | 6 +- .../RemoveSubRedditDialogPatch.kt | 5 +- .../layout/toolbar/ToolBarButtonPatch.kt | 6 +- .../misc/openlink/OpenLinksDirectlyPatch.kt | 6 +- .../misc/openlink/OpenLinksExternallyPatch.kt | 5 +- .../tracking/url/SanitizeUrlQueryPatch.kt | 7 +- .../reddit/utils/integrations/Constants.kt | 7 + .../utils/integrations/IntegrationsPatch.kt | 5 +- .../fingerprints/InitFingerprint.kt | 3 +- .../utils/resourceid/SharedResourceIdPatch.kt | 35 +- .../utils/settings/SettingsBytecodePatch.kt | 33 +- .../reddit/utils/settings/SettingsPatch.kt | 4 +- .../SettingsStatusLoadFingerprint.kt | 3 +- .../patches/shared/ads/AbstractAdsPatch.kt | 62 ++++ .../fingerprints/MusicAdsFingerprint.kt} | 13 +- .../fingerprints/VideoAdsFingerprint.kt} | 4 +- .../captions/AbstractAutoCaptionsPatch.kt | 26 +- .../StartVideoInformerFingerprint.kt | 2 +- .../fingerprints}/SubtitleTrackFingerprint.kt | 2 +- .../clientspoof/AbstractClientSpoofPatch.kt | 10 +- .../AbstractCustomPlaybackSpeedPatch.kt | 72 ++-- .../SpeedArrayGeneratorFingerprint.kt | 2 +- .../SpeedLimiterFallBackFingerprint.kt | 2 +- .../fingerprints}/SpeedLimiterFingerprint.kt | 2 +- ...stractRemoveViewerDiscretionDialogPatch.kt | 19 +- .../fingerprints}/CreateDialogFingerprint.kt | 2 +- .../shared/drawable/DrawableColorPatch.kt | 44 +++ .../fingerprints/DrawableFingerprint.kt} | 9 +- .../AbstractRemoveStringsElementsPatch.kt | 3 +- .../integrations/BaseIntegrationsPatch.kt | 106 ++++++ .../patches/shared/integrations/Constants.kt | 10 + .../patches/shared/litho/LithoFilterPatch.kt | 119 ++++++ ...LithoFilterPatchConstructorFingerprint.kt} | 6 +- .../fingerprints/PathBuilderFingerprint.kt} | 4 +- .../fingerprints/SetByteBufferFingerprint.kt} | 11 +- .../mapping/ResourceMappingPatch.kt | 7 +- .../{patch => }/mapping/ResourceType.kt | 2 +- .../shared/{patch => }/microg/Constants.kt | 2 +- .../microg/MicroGBytecodeHelper.kt | 10 +- .../microg/MicroGManifestHelper.kt | 11 +- .../microg/MicroGResourceHelper.kt | 3 +- .../opus/AbstractOpusCodecsPatch.kt | 8 +- .../CodecReferenceFingerprint.kt | 2 +- .../fingerprints}/CodecSelectorFingerprint.kt | 2 +- .../AbstractOverlayBackgroundPatch.kt | 3 +- .../packagename/PackageNamePatch.kt | 2 +- .../shared/patch/ads/AbstractAdsPatch.kt | 50 --- .../integrations/AbstractIntegrationsPatch.kt | 64 ---- .../patch/litho/ComponentParserPatch.kt | 106 ------ .../shared/patch/litho/LithoThemePatch.kt | 52 --- .../versionspoof/AbstractVersionSpoofPatch.kt | 58 --- .../settings/AbstractSettingsResourcePatch.kt | 2 +- .../fingerprints/SharedSettingFingerprint.kt | 12 + .../tracking/AbstractSanitizeUrlQueryPatch.kt | 2 +- .../CopyTextEndpointFingerprint.kt | 2 +- .../BaseTransformInstructionsPatch.kt | 2 +- .../{patch => }/transformation/MethodCall.kt | 2 +- .../translations/AbstractTranslationsPatch.kt | 3 +- .../versionspoof/AbstractVersionSpoofPatch.kt | 42 +++ .../fingerprints}/ClientInfoFingerprint.kt | 2 +- .../ClientInfoParentFingerprint.kt | 2 +- .../AbstractVoiceSearchButtonPatch.kt | 3 +- .../youtube/ads/general/GeneralAdsPatch.kt | 2 +- .../ads/getpremium/HideGetPremiumPatch.kt | 1 - .../youtube/ads/video/VideoAdsPatch.kt | 5 +- .../buttoncontainer/ButtonContainerPatch.kt | 2 +- .../comment/CommentComponentPatch.kt | 2 +- .../oldqualitylayout/OldQualityLayoutPatch.kt | 2 +- .../oldspeedlayout/OldSpeedLayoutPatch.kt | 2 +- .../player/PlayerFlyoutPanelPatch.kt | 2 +- .../quickactions/QuickActionsPatch.kt | 2 +- .../general/autocaptions/AutoCaptionsPatch.kt | 2 +- .../ChannelListSubMenuPatch.kt | 2 +- .../ChannelProfileComponentsPatch.kt | 2 +- .../DescriptionComponentsPatch.kt | 2 +- .../RemoveViewerDiscretionDialogPatch.kt | 2 +- .../youtube/general/handle/HideHandlePatch.kt | 2 +- .../general/layout/LayoutComponentsPatch.kt | 2 +- .../general/mixplaylists/MixPlaylistsPatch.kt | 2 +- .../suggestions/SuggestionsShelfPatch.kt | 2 +- .../branding/name/CustomBrandingNamePatch.kt | 2 +- .../DoubleTapOverlayBackgroundPatch.kt | 2 +- .../youtube/layout/theme/GeneralThemePatch.kt | 8 +- .../MaterialYouPatch.kt | 9 +- .../youtube/layout/theme/ThemePatch.kt | 6 +- .../voicesearch/VoiceSearchButtonPatch.kt | 2 +- .../misc/codec/audio/ForceOpusCodecPatch.kt | 2 +- .../externalbrowser/ExternalBrowserPatch.kt | 2 +- .../spoofappversion/SpoofAppVersionPatch.kt | 2 +- .../misc/tracking/SanitizeUrlQueryPatch.kt | 4 +- .../misc/translations/TranslationsPatch.kt | 2 +- .../download/pip/DisablePiPPatch.kt | 6 +- .../captionsbutton/HideCaptionsButtonPatch.kt | 2 +- .../collapsebutton/HideCollapseButtonPatch.kt | 66 +++- .../fingerprints/LiveChatFingerprint.kt | 2 +- .../player/infocards/HideInfoCardsPatch.kt | 2 +- .../suggestactions/SuggestedActionsPatch.kt | 2 +- .../watermark/HideChannelWatermarkPatch.kt | 2 +- .../seekbar/color/SeekbarColorPatch.kt | 6 +- .../shorts/components/ShortsComponentPatch.kt | 2 +- .../utils/browseid/BrowseIdHookPatch.kt | 23 +- .../utils/fix/clientspoof/ClientSpoofPatch.kt | 2 +- .../parameter/SpoofPlayerParameterPatch.kt | 2 +- ...delGeneralStoryboardRendererFingerprint.kt | 2 +- ...LiveStreamStoryboardRendererFingerprint.kt | 2 +- ...elStoryboardRecommendedLevelFingerprint.kt | 2 +- .../utils/integrations/IntegrationsPatch.kt | 6 +- .../APIPlayerServiceFingerprint.kt | 3 +- .../ApplicationInitFingerprint.kt | 3 +- ...mbeddedPlayerControlsOverlayFingerprint.kt | 3 +- .../fingerprints/EmbeddedPlayerFingerprint.kt | 3 +- .../RemoteEmbedFragmentFingerprint.kt | 3 +- .../RemoteEmbeddedPlayerFingerprint.kt | 3 +- .../StandalonePlayerActivityFingerprint.kt | 3 +- .../youtube/utils/litho/LithoFilterPatch.kt | 53 --- .../fingerprints/LithoFilterFingerprint.kt | 14 - .../utils/microg/MicroGBytecodePatch.kt | 4 +- .../youtube/utils/microg/MicroGPatch.kt | 8 +- .../OverrideQualityHookPatch.kt | 8 +- .../overridespeed/OverrideSpeedHookPatch.kt | 6 +- .../playerbutton/PlayerButtonHookPatch.kt | 66 ---- .../playercontrols/PlayerControlsPatch.kt | 2 +- .../utils/resourceid/SharedResourceIdPatch.kt | 20 +- .../general/ReturnYouTubeDislikePatch.kt | 4 +- ...ingNumberMeasureAnimatedTextFingerprint.kt | 22 +- .../youtube/utils/settings/ResourceUtils.kt | 6 +- .../utils/settings/SettingsBytecodePatch.kt | 4 +- .../youtube/utils/settings/SettingsPatch.kt | 14 +- .../utils/sponsorblock/SponsorBlockPatch.kt | 58 +-- .../customspeed/CustomPlaybackSpeedPatch.kt | 2 +- .../video/quality/VideoQualityPatch.kt | 4 +- .../youtube/video/speed/PlaybackSpeedPatch.kt | 2 +- .../kotlin/app/revanced/util/BytecodeUtils.kt | 31 ++ .../util/fingerprint/ReferenceFingerprint.kt | 34 ++ .../music/settings/host/values/strings.xml | 110 +++--- .../music/settings/values-v21/strings.xml | 2 +- .../sponsorblock/xml/sponsorblock_prefs.xml | 30 +- .../youtube/settings/host/values/strings.xml | 344 +++++++++--------- .../youtube/settings/values-v21/strings.xml | 14 +- .../youtube/settings/xml/revanced_prefs.xml | 36 +- ...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 ...egment.xml => revanced_sb_new_segment.xml} | 24 +- ...c_sb_adjust.xml => revanced_sb_adjust.xml} | 0 ..._backward.xml => revanced_sb_backward.xml} | 0 ...sb_compare.xml => revanced_sb_compare.xml} | 0 .../{ic_sb_edit.xml => revanced_sb_edit.xml} | 0 ...sb_forward.xml => revanced_sb_forward.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 ...egment.xml => revanced_sb_new_segment.xml} | 28 +- ...=> revanced_sb_new_segment_background.xml} | 0 ...ced_sb_skip_sponsor_button_background.xml} | 0 .../host/layout/youtube_controls_layout.xml | 10 +- ...=> revanced_sb_inline_sponsor_overlay.xml} | 10 +- ...ml => revanced_sb_skip_sponsor_button.xml} | 14 +- 210 files changed, 1396 insertions(+), 1414 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/music/utils/intenthook/IntentHookPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/utils/litho/LithoFilterPatch.kt rename src/main/kotlin/app/revanced/patches/music/utils/{intenthook => settings}/fingerprints/GoogleApiActivityFingerprint.kt (84%) create mode 100644 src/main/kotlin/app/revanced/patches/reddit/utils/integrations/Constants.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/ads/AbstractAdsPatch.kt rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/ads/LegacyAdsFingerprint.kt => ads/fingerprints/MusicAdsFingerprint.kt} (54%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/ads/MainstreamAdsFingerprint.kt => ads/fingerprints/VideoAdsFingerprint.kt} (57%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/captions/AbstractAutoCaptionsPatch.kt (67%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/captions => captions/fingerprints}/StartVideoInformerFingerprint.kt (88%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/captions => captions/fingerprints}/SubtitleTrackFingerprint.kt (89%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/clientspoof/AbstractClientSpoofPatch.kt (90%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/customspeed/AbstractCustomPlaybackSpeedPatch.kt (52%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/customspeed => customspeed/fingerprints}/SpeedArrayGeneratorFingerprint.kt (88%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/customspeed => customspeed/fingerprints}/SpeedLimiterFallBackFingerprint.kt (89%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/customspeed => customspeed/fingerprints}/SpeedLimiterFingerprint.kt (88%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/dialog/AbstractRemoveViewerDiscretionDialogPatch.kt (70%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/dialog => dialog/fingerprints}/CreateDialogFingerprint.kt (92%) create mode 100644 src/main/kotlin/app/revanced/patches/shared/drawable/DrawableColorPatch.kt rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/litho/LithoThemeFingerprint.kt => drawable/fingerprints/DrawableFingerprint.kt} (62%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/elements/AbstractRemoveStringsElementsPatch.kt (93%) create mode 100644 src/main/kotlin/app/revanced/patches/shared/integrations/BaseIntegrationsPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/integrations/Constants.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/litho/LithoFilterPatch.kt rename src/main/kotlin/app/revanced/patches/{music/utils/litho/fingerprints/LithoFilterFingerprint.kt => shared/litho/fingerprints/LithoFilterPatchConstructorFingerprint.kt} (66%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/litho/EmptyComponentBuilderFingerprint.kt => litho/fingerprints/PathBuilderFingerprint.kt} (80%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/litho/GeneralByteBufferFingerprint.kt => litho/fingerprints/SetByteBufferFingerprint.kt} (69%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/mapping/ResourceMappingPatch.kt (90%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/mapping/ResourceType.kt (83%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/microg/Constants.kt (98%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/microg/MicroGBytecodeHelper.kt (96%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/microg/MicroGManifestHelper.kt (82%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/microg/MicroGResourceHelper.kt (96%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/opus/AbstractOpusCodecsPatch.kt (91%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/opus => opus/fingerprints}/CodecReferenceFingerprint.kt (89%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/opus => opus/fingerprints}/CodecSelectorFingerprint.kt (90%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/overlaybackground/AbstractOverlayBackgroundPatch.kt (94%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/packagename/PackageNamePatch.kt (97%) delete mode 100644 src/main/kotlin/app/revanced/patches/shared/patch/ads/AbstractAdsPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/patch/integrations/AbstractIntegrationsPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/patch/litho/LithoThemePatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/patch/versionspoof/AbstractVersionSpoofPatch.kt rename src/main/kotlin/app/revanced/patches/shared/{patch => }/settings/AbstractSettingsResourcePatch.kt (95%) create mode 100644 src/main/kotlin/app/revanced/patches/shared/settings/fingerprints/SharedSettingFingerprint.kt rename src/main/kotlin/app/revanced/patches/shared/{patch => }/tracking/AbstractSanitizeUrlQueryPatch.kt (96%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/tracking => tracking/fingerprints}/CopyTextEndpointFingerprint.kt (91%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/transformation/BaseTransformInstructionsPatch.kt (97%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/transformation/MethodCall.kt (98%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/translations/AbstractTranslationsPatch.kt (92%) create mode 100644 src/main/kotlin/app/revanced/patches/shared/versionspoof/AbstractVersionSpoofPatch.kt rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/versionspoof => versionspoof/fingerprints}/ClientInfoFingerprint.kt (86%) rename src/main/kotlin/app/revanced/patches/shared/{fingerprints/versionspoof => versionspoof/fingerprints}/ClientInfoParentFingerprint.kt (74%) rename src/main/kotlin/app/revanced/patches/shared/{patch => }/voicesearch/AbstractVoiceSearchButtonPatch.kt (95%) rename src/main/kotlin/app/revanced/patches/youtube/layout/{materialyou => theme}/MaterialYouPatch.kt (89%) rename src/main/kotlin/app/revanced/patches/youtube/{utils/playerbutton => player/collapsebutton}/fingerprints/LiveChatFingerprint.kt (82%) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/utils/litho/LithoFilterPatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/utils/litho/fingerprints/LithoFilterFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/PlayerButtonHookPatch.kt create mode 100644 src/main/kotlin/app/revanced/util/fingerprint/ReferenceFingerprint.kt rename src/main/resources/youtube/sponsorblock/default/drawable/{ic_sb_adjust.xml => revanced_sb_adjust.xml} (100%) rename src/main/resources/youtube/sponsorblock/default/drawable/{ic_sb_compare.xml => revanced_sb_compare.xml} (100%) rename src/main/resources/youtube/sponsorblock/default/drawable/{ic_sb_edit.xml => revanced_sb_edit.xml} (100%) rename src/main/resources/youtube/sponsorblock/default/drawable/{ic_sb_logo.xml => revanced_sb_logo.xml} (100%) rename src/main/resources/youtube/sponsorblock/default/drawable/{ic_sb_publish.xml => revanced_sb_publish.xml} (100%) rename src/main/resources/youtube/sponsorblock/default/drawable/{ic_sb_voting.xml => revanced_sb_voting.xml} (100%) rename src/main/resources/youtube/sponsorblock/default/layout/{new_segment.xml => revanced_sb_new_segment.xml} (83%) rename src/main/resources/youtube/sponsorblock/outline/drawable/{ic_sb_adjust.xml => revanced_sb_adjust.xml} (100%) rename src/main/resources/youtube/sponsorblock/outline/drawable/{ic_sb_backward.xml => revanced_sb_backward.xml} (100%) rename src/main/resources/youtube/sponsorblock/outline/drawable/{ic_sb_compare.xml => revanced_sb_compare.xml} (100%) rename src/main/resources/youtube/sponsorblock/outline/drawable/{ic_sb_edit.xml => revanced_sb_edit.xml} (100%) rename src/main/resources/youtube/sponsorblock/outline/drawable/{ic_sb_forward.xml => revanced_sb_forward.xml} (100%) rename src/main/resources/youtube/sponsorblock/outline/drawable/{ic_sb_logo.xml => revanced_sb_logo.xml} (100%) rename src/main/resources/youtube/sponsorblock/outline/drawable/{ic_sb_publish.xml => revanced_sb_publish.xml} (100%) rename src/main/resources/youtube/sponsorblock/outline/drawable/{ic_sb_voting.xml => revanced_sb_voting.xml} (100%) rename src/main/resources/youtube/sponsorblock/outline/layout/{new_segment.xml => revanced_sb_new_segment.xml} (80%) rename src/main/resources/youtube/sponsorblock/shared/drawable/{ns_bg.xml => revanced_sb_new_segment_background.xml} (100%) rename src/main/resources/youtube/sponsorblock/shared/drawable/{sb_btn_bg.xml => revanced_sb_skip_sponsor_button_background.xml} (100%) rename src/main/resources/youtube/sponsorblock/shared/layout/{inline_sponsor_overlay.xml => revanced_sb_inline_sponsor_overlay.xml} (81%) rename src/main/resources/youtube/sponsorblock/shared/layout/{skip_sponsor_button.xml => revanced_sb_skip_sponsor_button.xml} (79%) diff --git a/src/main/kotlin/app/revanced/patches/music/ads/general/GeneralAdsPatch.kt b/src/main/kotlin/app/revanced/patches/music/ads/general/GeneralAdsPatch.kt index 4abc9466c..effb750cf 100644 --- a/src/main/kotlin/app/revanced/patches/music/ads/general/GeneralAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/ads/general/GeneralAdsPatch.kt @@ -16,13 +16,13 @@ import app.revanced.patches.music.ads.music.MusicAdsPatch import app.revanced.patches.music.navigation.component.NavigationBarComponentPatch import app.revanced.patches.music.utils.integrations.Constants.ADS_PATH import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.music.utils.litho.LithoFilterPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.ButtonContainer import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.FloatingLayout import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.InterstitialsContainer import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch +import app.revanced.patches.shared.litho.LithoFilterPatch import app.revanced.util.exception import app.revanced.util.getWideLiteralInstructionIndex import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/music/ads/music/MusicAdsPatch.kt b/src/main/kotlin/app/revanced/patches/music/ads/music/MusicAdsPatch.kt index 988725031..9eb70f2c7 100644 --- a/src/main/kotlin/app/revanced/patches/music/ads/music/MusicAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/ads/music/MusicAdsPatch.kt @@ -1,8 +1,9 @@ package app.revanced.patches.music.ads.music import app.revanced.patches.music.utils.integrations.Constants.ADS_PATH -import app.revanced.patches.shared.patch.ads.AbstractAdsPatch +import app.revanced.patches.shared.ads.AbstractAdsPatch object MusicAdsPatch : AbstractAdsPatch( - "$ADS_PATH/MusicAdsPatch;->hideMusicAds()Z" + "$ADS_PATH/MusicAdsPatch;", + "hideMusicAds" ) diff --git a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt index 474cc7978..3f3f225a4 100644 --- a/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/flyoutpanel/component/FlyoutPanelPatch.kt @@ -11,11 +11,11 @@ import app.revanced.patches.music.flyoutpanel.component.fingerprints.SleepTimerF import app.revanced.patches.music.flyoutpanel.shared.FlyoutPanelMenuItemPatch import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.music.utils.integrations.Constants.FLYOUT -import app.revanced.patches.music.utils.litho.LithoFilterPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.EndButtonsContainer import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch +import app.revanced.patches.shared.litho.LithoFilterPatch import app.revanced.util.exception import app.revanced.util.getTargetIndex import app.revanced.util.getWideLiteralInstructionIndex diff --git a/src/main/kotlin/app/revanced/patches/music/general/amoled/AmoledPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/amoled/AmoledPatch.kt index f151182df..cbc8e9cd4 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/amoled/AmoledPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/amoled/AmoledPatch.kt @@ -5,13 +5,13 @@ import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.UTILS_PATH -import app.revanced.patches.shared.patch.litho.LithoThemePatch +import app.revanced.patches.shared.drawable.DrawableColorPatch import org.w3c.dom.Element @Patch( name = "Amoled", description = "Applies a pure black theme to some components.", - dependencies = [LithoThemePatch::class], + dependencies = [DrawableColorPatch::class], compatiblePackages = [ CompatiblePackage( "com.google.android.apps.youtube.music", @@ -34,7 +34,7 @@ import org.w3c.dom.Element object AmoledPatch : ResourcePatch() { override fun execute(context: ResourceContext) { - LithoThemePatch.injectCall("$UTILS_PATH/LithoThemePatch;->applyLithoTheme(I)I") + DrawableColorPatch.injectCall("$UTILS_PATH/DrawableColorPatch;->getColor(I)I") context.xmlEditor["res/values/colors.xml"].use { editor -> val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element diff --git a/src/main/kotlin/app/revanced/patches/music/general/autocaptions/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/autocaptions/AutoCaptionsPatch.kt index c09340f54..1423ea062 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/autocaptions/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/autocaptions/AutoCaptionsPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patches.music.utils.integrations.Constants.GENERAL import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.video.videoid.VideoIdPatch -import app.revanced.patches.shared.patch.captions.AbstractAutoCaptionsPatch +import app.revanced.patches.shared.captions.AbstractAutoCaptionsPatch @Patch( name = "Disable auto captions", diff --git a/src/main/kotlin/app/revanced/patches/music/general/buttonshelf/HideButtonShelfPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/buttonshelf/HideButtonShelfPatch.kt index a206700d4..74039f21d 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/buttonshelf/HideButtonShelfPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/buttonshelf/HideButtonShelfPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.music.utils.litho.LithoFilterPatch import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch +import app.revanced.patches.shared.litho.LithoFilterPatch @Patch( name = "Hide button shelf", diff --git a/src/main/kotlin/app/revanced/patches/music/general/carouselshelf/HideCarouselShelfPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/carouselshelf/HideCarouselShelfPatch.kt index d3387635d..9338a7678 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/carouselshelf/HideCarouselShelfPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/carouselshelf/HideCarouselShelfPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.music.utils.litho.LithoFilterPatch import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch +import app.revanced.patches.shared.litho.LithoFilterPatch @Patch( name = "Hide carousel shelf", diff --git a/src/main/kotlin/app/revanced/patches/music/general/channelguidelines/HideChannelGuidelinesPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/channelguidelines/HideChannelGuidelinesPatch.kt index 0daeeb738..4bb6b815d 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/channelguidelines/HideChannelGuidelinesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/channelguidelines/HideChannelGuidelinesPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.music.utils.litho.LithoFilterPatch import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch +import app.revanced.patches.shared.litho.LithoFilterPatch @Patch( name = "Hide channel guidelines", diff --git a/src/main/kotlin/app/revanced/patches/music/general/customfilter/CustomFilterPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/customfilter/CustomFilterPatch.kt index 2e3b8f691..489c93a3f 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/customfilter/CustomFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/customfilter/CustomFilterPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.music.utils.litho.LithoFilterPatch import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch +import app.revanced.patches.shared.litho.LithoFilterPatch @Patch( name = "Enable custom filter", diff --git a/src/main/kotlin/app/revanced/patches/music/general/dialog/RemoveViewerDiscretionDialogPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/dialog/RemoveViewerDiscretionDialogPatch.kt index 75574f946..8f847ed7f 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/dialog/RemoveViewerDiscretionDialogPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/dialog/RemoveViewerDiscretionDialogPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.GENERAL import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch -import app.revanced.patches.shared.patch.dialog.AbstractRemoveViewerDiscretionDialogPatch +import app.revanced.patches.shared.dialog.AbstractRemoveViewerDiscretionDialogPatch @Patch( name = "Remove viewer discretion dialog", diff --git a/src/main/kotlin/app/revanced/patches/music/general/emojipicker/HideEmojiPickerPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/emojipicker/HideEmojiPickerPatch.kt index 0221aae35..bc7ea0d3f 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/emojipicker/HideEmojiPickerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/emojipicker/HideEmojiPickerPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.music.utils.litho.LithoFilterPatch import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch +import app.revanced.patches.shared.litho.LithoFilterPatch @Patch( name = "Hide emoji picker and time stamp", diff --git a/src/main/kotlin/app/revanced/patches/music/general/playlistcard/HidePlaylistCardPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/playlistcard/HidePlaylistCardPatch.kt index befaba306..559d4cc9b 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/playlistcard/HidePlaylistCardPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/playlistcard/HidePlaylistCardPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.music.utils.litho.LithoFilterPatch import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch +import app.revanced.patches.shared.litho.LithoFilterPatch @Patch( name = "Hide playlist card", diff --git a/src/main/kotlin/app/revanced/patches/music/general/sampleshelf/HideSampleShelfPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/sampleshelf/HideSampleShelfPatch.kt index 288293117..94b72101f 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/sampleshelf/HideSampleShelfPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/sampleshelf/HideSampleShelfPatch.kt @@ -5,9 +5,9 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.music.utils.litho.LithoFilterPatch import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch +import app.revanced.patches.shared.litho.LithoFilterPatch @Patch( name = "Hide sample shelf", diff --git a/src/main/kotlin/app/revanced/patches/music/general/voicesearch/VoiceSearchButtonPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/voicesearch/VoiceSearchButtonPatch.kt index dfff56503..b83289a7c 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/voicesearch/VoiceSearchButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/voicesearch/VoiceSearchButtonPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.music.general.voicesearch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.voicesearch.AbstractVoiceSearchButtonPatch +import app.revanced.patches.shared.voicesearch.AbstractVoiceSearchButtonPatch @Patch( name = "Hide voice search button", diff --git a/src/main/kotlin/app/revanced/patches/music/layout/branding/name/CustomBrandingNamePatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/branding/name/CustomBrandingNamePatch.kt index 47c257496..921d1a4a7 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/branding/name/CustomBrandingNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/branding/name/CustomBrandingNamePatch.kt @@ -6,7 +6,7 @@ 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.music.utils.integrations.Constants.LANGUAGE_LIST -import app.revanced.patches.shared.patch.elements.AbstractRemoveStringsElementsPatch +import app.revanced.patches.shared.elements.AbstractRemoveStringsElementsPatch @Patch( name = "Custom branding name YouTube Music", diff --git a/src/main/kotlin/app/revanced/patches/music/layout/doubletapbackground/DoubleTapOverlayBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/doubletapbackground/DoubleTapOverlayBackgroundPatch.kt index 1bbce6197..ef340ec23 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/doubletapbackground/DoubleTapOverlayBackgroundPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/doubletapbackground/DoubleTapOverlayBackgroundPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.music.layout.doubletapbackground import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.overlaybackground.AbstractOverlayBackgroundPatch +import app.revanced.patches.shared.overlaybackground.AbstractOverlayBackgroundPatch @Patch( name = "Hide double tap overlay filter", diff --git a/src/main/kotlin/app/revanced/patches/music/layout/playeroverlay/PlayerOverlayFilterPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/playeroverlay/PlayerOverlayFilterPatch.kt index 5d62c0604..a881ef99f 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/playeroverlay/PlayerOverlayFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/playeroverlay/PlayerOverlayFilterPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.music.layout.doubletapbackground import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.overlaybackground.AbstractOverlayBackgroundPatch +import app.revanced.patches.shared.overlaybackground.AbstractOverlayBackgroundPatch @Patch( name = "Hide player overlay filter", diff --git a/src/main/kotlin/app/revanced/patches/music/misc/codecs/CodecsUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/codecs/CodecsUnlockPatch.kt index 9a92ef979..adcd82489 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/codecs/CodecsUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/codecs/CodecsUnlockPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.MISC_PATH import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch -import app.revanced.patches.shared.patch.opus.AbstractOpusCodecsPatch +import app.revanced.patches.shared.opus.AbstractOpusCodecsPatch @Patch( name = "Enable opus codec", diff --git a/src/main/kotlin/app/revanced/patches/music/misc/spoofappversion/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/spoofappversion/SpoofAppVersionPatch.kt index bc08cb022..de065450e 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/spoofappversion/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/spoofappversion/SpoofAppVersionPatch.kt @@ -7,7 +7,7 @@ import app.revanced.patches.music.utils.integrations.Constants.MISC_PATH import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.patches.music.utils.settings.SettingsPatch.contexts -import app.revanced.patches.shared.patch.versionspoof.AbstractVersionSpoofPatch +import app.revanced.patches.shared.versionspoof.AbstractVersionSpoofPatch import app.revanced.util.copyXmlNode @Patch( diff --git a/src/main/kotlin/app/revanced/patches/music/misc/tracking/SanitizeUrlQueryPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/tracking/SanitizeUrlQueryPatch.kt index 98e04f6f6..a0bd820e6 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/tracking/SanitizeUrlQueryPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/tracking/SanitizeUrlQueryPatch.kt @@ -7,8 +7,8 @@ import app.revanced.patches.music.misc.tracking.fingerprints.ShareLinkFormatterF import app.revanced.patches.music.utils.integrations.Constants.MISC_PATH import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch -import app.revanced.patches.shared.fingerprints.tracking.CopyTextEndpointFingerprint -import app.revanced.patches.shared.patch.tracking.AbstractSanitizeUrlQueryPatch +import app.revanced.patches.shared.tracking.AbstractSanitizeUrlQueryPatch +import app.revanced.patches.shared.tracking.fingerprints.CopyTextEndpointFingerprint @Patch( name = "Sanitize sharing links", diff --git a/src/main/kotlin/app/revanced/patches/music/misc/translations/TranslationsPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/translations/TranslationsPatch.kt index 1d384a218..1c14ee7d2 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/translations/TranslationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/translations/TranslationsPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.music.misc.translations import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.settings.SettingsPatch -import app.revanced.patches.shared.patch.translations.AbstractTranslationsPatch +import app.revanced.patches.shared.translations.AbstractTranslationsPatch @Patch( name = "Translations", diff --git a/src/main/kotlin/app/revanced/patches/music/player/colormatchplayer/ColorMatchPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/music/player/colormatchplayer/ColorMatchPlayerPatch.kt index 1ab7167cf..de56891ef 100644 --- a/src/main/kotlin/app/revanced/patches/music/player/colormatchplayer/ColorMatchPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/player/colormatchplayer/ColorMatchPlayerPatch.kt @@ -8,8 +8,8 @@ import app.revanced.patcher.extensions.or import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.music.utils.fingerprints.SwitchToggleColorFingerprint import app.revanced.patches.music.utils.fingerprints.MiniPlayerConstructorFingerprint +import app.revanced.patches.music.utils.fingerprints.SwitchToggleColorFingerprint import app.revanced.patches.music.utils.integrations.Constants.PLAYER import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.ColorGrey diff --git a/src/main/kotlin/app/revanced/patches/music/player/nextprevious/MiniPlayerButtonResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/player/nextprevious/MiniPlayerButtonResourcePatch.kt index c68b33283..032dc821e 100644 --- a/src/main/kotlin/app/revanced/patches/music/player/nextprevious/MiniPlayerButtonResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/player/nextprevious/MiniPlayerButtonResourcePatch.kt @@ -6,8 +6,8 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.DomFileEditor import app.revanced.patches.music.utils.settings.SettingsPatch import app.revanced.util.adoptChild -import app.revanced.util.insertNode import app.revanced.util.doRecursively +import app.revanced.util.insertNode import org.w3c.dom.Element import java.io.Closeable diff --git a/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/ClientSpoofPatch.kt index d0af44fce..ffc66a83f 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/fix/clientspoof/ClientSpoofPatch.kt @@ -1,5 +1,5 @@ package app.revanced.patches.music.utils.fix.clientspoof -import app.revanced.patches.shared.patch.clientspoof.AbstractClientSpoofPatch +import app.revanced.patches.shared.clientspoof.AbstractClientSpoofPatch object ClientSpoofPatch : AbstractClientSpoofPatch("com.google.android.apps.youtube.music") \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/utils/fix/fileprovider/FileProviderPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/fix/fileprovider/FileProviderPatch.kt index 2c183c5c0..d735bc134 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/fix/fileprovider/FileProviderPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/fix/fileprovider/FileProviderPatch.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.music.utils.fix.fileprovider.fingerprints.FileProviderResolverFingerprint -import app.revanced.patches.shared.patch.packagename.PackageNamePatch +import app.revanced.patches.shared.packagename.PackageNamePatch import app.revanced.util.exception @Patch(dependencies = [PackageNamePatch::class]) diff --git a/src/main/kotlin/app/revanced/patches/music/utils/integrations/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/integrations/IntegrationsPatch.kt index c5b80fd8e..281ebef85 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/integrations/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/integrations/IntegrationsPatch.kt @@ -1,12 +1,10 @@ package app.revanced.patches.music.utils.integrations import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.music.utils.integrations.Constants.INTEGRATIONS_PATH import app.revanced.patches.music.utils.integrations.fingerprints.InitFingerprint -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch @Patch(requiresIntegrations = true) -object IntegrationsPatch : AbstractIntegrationsPatch( - "$INTEGRATIONS_PATH/utils/ReVancedUtils;", +object IntegrationsPatch : BaseIntegrationsPatch( setOf(InitFingerprint), ) diff --git a/src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt index ad4111813..5b3cf515d 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt @@ -1,8 +1,9 @@ package app.revanced.patches.music.utils.integrations.fingerprints -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.Opcode +@Suppress("DEPRECATION") object InitFingerprint : IntegrationsFingerprint( returnType = "V", parameters = emptyList(), diff --git a/src/main/kotlin/app/revanced/patches/music/utils/intenthook/IntentHookPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/intenthook/IntentHookPatch.kt deleted file mode 100644 index d7019316f..000000000 --- a/src/main/kotlin/app/revanced/patches/music/utils/intenthook/IntentHookPatch.kt +++ /dev/null @@ -1,37 +0,0 @@ -package app.revanced.patches.music.utils.intenthook - -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.patches.music.utils.integrations.Constants.INTEGRATIONS_PATH -import app.revanced.patches.music.utils.integrations.IntegrationsPatch -import app.revanced.patches.music.utils.intenthook.fingerprints.GoogleApiActivityFingerprint -import app.revanced.util.exception - -@Patch( - dependencies = [IntegrationsPatch::class], - requiresIntegrations = true -) -object IntentHookPatch : BytecodePatch( - setOf(GoogleApiActivityFingerprint) -) { - override fun execute(context: BytecodeContext) { - - GoogleApiActivityFingerprint.result?.let { - it.mutableMethod.apply { - addInstructionsWithLabels( - 1, """ - invoke-static {p0}, $INTEGRATIONS_PATH/settingsmenu/ReVancedSettingActivity;->initializeSettings(Landroid/app/Activity;)Z - move-result v0 - if-eqz v0, :show - return-void - """, ExternalLabel("show", getInstruction(1)) - ) - } - } ?: throw GoogleApiActivityFingerprint.exception - - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/utils/litho/LithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/litho/LithoFilterPatch.kt deleted file mode 100644 index 9edc4549f..000000000 --- a/src/main/kotlin/app/revanced/patches/music/utils/litho/LithoFilterPatch.kt +++ /dev/null @@ -1,55 +0,0 @@ -package app.revanced.patches.music.utils.litho - -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.music.utils.litho.fingerprints.LithoFilterFingerprint -import app.revanced.patches.shared.patch.litho.ComponentParserPatch -import app.revanced.util.exception -import java.io.Closeable - -@Patch(dependencies = [ComponentParserPatch::class]) -object LithoFilterPatch : BytecodePatch( - setOf(LithoFilterFingerprint) -), Closeable { - private const val INTEGRATIONS_CLASS_DESCRIPTOR = - "$COMPONENTS_PATH/LithoFilterPatch;" - - internal lateinit var addFilter: (String) -> Unit - private set - - private var filterCount = 0 - - override fun execute(context: BytecodeContext) { - ComponentParserPatch.injectCall(INTEGRATIONS_CLASS_DESCRIPTOR) - - LithoFilterFingerprint.result?.let { - it.mutableMethod.apply { - removeInstructions(0, 6) - - addFilter = { classDescriptor -> - addInstructions( - 0, """ - new-instance v1, $classDescriptor - invoke-direct {v1}, $classDescriptor->()V - const/16 v2, ${filterCount++} - aput-object v1, v0, v2 - """ - ) - } - } - } ?: throw LithoFilterFingerprint.exception - - } - - override fun close() = LithoFilterFingerprint.result!! - .mutableMethod.addInstructions( - 0, """ - const/16 v0, $filterCount - new-array v0, v0, [$COMPONENTS_PATH/Filter; - """ - ) -} diff --git a/src/main/kotlin/app/revanced/patches/music/utils/microg/MicroGPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/MicroGPatch.kt index 8707d678a..941a83b04 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/microg/MicroGPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/MicroGPatch.kt @@ -17,8 +17,8 @@ import app.revanced.patches.music.utils.microg.fingerprints.CastDynamiteModuleV2 import app.revanced.patches.music.utils.microg.fingerprints.GooglePlayUtilityFingerprint import app.revanced.patches.music.utils.microg.fingerprints.PrimeFingerprint import app.revanced.patches.music.utils.microg.fingerprints.ServiceCheckFingerprint -import app.revanced.patches.shared.patch.microg.MicroGBytecodeHelper -import app.revanced.patches.shared.patch.packagename.PackageNamePatch +import app.revanced.patches.shared.microg.MicroGBytecodeHelper +import app.revanced.patches.shared.packagename.PackageNamePatch @Patch( name = "MicroG support", diff --git a/src/main/kotlin/app/revanced/patches/music/utils/microg/MicroGResourcePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/microg/MicroGResourcePatch.kt index f35e5ef51..1ee1b1197 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/microg/MicroGResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/microg/MicroGResourcePatch.kt @@ -11,10 +11,10 @@ import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.ResourceUtils.addMicroGPreference import app.revanced.patches.music.utils.settings.ResourceUtils.setMicroG import app.revanced.patches.music.utils.settings.SettingsPatch -import app.revanced.patches.shared.patch.microg.Constants.MICROG_PACKAGE_NAME -import app.revanced.patches.shared.patch.microg.MicroGManifestHelper.addSpoofingMetadata -import app.revanced.patches.shared.patch.microg.MicroGResourceHelper.patchManifest -import app.revanced.patches.shared.patch.packagename.PackageNamePatch +import app.revanced.patches.shared.microg.Constants.MICROG_PACKAGE_NAME +import app.revanced.patches.shared.microg.MicroGManifestHelper.addSpoofingMetadata +import app.revanced.patches.shared.microg.MicroGResourceHelper.patchManifest +import app.revanced.patches.shared.packagename.PackageNamePatch @Patch( dependencies = [ diff --git a/src/main/kotlin/app/revanced/patches/music/utils/overridequality/OverrideQualityHookPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/overridequality/OverrideQualityHookPatch.kt index 7c157b3e8..54ec8fee0 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/overridequality/OverrideQualityHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/overridequality/OverrideQualityHookPatch.kt @@ -90,7 +90,7 @@ object OverrideQualityHookPatch : BytecodePatch( addInstruction( textIndex + 1, - "sput-object v$textRegister, $INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR->currentQuality:Ljava/lang/String;" + "sput-object v$textRegister, $INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR->currentQuality:Ljava/lang/String;" ) } } ?: throw VideoQualityTextFingerprint.exception @@ -99,8 +99,8 @@ object OverrideQualityHookPatch : BytecodePatch( private const val INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR = "$VIDEO_PATH/VideoQualityPatch;" - private const val INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR = - "$INTEGRATIONS_PATH/utils/VideoHelpers;" + private const val INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR = + "$INTEGRATIONS_PATH/utils/VideoUtils;" private lateinit var QUALITY_CLASS: String private lateinit var QUALITY_METHOD: String diff --git a/src/main/kotlin/app/revanced/patches/music/utils/overridespeed/OverrideSpeedHookPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/overridespeed/OverrideSpeedHookPatch.kt index 2bb6f4334..a6d0c1c93 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/overridespeed/OverrideSpeedHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/overridespeed/OverrideSpeedHookPatch.kt @@ -39,8 +39,8 @@ object OverrideSpeedHookPatch : BytecodePatch( private const val INTEGRATIONS_PLAYBACK_SPEED_CLASS_DESCRIPTOR = "$VIDEO_PATH/PlaybackSpeedPatch;" - private const val INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR = - "$INTEGRATIONS_PATH/utils/VideoHelpers;" + private const val INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR = + "$INTEGRATIONS_PATH/utils/VideoUtils;" private lateinit var iGetObjectReference: Reference private lateinit var invokeInterfaceReference: Reference @@ -100,7 +100,7 @@ object OverrideSpeedHookPatch : BytecodePatch( speedMethod.addInstruction( speedMethod.implementation!!.instructions.size - 1, - "sput p1, $INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR->currentSpeed:F" + "sput p1, $INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR->currentSpeed:F" ) addInstructions( diff --git a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt index c2021bb72..aa2cb764f 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt @@ -3,15 +3,15 @@ package app.revanced.patches.music.utils.resourceid import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch -import app.revanced.patches.shared.patch.mapping.ResourceType -import app.revanced.patches.shared.patch.mapping.ResourceType.BOOL -import app.revanced.patches.shared.patch.mapping.ResourceType.COLOR -import app.revanced.patches.shared.patch.mapping.ResourceType.DIMEN -import app.revanced.patches.shared.patch.mapping.ResourceType.ID -import app.revanced.patches.shared.patch.mapping.ResourceType.LAYOUT -import app.revanced.patches.shared.patch.mapping.ResourceType.STRING -import app.revanced.patches.shared.patch.mapping.ResourceType.STYLE +import app.revanced.patches.shared.mapping.ResourceMappingPatch +import app.revanced.patches.shared.mapping.ResourceType +import app.revanced.patches.shared.mapping.ResourceType.BOOL +import app.revanced.patches.shared.mapping.ResourceType.COLOR +import app.revanced.patches.shared.mapping.ResourceType.DIMEN +import app.revanced.patches.shared.mapping.ResourceType.ID +import app.revanced.patches.shared.mapping.ResourceType.LAYOUT +import app.revanced.patches.shared.mapping.ResourceType.STRING +import app.revanced.patches.shared.mapping.ResourceType.STYLE @Patch(dependencies = [ResourceMappingPatch::class]) object SharedResourceIdPatch : ResourcePatch() { diff --git a/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubedislike/ReturnYouTubeDislikeBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubedislike/ReturnYouTubeDislikeBytecodePatch.kt index 67862b843..aa1731a12 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubedislike/ReturnYouTubeDislikeBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubedislike/ReturnYouTubeDislikeBytecodePatch.kt @@ -68,7 +68,7 @@ object ReturnYouTubeDislikeBytecodePatch : BytecodePatch( addInstructions( insertIndex, """ - invoke-static {v$insertRegister}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->onComponentCreated(Landroid/text/Spanned;)Landroid/text/Spanned; + invoke-static {v$insertRegister}, $INTEGRATIONS_RYD_CLASS_DESCRIPTOR->onSpannedCreated(Landroid/text/Spanned;)Landroid/text/Spanned; move-result-object v$insertRegister """ ) diff --git a/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsBytecodePatch.kt index d065c4992..397cbf09f 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsBytecodePatch.kt @@ -2,16 +2,23 @@ package app.revanced.patches.music.utils.settings import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels 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.patcher.util.smali.ExternalLabel import app.revanced.patches.music.utils.integrations.Constants.INTEGRATIONS_PATH import app.revanced.patches.music.utils.integrations.IntegrationsPatch import app.revanced.patches.music.utils.mainactivity.MainActivityResolvePatch import app.revanced.patches.music.utils.mainactivity.MainActivityResolvePatch.injectInit +import app.revanced.patches.music.utils.settings.fingerprints.GoogleApiActivityFingerprint import app.revanced.patches.music.utils.settings.fingerprints.PreferenceFingerprint import app.revanced.patches.music.utils.settings.fingerprints.SettingsHeadersFragmentFingerprint +import app.revanced.patches.shared.settings.fingerprints.SharedSettingFingerprint import app.revanced.util.exception +import app.revanced.util.getTargetIndex +import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @@ -24,19 +31,36 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction ) object SettingsBytecodePatch : BytecodePatch( setOf( + GoogleApiActivityFingerprint, PreferenceFingerprint, + SharedSettingFingerprint, SettingsHeadersFragmentFingerprint ) ) { private const val INTEGRATIONS_ACTIVITY_CLASS_DESCRIPTOR = - "$INTEGRATIONS_PATH/settingsmenu/ReVancedSettingActivity;" + "$INTEGRATIONS_PATH/settings/ActivityHook;" private const val INTEGRATIONS_FRAGMENT_CLASS_DESCRIPTOR = - "$INTEGRATIONS_PATH/settingsmenu/ReVancedSettingsFragment;" + "$INTEGRATIONS_PATH/settings/preference/ReVancedPreferenceFragment;" override fun execute(context: BytecodeContext) { /** - * Inject settings Activity. + * Set SharedPrefCategory + */ + SharedSettingFingerprint.result?.let { + it.mutableMethod.apply { + val stringIndex = getTargetIndex(Opcode.CONST_STRING) + val stringRegister = getInstruction(stringIndex).registerA + + replaceInstruction( + stringIndex, + "const-string v$stringRegister, \"youtube\"" + ) + } + } ?: throw SharedSettingFingerprint.exception + + /** + * Inject settings Activity */ SettingsHeadersFragmentFingerprint.result?.let { it.mutableMethod.apply { @@ -51,7 +75,7 @@ object SettingsBytecodePatch : BytecodePatch( } ?: throw SettingsHeadersFragmentFingerprint.exception /** - * Values are loaded when preferences change. + * Values are loaded when preferences change */ PreferenceFingerprint.result?.let { it.mutableMethod.apply { @@ -66,8 +90,24 @@ object SettingsBytecodePatch : BytecodePatch( } } ?: throw PreferenceFingerprint.exception + /** + * Inject dummy Activity for intent + */ + GoogleApiActivityFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 1, """ + invoke-static {p0}, $INTEGRATIONS_ACTIVITY_CLASS_DESCRIPTOR->initialize(Landroid/app/Activity;)Z + move-result v0 + if-eqz v0, :show + return-void + """, ExternalLabel("show", getInstruction(1)) + ) + } + } ?: throw GoogleApiActivityFingerprint.exception + injectInit("InitializationPatch", "setDeviceInformation") - injectInit("InitializationPatch", "initializeReVancedSettings") + injectInit("InitializationPatch", "onCreate") } } diff --git a/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsPatch.kt index cb0ca26c9..08e3eb4c4 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/SettingsPatch.kt @@ -4,7 +4,6 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.fix.accessibility.AccessibilityNodeInfoPatch -import app.revanced.patches.music.utils.intenthook.IntentHookPatch import app.revanced.patches.music.utils.settings.ResourceUtils.YOUTUBE_MUSIC_SETTINGS_KEY import app.revanced.patches.music.utils.settings.ResourceUtils.addMusicPreference import app.revanced.patches.music.utils.settings.ResourceUtils.addMusicPreferenceCategory @@ -12,7 +11,7 @@ import app.revanced.patches.music.utils.settings.ResourceUtils.addMusicPreferenc import app.revanced.patches.music.utils.settings.ResourceUtils.addMusicPreferenceWithoutSummary import app.revanced.patches.music.utils.settings.ResourceUtils.addReVancedMusicPreference import app.revanced.patches.music.utils.settings.ResourceUtils.sortMusicPreferenceCategory -import app.revanced.patches.shared.patch.settings.AbstractSettingsResourcePatch +import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch import app.revanced.util.ResourceGroup import app.revanced.util.copyResources import app.revanced.util.copyXmlNode @@ -26,7 +25,6 @@ import java.util.concurrent.TimeUnit description = "Adds ReVanced Extended settings to YouTube Music.", dependencies = [ AccessibilityNodeInfoPatch::class, - IntentHookPatch::class, SettingsBytecodePatch::class ], compatiblePackages = [ @@ -47,7 +45,7 @@ import java.util.concurrent.TimeUnit ) ] ) -@Suppress("unused") +@Suppress("DEPRECATION", "unused") object SettingsPatch : AbstractSettingsResourcePatch( "music/settings" ), Closeable { diff --git a/src/main/kotlin/app/revanced/patches/music/utils/intenthook/fingerprints/GoogleApiActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/fingerprints/GoogleApiActivityFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/music/utils/intenthook/fingerprints/GoogleApiActivityFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/utils/settings/fingerprints/GoogleApiActivityFingerprint.kt index 98a223694..7aab144ee 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/intenthook/fingerprints/GoogleApiActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/fingerprints/GoogleApiActivityFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.utils.intenthook.fingerprints +package app.revanced.patches.music.utils.settings.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/music/video/customspeed/CustomPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/music/video/customspeed/CustomPlaybackSpeedPatch.kt index 904503bee..2e509a19c 100644 --- a/src/main/kotlin/app/revanced/patches/music/video/customspeed/CustomPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/video/customspeed/CustomPlaybackSpeedPatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.utils.integrations.Constants.VIDEO_PATH import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch -import app.revanced.patches.shared.patch.customspeed.AbstractCustomPlaybackSpeedPatch +import app.revanced.patches.shared.customspeed.AbstractCustomPlaybackSpeedPatch @Patch( name = "Custom playback speed", diff --git a/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt index 293c38ed7..d1ddc70e2 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/ad/banner/HideBannerPatch.kt @@ -3,6 +3,7 @@ package app.revanced.patches.reddit.ad.banner import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch +@Suppress("DEPRECATION") object HideBannerPatch : ResourcePatch() { private const val RESOURCE_FILE_PATH = "res/layout/merge_listheader_link_detail.xml" override fun execute(context: ResourceContext) { diff --git a/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt index f36344b74..fc0ac4769 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/ad/comments/HideCommentAdsPatch.kt @@ -4,26 +4,22 @@ 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.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.util.exception +import app.revanced.util.getWalkerMethod object HideCommentAdsPatch : BytecodePatch( setOf(HideCommentAdsFingerprint) ) { private const val INTEGRATION_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/GeneralAdsPatch;" + - "->hideCommentAds()Z" + "$PATCHES_PATH/GeneralAdsPatch;->hideCommentAds()Z" override fun execute(context: BytecodeContext) { - HideCommentAdsFingerprint.result?.let { - with( - context - .toMethodWalker(it.method) - .nextMethod(it.scanResult.patternScanResult!!.startIndex, true) - .getMethod() as MutableMethod - ) { + HideCommentAdsFingerprint.result?.apply { + val walkerMethod = getWalkerMethod(context, scanResult.patternScanResult!!.startIndex) + walkerMethod.apply { addInstructionsWithLabels( 0, """ invoke-static {}, $INTEGRATION_METHOD_DESCRIPTOR diff --git a/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt index 01877af16..e6ecf30ed 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/ad/general/HideAdsPatch.kt @@ -5,7 +5,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions 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.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel @@ -13,13 +12,14 @@ import app.revanced.patches.reddit.ad.banner.HideBannerPatch import app.revanced.patches.reddit.ad.comments.HideCommentAdsPatch import app.revanced.patches.reddit.ad.general.fingerprints.AdPostFingerprint import app.revanced.patches.reddit.ad.general.fingerprints.NewAdPostFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.util.exception +import app.revanced.util.getTargetIndexWithFieldReferenceName +import app.revanced.util.getTargetIndexWithMethodReferenceName import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c -import com.android.tools.smali.dexlib2.iface.reference.FieldReference +import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @Patch( name = "Hide ads", @@ -44,26 +44,17 @@ object HideAdsPatch : BytecodePatch( ) ) { private const val INTEGRATIONS_OLD_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/GeneralAdsPatch;" + - "->hideOldPostAds(Ljava/util/List;)Ljava/util/List;" + "$PATCHES_PATH/GeneralAdsPatch;->hideOldPostAds(Ljava/util/List;)Ljava/util/List;" private const val INTEGRATIONS_NEW_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/GeneralAdsPatch;" + - "->hideNewPostAds()Z" + "$PATCHES_PATH/GeneralAdsPatch;->hideNewPostAds()Z" override fun execute(context: BytecodeContext) { // region Filter promoted ads (does not work in popular or latest feed) - AdPostFingerprint.result?.let { it.mutableMethod.apply { - val targetIndex = it.scanResult.patternScanResult!!.endIndex - val targetReference = getInstruction(targetIndex).reference - val targetReferenceName = (targetReference as FieldReference).name - - if (targetReferenceName != "children") - throw PatchException("Method signature reference name did not match: $targetReferenceName") - - val targetRegister = getInstruction(targetIndex).registerA + val targetIndex = getTargetIndexWithFieldReferenceName("children") + val targetRegister = getInstruction(targetIndex).registerA addInstructions( targetIndex, """ @@ -79,13 +70,7 @@ object HideAdsPatch : BytecodePatch( // By removing the appending instruction no ad posts gets appended to the feed. NewAdPostFingerprint.result?.let { it.mutableMethod.apply { - val targetIndex = it.scanResult.patternScanResult!!.endIndex - val targetParameter = - getInstruction(targetIndex).reference.toString() - - if (!targetParameter.endsWith("Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z")) - throw PatchException("Method signature parameter did not match: $targetParameter") - + val targetIndex = getTargetIndexWithMethodReferenceName("add") val targetRegister = getInstruction(targetIndex).registerD + 1 @@ -99,7 +84,7 @@ object HideAdsPatch : BytecodePatch( } } ?: throw NewAdPostFingerprint.exception - updateSettingsStatus("GeneralAds") + updateSettingsStatus("enableGeneralAds") } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/ad/general/fingerprints/AdPostFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/ad/general/fingerprints/AdPostFingerprint.kt index f9741398f..ff7ef3937 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/ad/general/fingerprints/AdPostFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/ad/general/fingerprints/AdPostFingerprint.kt @@ -9,10 +9,6 @@ object AdPostFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, opcodes = listOf( - Opcode.CONST_STRING, - null, - Opcode.CONST_STRING, - null, Opcode.INVOKE_DIRECT, Opcode.IPUT_OBJECT ), diff --git a/src/main/kotlin/app/revanced/patches/reddit/ad/general/fingerprints/NewAdPostFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/ad/general/fingerprints/NewAdPostFingerprint.kt index 127247163..d8f72ea30 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/ad/general/fingerprints/NewAdPostFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/ad/general/fingerprints/NewAdPostFingerprint.kt @@ -8,9 +8,7 @@ import com.android.tools.smali.dexlib2.Opcode object NewAdPostFingerprint : MethodFingerprint( returnType = "L", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - opcodes = listOf( - Opcode.INVOKE_VIRTUAL, - ), + opcodes = listOf(Opcode.INVOKE_VIRTUAL), strings = listOf( "chain", "feedElement" diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/branding/name/CustomBrandingNamePatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/branding/name/CustomBrandingNamePatch.kt index 21b7c0546..f014dd5a0 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/branding/name/CustomBrandingNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/branding/name/CustomBrandingNamePatch.kt @@ -1,7 +1,6 @@ package app.revanced.patches.reddit.layout.branding.name import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch @@ -23,48 +22,61 @@ import java.nio.file.Files ], use = false ) -@Suppress("unused") +@Suppress("DEPRECATION", "unused") object CustomBrandingNamePatch : ResourcePatch() { + private const val ORIGINAL_APP_NAME = "Reddit" private const val APP_NAME = "RVX Reddit" private val AppName by stringPatchOption( key = "AppName", - default = APP_NAME, + default = ORIGINAL_APP_NAME, + values = mapOf( + "Default" to APP_NAME, + "Original" to ORIGINAL_APP_NAME, + ), title = "App name", description = "The name of the app." ) override fun execute(context: ResourceContext) { - val appName = AppName - ?: throw PatchException("Invalid app name.") - - val resDirectory = context["res"] - - val valuesV24Directory = resDirectory.resolve("values-v24") - if (!valuesV24Directory.isDirectory) - Files.createDirectories(valuesV24Directory.toPath()) - - val stringsXml = valuesV24Directory.resolve("strings.xml") - - if (!stringsXml.exists()) { - FileWriter(stringsXml).use { - it.write("") - } + val appName = if (AppName != null) { + AppName!! + } else { + println("WARNING: Invalid name name. Does not apply patches.") + ORIGINAL_APP_NAME } - context.xmlEditor["res/values-v24/strings.xml"].use { editor -> - val document = editor.file + if (appName != ORIGINAL_APP_NAME) { + val resDirectory = context["res"] - mapOf( - "app_name" to appName - ).forEach { (k, v) -> - val stringElement = document.createElement("string") + val valuesV24Directory = resDirectory.resolve("values-v24") + if (!valuesV24Directory.isDirectory) + Files.createDirectories(valuesV24Directory.toPath()) - stringElement.setAttribute("name", k) - stringElement.textContent = v + val stringsXml = valuesV24Directory.resolve("strings.xml") - document.getElementsByTagName("resources").item(0).appendChild(stringElement) + if (!stringsXml.exists()) { + FileWriter(stringsXml).use { + it.write("") + } } + + context.xmlEditor["res/values-v24/strings.xml"].use { editor -> + val document = editor.file + + mapOf( + "app_name" to appName + ).forEach { (k, v) -> + val stringElement = document.createElement("string") + + stringElement.setAttribute("name", k) + stringElement.textContent = v + + document.getElementsByTagName("resources").item(0).appendChild(stringElement) + } + } + } else { + println("INFO: App name will remain unchanged as it matches the original.") } } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/branding/packagename/ChangePackageNamePatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/branding/packagename/ChangePackageNamePatch.kt index 0a15e5718..03baf91c0 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/branding/packagename/ChangePackageNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/branding/packagename/ChangePackageNamePatch.kt @@ -1,7 +1,6 @@ package app.revanced.patches.reddit.layout.branding.packagename import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch @@ -23,21 +22,22 @@ import java.io.Closeable ], use = false ) -@Suppress("unused") +@Suppress("DEPRECATION", "unused") object ChangePackageNamePatch : ResourcePatch(), Closeable { private const val PACKAGE_NAME_REDDIT = "com.reddit.frontpage" private const val CLONE_PACKAGE_NAME_REDDIT = "$PACKAGE_NAME_REDDIT.revanced" private const val DEFAULT_PACKAGE_NAME_REDDIT = "$PACKAGE_NAME_REDDIT.rvx" private lateinit var context: ResourceContext - private lateinit var redditPackageName: String + private var redditPackageName = PACKAGE_NAME_REDDIT private val PackageNameReddit by stringPatchOption( key = "PackageNameReddit", - default = DEFAULT_PACKAGE_NAME_REDDIT, + default = PACKAGE_NAME_REDDIT, values = mapOf( "Clone" to CLONE_PACKAGE_NAME_REDDIT, - "Default" to DEFAULT_PACKAGE_NAME_REDDIT + "Default" to DEFAULT_PACKAGE_NAME_REDDIT, + "Original" to PACKAGE_NAME_REDDIT, ), title = "Package name of Reddit", description = "The name of the package to rename the app to." @@ -46,35 +46,44 @@ object ChangePackageNamePatch : ResourcePatch(), Closeable { override fun execute(context: ResourceContext) { this.context = context - redditPackageName = PackageNameReddit - ?: throw PatchException("Invalid package name.") + if (PackageNameReddit != null) { + redditPackageName = PackageNameReddit!! + } else { + println("WARNING: Invalid package name. Does not apply patches.") + } - // Ensure device runs Android. - try { - // RVX Manager - // ==== - // For some reason, in Android AAPT2, a compilation error occurs when changing the [strings.xml] of the Reddit - // This only affects RVX Manager, and has not yet found a valid workaround - Class.forName("android.os.Environment") - } catch (_: ClassNotFoundException) { - // CLI - context.replacePackageName(redditPackageName) + if (redditPackageName != PACKAGE_NAME_REDDIT) { + // Ensure device runs Android. + try { + // RVX Manager + // ==== + // For some reason, in Android AAPT2, a compilation error occurs when changing the [strings.xml] of the Reddit + // This only affects RVX Manager, and has not yet found a valid workaround + Class.forName("android.os.Environment") + } catch (_: ClassNotFoundException) { + // CLI + context.replacePackageName(redditPackageName) + } + } else { + println("INFO: Package name will remain unchanged as it matches the original.") } } override fun close() { - context["AndroidManifest.xml"].apply { - writeText( - readText() - .replace( - "package=\"$PACKAGE_NAME_REDDIT", - "package=\"$redditPackageName" - ) - .replace( - "$PACKAGE_NAME_REDDIT.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION", - "$redditPackageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" - ) - ) + if (redditPackageName != PACKAGE_NAME_REDDIT) { + context["AndroidManifest.xml"].apply { + writeText( + readText() + .replace( + "package=\"$PACKAGE_NAME_REDDIT", + "package=\"$redditPackageName" + ) + .replace( + "$PACKAGE_NAME_REDDIT.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION", + "$redditPackageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" + ) + ) + } } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/navigation/NavigationButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/navigation/NavigationButtonsPatch.kt index 09f8dcad6..b509a1d79 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/navigation/NavigationButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/navigation/NavigationButtonsPatch.kt @@ -7,6 +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.patches.reddit.layout.navigation.fingerprints.BottomNavScreenFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.util.exception @@ -31,8 +32,7 @@ object NavigationButtonsPatch : BytecodePatch( setOf(BottomNavScreenFingerprint) ) { private const val INTEGRATIONS_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/NavigationButtonsPatch;" + - "->hideNavigationButtons(Landroid/view/ViewGroup;)V" + "$PATCHES_PATH/NavigationButtonsPatch;->hideNavigationButtons(Landroid/view/ViewGroup;)V" override fun execute(context: BytecodeContext) { @@ -49,7 +49,7 @@ object NavigationButtonsPatch : BytecodePatch( } } ?: throw BottomNavScreenFingerprint.exception - updateSettingsStatus("NavigationButtons") + updateSettingsStatus("enableNavigationButtons") } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/fingerprints/PremiumIconFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/fingerprints/PremiumIconFingerprint.kt index 6f6aa6eac..9d3aeeae4 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/fingerprints/PremiumIconFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/premiumicon/fingerprints/PremiumIconFingerprint.kt @@ -5,6 +5,7 @@ import app.revanced.patcher.fingerprint.MethodFingerprint object PremiumIconFingerprint : MethodFingerprint( returnType = "Z", customFingerprint = { methodDef, classDef -> - methodDef.definingClass.endsWith("/MyAccount;") && methodDef.name == "isPremiumSubscriber" && classDef.sourceFile == "MyAccount.kt" + methodDef.definingClass.endsWith("/MyAccount;") + && methodDef.name == "isPremiumSubscriber" && classDef.sourceFile == "MyAccount.kt" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/recentlyvisited/RecentlyVisitedShelfPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/recentlyvisited/RecentlyVisitedShelfPatch.kt index 5618f08a8..a005b7b5b 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/recentlyvisited/RecentlyVisitedShelfPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/recentlyvisited/RecentlyVisitedShelfPatch.kt @@ -8,16 +8,17 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.reddit.layout.recentlyvisited.fingerprints.CommunityDrawerPresenterFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.util.exception -import app.revanced.util.getReference import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndexReversed +import app.revanced.util.getTargetIndexWithFieldReferenceName +import app.revanced.util.getTargetIndexWithReference import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.reference.FieldReference import com.android.tools.smali.dexlib2.iface.reference.Reference @Patch( @@ -39,8 +40,7 @@ object RecentlyVisitedShelfPatch : BytecodePatch( setOf(CommunityDrawerPresenterFingerprint) ) { private const val INTEGRATIONS_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/RecentlyVisitedShelfPatch;" + - "->hideRecentlyVisitedShelf(Ljava/util/List;)Ljava/util/List;" + "$PATCHES_PATH/RecentlyVisitedShelfPatch;->hideRecentlyVisitedShelf(Ljava/util/List;)Ljava/util/List;" override fun execute(context: BytecodeContext) { @@ -49,20 +49,14 @@ object RecentlyVisitedShelfPatch : BytecodePatch( it.mutableClass.methods.find { method -> method.name == "" } ?.apply { - val recentlyVisitedFieldIndex = implementation!!.instructions.indexOfFirst { instruction -> - instruction.opcode == Opcode.SGET_OBJECT - && instruction.getReference()?.name == "RECENTLY_VISITED" - } + val recentlyVisitedFieldIndex = getTargetIndexWithFieldReferenceName("RECENTLY_VISITED") val recentlyVisitedObjectIndex = getTargetIndex(recentlyVisitedFieldIndex, Opcode.IPUT_OBJECT) recentlyVisitedReference = getInstruction(recentlyVisitedObjectIndex).reference } ?: throw PatchException("Constructor method not found!") it.mutableMethod.apply { - val recentlyVisitedObjectIndex = implementation!!.instructions.indexOfFirst { instruction -> - instruction.opcode == Opcode.IGET_OBJECT - && (instruction as? ReferenceInstruction)?.reference == recentlyVisitedReference - } + val recentlyVisitedObjectIndex = getTargetIndexWithReference(recentlyVisitedReference.toString()) arrayOf( getTargetIndex(recentlyVisitedObjectIndex, Opcode.INVOKE_STATIC), getTargetIndexReversed(recentlyVisitedObjectIndex, Opcode.INVOKE_STATIC) @@ -80,7 +74,7 @@ object RecentlyVisitedShelfPatch : BytecodePatch( } } ?: throw CommunityDrawerPresenterFingerprint.exception - updateSettingsStatus("RecentlyVisitedShelf") + updateSettingsStatus("enableRecentlyVisitedShelf") } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/screenshotpopup/ScreenshotPopupPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/screenshotpopup/ScreenshotPopupPatch.kt index 7e2a41bb7..341912cde 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/screenshotpopup/ScreenshotPopupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/screenshotpopup/ScreenshotPopupPatch.kt @@ -8,6 +8,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.reddit.layout.screenshotpopup.fingerprints.ScreenshotTakenBannerFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsPatch @@ -32,8 +33,7 @@ object ScreenshotPopupPatch : BytecodePatch( setOf(ScreenshotTakenBannerFingerprint) ) { private const val INTEGRATIONS_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/ScreenshotPopupPatch;" + - "->disableScreenshotPopup()Z" + "$PATCHES_PATH/ScreenshotPopupPatch;->disableScreenshotPopup()Z" override fun execute(context: BytecodeContext) { @@ -50,7 +50,7 @@ object ScreenshotPopupPatch : BytecodePatch( } } ?: throw ScreenshotTakenBannerFingerprint.exception - updateSettingsStatus("ScreenshotPopup") + updateSettingsStatus("enableScreenshotPopup") } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/subredditdialog/RemoveSubRedditDialogPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/subredditdialog/RemoveSubRedditDialogPatch.kt index 3650aece2..e0a4d1145 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/subredditdialog/RemoveSubRedditDialogPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/subredditdialog/RemoveSubRedditDialogPatch.kt @@ -8,6 +8,7 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.reddit.layout.subredditdialog.fingerprints.FrequentUpdatesSheetScreenFingerprint import app.revanced.patches.reddit.layout.subredditdialog.fingerprints.RedditAlertDialogsFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch.CancelButton import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch.TextAppearanceRedditBaseOldButtonColored @@ -40,7 +41,7 @@ object RemoveSubRedditDialogPatch : BytecodePatch( ) ) { private const val INTEGRATIONS_CLASS_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/RemoveSubRedditDialogPatch;" + "$PATCHES_PATH/RemoveSubRedditDialogPatch;" override fun execute(context: BytecodeContext) { @@ -68,7 +69,7 @@ object RemoveSubRedditDialogPatch : BytecodePatch( } } ?: throw RedditAlertDialogsFingerprint.exception - updateSettingsStatus("RemoveSubRedditDialog") + updateSettingsStatus("enableSubRedditDialog") } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/toolbar/ToolBarButtonPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/toolbar/ToolBarButtonPatch.kt index 737c8e360..20388478f 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/toolbar/ToolBarButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/toolbar/ToolBarButtonPatch.kt @@ -7,6 +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.patches.reddit.layout.toolbar.fingerprints.HomePagerScreenFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch.ToolBarNavSearchCtaContainer import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus @@ -38,8 +39,7 @@ object ToolBarButtonPatch : BytecodePatch( setOf(HomePagerScreenFingerprint) ) { private const val INTEGRATIONS_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/ToolBarButtonPatch;" + - "->hideToolBarButton(Landroid/view/View;)V" + "$PATCHES_PATH/ToolBarButtonPatch;->hideToolBarButton(Landroid/view/View;)V" override fun execute(context: BytecodeContext) { @@ -57,7 +57,7 @@ object ToolBarButtonPatch : BytecodePatch( } } ?: throw HomePagerScreenFingerprint.exception - updateSettingsStatus("ToolBarButton") + updateSettingsStatus("enableToolBarButton") } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/misc/openlink/OpenLinksDirectlyPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/misc/openlink/OpenLinksDirectlyPatch.kt index f819ceaf3..7337f99f4 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/misc/openlink/OpenLinksDirectlyPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/misc/openlink/OpenLinksDirectlyPatch.kt @@ -6,6 +6,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.reddit.misc.openlink.fingerprints.ScreenNavigatorFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.util.exception @@ -29,8 +30,7 @@ object OpenLinksDirectlyPatch : BytecodePatch( setOf(ScreenNavigatorFingerprint) ) { private const val INTEGRATIONS_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/OpenLinksDirectlyPatch;" + - "->parseRedirectUri(Landroid/net/Uri;)Landroid/net/Uri;" + "$PATCHES_PATH/OpenLinksDirectlyPatch;->parseRedirectUri(Landroid/net/Uri;)Landroid/net/Uri;" override fun execute(context: BytecodeContext) { ScreenNavigatorFingerprint.result?.let { @@ -44,7 +44,7 @@ object OpenLinksDirectlyPatch : BytecodePatch( } } ?: throw ScreenNavigatorFingerprint.exception - updateSettingsStatus("OpenLinksDirectly") + updateSettingsStatus("enableOpenLinksDirectly") } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/misc/openlink/OpenLinksExternallyPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/misc/openlink/OpenLinksExternallyPatch.kt index 8336c1341..d158d557a 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/misc/openlink/OpenLinksExternallyPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/misc/openlink/OpenLinksExternallyPatch.kt @@ -8,6 +8,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.reddit.misc.openlink.fingerprints.ScreenNavigatorFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.util.exception @@ -32,7 +33,7 @@ object OpenLinksExternallyPatch : BytecodePatch( setOf(ScreenNavigatorFingerprint) ) { private const val INTEGRATIONS_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/OpenLinksExternallyPatch;" + "$PATCHES_PATH/OpenLinksExternallyPatch;" override fun execute(context: BytecodeContext) { ScreenNavigatorFingerprint.result?.let { @@ -50,7 +51,7 @@ object OpenLinksExternallyPatch : BytecodePatch( } } ?: throw ScreenNavigatorFingerprint.exception - updateSettingsStatus("OpenLinksExternally") + updateSettingsStatus("enableOpenLinksExternally") } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt index 5a38fd59d..cb740530f 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/SanitizeUrlQueryPatch.kt @@ -8,6 +8,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.reddit.misc.tracking.url.fingerprints.ShareLinkFormatterFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.settings.SettingsBytecodePatch.updateSettingsStatus import app.revanced.patches.reddit.utils.settings.SettingsPatch import app.revanced.util.exception @@ -31,13 +32,11 @@ object SanitizeUrlQueryPatch : BytecodePatch( setOf(ShareLinkFormatterFingerprint) ) { private const val SANITIZE_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/patches/SanitizeUrlQueryPatch;" + - "->stripQueryParameters()Z" + "$PATCHES_PATH/SanitizeUrlQueryPatch;->stripQueryParameters()Z" override fun execute(context: BytecodeContext) { ShareLinkFormatterFingerprint.result?.let { result -> result.mutableMethod.apply { - addInstructionsWithLabels( 0, """ @@ -50,7 +49,7 @@ object SanitizeUrlQueryPatch : BytecodePatch( } } ?: throw ShareLinkFormatterFingerprint.exception - updateSettingsStatus("SanitizeUrlQuery") + updateSettingsStatus("enableSanitizeUrlQuery") } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/Constants.kt b/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/Constants.kt new file mode 100644 index 000000000..f8555307e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/Constants.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.reddit.utils.integrations + +@Suppress("MemberVisibilityCanBePrivate") +object Constants { + const val INTEGRATIONS_PATH = "Lapp/revanced/integrations/reddit" + const val PATCHES_PATH = "$INTEGRATIONS_PATH/patches" +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/IntegrationsPatch.kt index 7df8b7580..49141d796 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/IntegrationsPatch.kt @@ -2,10 +2,9 @@ package app.revanced.patches.reddit.utils.integrations import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.reddit.utils.integrations.fingerprints.InitFingerprint -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch @Patch(requiresIntegrations = true) -object IntegrationsPatch : AbstractIntegrationsPatch( - "Lapp/revanced/integrations/reddit/utils/ReVancedUtils;", +object IntegrationsPatch : BaseIntegrationsPatch( setOf(InitFingerprint), ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/fingerprints/InitFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/fingerprints/InitFingerprint.kt index 860b6b026..05b51f66b 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/fingerprints/InitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/utils/integrations/fingerprints/InitFingerprint.kt @@ -1,7 +1,8 @@ package app.revanced.patches.reddit.utils.integrations.fingerprints -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint +@Suppress("DEPRECATION") object InitFingerprint : IntegrationsFingerprint( customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/FrontpageApplication;") && diff --git a/src/main/kotlin/app/revanced/patches/reddit/utils/resourceid/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/utils/resourceid/SharedResourceIdPatch.kt index 02c372d7b..1698293be 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/utils/resourceid/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/utils/resourceid/SharedResourceIdPatch.kt @@ -3,32 +3,27 @@ package app.revanced.patches.reddit.utils.resourceid import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch -import app.revanced.patches.shared.patch.mapping.ResourceType -import app.revanced.patches.shared.patch.mapping.ResourceType.ID -import app.revanced.patches.shared.patch.mapping.ResourceType.STRING -import app.revanced.patches.shared.patch.mapping.ResourceType.STYLE +import app.revanced.patches.shared.mapping.ResourceMappingPatch +import app.revanced.patches.shared.mapping.ResourceMappingPatch.getId +import app.revanced.patches.shared.mapping.ResourceType.ID +import app.revanced.patches.shared.mapping.ResourceType.STRING +import app.revanced.patches.shared.mapping.ResourceType.STYLE @Patch(dependencies = [ResourceMappingPatch::class]) object SharedResourceIdPatch : ResourcePatch() { - var CancelButton: Long = -1L - var LabelAcknowledgements: Long = -1L - var ScreenShotShareBanner: Long = -1L - var TextAppearanceRedditBaseOldButtonColored: Long = -1L - var ToolBarNavSearchCtaContainer: Long = -1L + var CancelButton = -1L + var LabelAcknowledgements = -1L + var ScreenShotShareBanner = -1L + var TextAppearanceRedditBaseOldButtonColored = -1L + var ToolBarNavSearchCtaContainer = -1L override fun execute(context: ResourceContext) { - fun find(resourceType: ResourceType, resourceName: String) = ResourceMappingPatch - .resourceMappings - .find { it.type == resourceType.value && it.name == resourceName }?.id - ?: -1 - - CancelButton = find(ID, "cancel_button") - LabelAcknowledgements = find(STRING, "label_acknowledgements") - ScreenShotShareBanner = find(STRING, "screenshot_share_banner_title") - TextAppearanceRedditBaseOldButtonColored = find(STYLE, "TextAppearance.RedditBase.OldButton.Colored") - ToolBarNavSearchCtaContainer = find(ID, "toolbar_nav_search_cta_container") + CancelButton = getId(ID, "cancel_button") + LabelAcknowledgements = getId(STRING, "label_acknowledgements") + ScreenShotShareBanner = getId(STRING, "screenshot_share_banner_title") + TextAppearanceRedditBaseOldButtonColored = getId(STYLE, "TextAppearance.RedditBase.OldButton.Colored") + ToolBarNavSearchCtaContainer = getId(ID, "toolbar_nav_search_cta_container") } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/utils/settings/SettingsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/reddit/utils/settings/SettingsBytecodePatch.kt index bafc06292..0645353d3 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/utils/settings/SettingsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/utils/settings/SettingsBytecodePatch.kt @@ -4,16 +4,21 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions 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.patcher.util.proxy.mutableTypes.MutableMethod +import app.revanced.patches.reddit.utils.integrations.Constants.INTEGRATIONS_PATH import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.reddit.utils.resourceid.SharedResourceIdPatch.LabelAcknowledgements import app.revanced.patches.reddit.utils.settings.fingerprints.AcknowledgementsLabelBuilderFingerprint import app.revanced.patches.reddit.utils.settings.fingerprints.OssLicensesMenuActivityOnCreateFingerprint import app.revanced.patches.reddit.utils.settings.fingerprints.SettingsStatusLoadFingerprint +import app.revanced.patches.shared.settings.fingerprints.SharedSettingFingerprint import app.revanced.util.exception +import app.revanced.util.getTargetIndex import app.revanced.util.getWideLiteralInstructionIndex +import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch(dependencies = [SharedResourceIdPatch::class]) @@ -21,25 +26,39 @@ object SettingsBytecodePatch : BytecodePatch( setOf( AcknowledgementsLabelBuilderFingerprint, OssLicensesMenuActivityOnCreateFingerprint, + SharedSettingFingerprint, SettingsStatusLoadFingerprint ) ) { private const val INTEGRATIONS_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/reddit/settingsmenu/ReVancedSettingActivity;->initializeSettings(Landroid/app/Activity;)V" + "$INTEGRATIONS_PATH/settings/ActivityHook;->initialize(Landroid/app/Activity;)V" private lateinit var settingsMethod: MutableMethod internal fun updateSettingsStatus(description: String) { - settingsMethod.apply { - addInstruction( - 0, - "invoke-static {}, Lapp/revanced/integrations/reddit/settingsmenu/SettingsStatus;->$description()V" - ) - } + settingsMethod.addInstruction( + 0, + "invoke-static {}, $INTEGRATIONS_PATH/settings/SettingsStatus;->$description()V" + ) } override fun execute(context: BytecodeContext) { + /** + * Set SharedPrefCategory + */ + SharedSettingFingerprint.result?.let { + it.mutableMethod.apply { + val stringIndex = getTargetIndex(Opcode.CONST_STRING) + val stringRegister = getInstruction(stringIndex).registerA + + replaceInstruction( + stringIndex, + "const-string v$stringRegister, \"reddit_revanced\"" + ) + } + } ?: throw SharedSettingFingerprint.exception + /** * Replace settings label */ diff --git a/src/main/kotlin/app/revanced/patches/reddit/utils/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/utils/settings/SettingsPatch.kt index 47baf720c..f83305ccf 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/utils/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/utils/settings/SettingsPatch.kt @@ -11,8 +11,7 @@ import kotlin.io.path.exists @Patch( name = "Settings", description = "Adds ReVanced Extended settings to Reddit.", - dependencies = - [ + dependencies = [ IntegrationsPatch::class, SettingsBytecodePatch::class ], @@ -27,6 +26,7 @@ import kotlin.io.path.exists ], requiresIntegrations = true, ) +@Suppress("DEPRECATION") object SettingsPatch : ResourcePatch() { override fun execute(context: ResourceContext) { diff --git a/src/main/kotlin/app/revanced/patches/reddit/utils/settings/fingerprints/SettingsStatusLoadFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/utils/settings/fingerprints/SettingsStatusLoadFingerprint.kt index cb569eb0c..e539fb1e2 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/utils/settings/fingerprints/SettingsStatusLoadFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/utils/settings/fingerprints/SettingsStatusLoadFingerprint.kt @@ -1,10 +1,11 @@ package app.revanced.patches.reddit.utils.settings.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.patches.reddit.utils.integrations.Constants.INTEGRATIONS_PATH object SettingsStatusLoadFingerprint : MethodFingerprint( customFingerprint = { methodDef, _ -> - methodDef.definingClass.endsWith("Lapp/revanced/integrations/reddit/settingsmenu/SettingsStatus;") && + methodDef.definingClass.endsWith("$INTEGRATIONS_PATH/settings/SettingsStatus;") && methodDef.name == "load" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/ads/AbstractAdsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/ads/AbstractAdsPatch.kt new file mode 100644 index 000000000..6b47286cc --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/ads/AbstractAdsPatch.kt @@ -0,0 +1,62 @@ +package app.revanced.patches.shared.ads + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.shared.ads.fingerprints.MusicAdsFingerprint +import app.revanced.patches.shared.ads.fingerprints.VideoAdsFingerprint +import app.revanced.util.exception +import app.revanced.util.getWalkerMethod +import app.revanced.util.indexOfFirstInstruction +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction +import com.android.tools.smali.dexlib2.iface.reference.MethodReference + +abstract class AbstractAdsPatch( + private val classDescriptor: String, + private val methodDescriptor: String +) : BytecodePatch( + setOf( + MusicAdsFingerprint, + VideoAdsFingerprint + ) +) { + override fun execute(context: BytecodeContext) { + MusicAdsFingerprint.result?.let { + it.mutableMethod.apply { + val targetIndex = indexOfFirstInstruction { + val reference = ((this as? ReferenceInstruction)?.reference as? MethodReference) + + opcode == Opcode.INVOKE_VIRTUAL + && reference?.returnType == "V" + && reference.parameterTypes.size == 1 + && reference.parameterTypes.first() == "Z" + } + + getWalkerMethod(context, targetIndex) + .addInstructions( + 0, """ + invoke-static {p1}, $classDescriptor->$methodDescriptor(Z)Z + move-result p1 + """ + ) + } + } ?: throw MusicAdsFingerprint.exception + + VideoAdsFingerprint.result?.let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $classDescriptor->$methodDescriptor()Z + move-result v0 + if-nez v0, :show_ads + return-void + """, ExternalLabel("show_ads", getInstruction(0)) + ) + } + } ?: throw VideoAdsFingerprint.exception + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ads/LegacyAdsFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/MusicAdsFingerprint.kt similarity index 54% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/ads/LegacyAdsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/MusicAdsFingerprint.kt index 316e0ae8d..94b92dcd7 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ads/LegacyAdsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/MusicAdsFingerprint.kt @@ -1,12 +1,11 @@ -package app.revanced.patches.shared.fingerprints.ads +package app.revanced.patches.shared.ads.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.util.fingerprint.LiteralValueFingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction -object LegacyAdsFingerprint : MethodFingerprint( +object MusicAdsFingerprint : LiteralValueFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = emptyList(), @@ -20,9 +19,5 @@ object LegacyAdsFingerprint : MethodFingerprint( Opcode.IPUT_WIDE, Opcode.CONST_4, ), - customFingerprint = { methodDef, _ -> - methodDef.implementation!!.instructions.any { - ((it as? NarrowLiteralInstruction)?.narrowLiteral == 4) - } - } + literalSupplier = { 4 } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ads/MainstreamAdsFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/VideoAdsFingerprint.kt similarity index 57% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/ads/MainstreamAdsFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/VideoAdsFingerprint.kt index c346bb8bd..65256d765 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/ads/MainstreamAdsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/VideoAdsFingerprint.kt @@ -1,8 +1,8 @@ -package app.revanced.patches.shared.fingerprints.ads +package app.revanced.patches.shared.ads.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint -object MainstreamAdsFingerprint : MethodFingerprint( +object VideoAdsFingerprint : MethodFingerprint( returnType = "V", strings = listOf("markFillRequested", "requestEnterSlot") ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/captions/AbstractAutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/captions/AbstractAutoCaptionsPatch.kt similarity index 67% rename from src/main/kotlin/app/revanced/patches/shared/patch/captions/AbstractAutoCaptionsPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/captions/AbstractAutoCaptionsPatch.kt index d415691f9..e7110ebac 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/captions/AbstractAutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/captions/AbstractAutoCaptionsPatch.kt @@ -1,14 +1,15 @@ -package app.revanced.patches.shared.patch.captions +package app.revanced.patches.shared.captions import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.fingerprints.captions.StartVideoInformerFingerprint -import app.revanced.patches.shared.fingerprints.captions.SubtitleTrackFingerprint +import app.revanced.patches.shared.captions.fingerprints.StartVideoInformerFingerprint +import app.revanced.patches.shared.captions.fingerprints.SubtitleTrackFingerprint import app.revanced.util.exception +import app.revanced.util.getWalkerMethod +import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction @@ -34,20 +35,17 @@ abstract class AbstractAutoCaptionsPatch( } ?: throw StartVideoInformerFingerprint.exception SubtitleTrackFingerprint.result?.let { - val targetMethod = context - .toMethodWalker(it.method) - .nextMethod(it.scanResult.patternScanResult!!.startIndex + 1, true) - .getMethod() as MutableMethod + val targetMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.startIndex + 1) targetMethod.apply { - val insertIndex = implementation!!.instructions.indexOfFirst { instruction -> - instruction.opcode == Opcode.INVOKE_VIRTUAL - && ((instruction as? ReferenceInstruction)?.reference as? MethodReference)?.returnType == "Z" - } + 2 - val insertRegister = getInstruction(insertIndex).registerA + val targetIndex = indexOfFirstInstruction { + opcode == Opcode.INVOKE_VIRTUAL + && ((this as? ReferenceInstruction)?.reference as? MethodReference)?.returnType == "Z" + } + 1 + val insertRegister = getInstruction(targetIndex).registerA addInstructions( - insertIndex, """ + targetIndex + 1, """ invoke-static {v$insertRegister}, $classDescriptor->disableAutoCaptions(Z)Z move-result v$insertRegister """ diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/captions/StartVideoInformerFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/captions/fingerprints/StartVideoInformerFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/captions/StartVideoInformerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/captions/fingerprints/StartVideoInformerFingerprint.kt index 23b3530f7..90730fcab 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/captions/StartVideoInformerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/captions/fingerprints/StartVideoInformerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.captions +package app.revanced.patches.shared.captions.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/captions/SubtitleTrackFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/captions/fingerprints/SubtitleTrackFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/captions/SubtitleTrackFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/captions/fingerprints/SubtitleTrackFingerprint.kt index e354f1c14..5763545ae 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/captions/SubtitleTrackFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/captions/fingerprints/SubtitleTrackFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.captions +package app.revanced.patches.shared.captions.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/clientspoof/AbstractClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/shared/clientspoof/AbstractClientSpoofPatch.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/shared/patch/clientspoof/AbstractClientSpoofPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/clientspoof/AbstractClientSpoofPatch.kt index c3ecef23c..046bf903a 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/clientspoof/AbstractClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/clientspoof/AbstractClientSpoofPatch.kt @@ -1,12 +1,12 @@ -package app.revanced.patches.shared.patch.clientspoof +package app.revanced.patches.shared.clientspoof import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.patch.transformation.BaseTransformInstructionsPatch -import app.revanced.patches.shared.patch.transformation.IMethodCall -import app.revanced.patches.shared.patch.transformation.Instruction35cInfo -import app.revanced.patches.shared.patch.transformation.filterMapInstruction35c +import app.revanced.patches.shared.transformation.BaseTransformInstructionsPatch +import app.revanced.patches.shared.transformation.IMethodCall +import app.revanced.patches.shared.transformation.Instruction35cInfo +import app.revanced.patches.shared.transformation.filterMapInstruction35c import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/customspeed/AbstractCustomPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/shared/customspeed/AbstractCustomPlaybackSpeedPatch.kt similarity index 52% rename from src/main/kotlin/app/revanced/patches/shared/patch/customspeed/AbstractCustomPlaybackSpeedPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/customspeed/AbstractCustomPlaybackSpeedPatch.kt index 3576ac76d..6fbc47b84 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/customspeed/AbstractCustomPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/customspeed/AbstractCustomPlaybackSpeedPatch.kt @@ -1,20 +1,19 @@ -package app.revanced.patches.shared.patch.customspeed +package app.revanced.patches.shared.customspeed import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patches.shared.fingerprints.customspeed.SpeedArrayGeneratorFingerprint -import app.revanced.patches.shared.fingerprints.customspeed.SpeedLimiterFallBackFingerprint -import app.revanced.patches.shared.fingerprints.customspeed.SpeedLimiterFingerprint +import app.revanced.patches.shared.customspeed.fingerprints.SpeedArrayGeneratorFingerprint +import app.revanced.patches.shared.customspeed.fingerprints.SpeedLimiterFallBackFingerprint +import app.revanced.patches.shared.customspeed.fingerprints.SpeedLimiterFingerprint import app.revanced.util.exception -import com.android.tools.smali.dexlib2.Opcode +import app.revanced.util.getTargetIndexWithFieldReferenceType +import app.revanced.util.getTargetIndexWithMethodReferenceName +import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -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 abstract class AbstractCustomPlaybackSpeedPatch( private val descriptor: String, @@ -38,44 +37,25 @@ abstract class AbstractCustomPlaybackSpeedPatch( """ ) - val targetInstruction = implementation!!.instructions + val sizeIndex = getTargetIndexWithMethodReferenceName("size") + 1 + val sizeRegister = getInstruction(sizeIndex).registerA - for ((index, instruction) in targetInstruction.withIndex()) { - if (instruction.opcode != Opcode.INVOKE_INTERFACE) continue - - val sizeInstruction = getInstruction(index) - if ((sizeInstruction.reference as MethodReference).name != "size") continue - - val register = getInstruction(index + 1).registerA - - addInstructions( - index + 2, """ - invoke-static {v$register}, $descriptor->getSize(I)I - move-result v$register + addInstructions( + sizeIndex + 1, """ + invoke-static {v$sizeRegister}, $descriptor->getSize(I)I + move-result v$sizeRegister """ - ) - break - } + ) + val arrayIndex = getTargetIndexWithFieldReferenceType("[F") + val arrayRegister = getInstruction(arrayIndex).registerA - for ((index, instruction) in targetInstruction.withIndex()) { - if (instruction.opcode != Opcode.SGET_OBJECT) continue - - val targetReference = - getInstruction(index).reference.toString() - - if (targetReference.endsWith(":[F")) { - val register = getInstruction(index).registerA - - addInstructions( - index + 1, """ - invoke-static {v$register}, $descriptor->getArray([F)[F - move-result-object v$register - """ - ) - break - } - } + addInstructions( + arrayIndex + 1, """ + invoke-static {v$arrayRegister}, $descriptor->getArray([F)[F + move-result-object v$arrayRegister + """ + ) } } ?: throw SpeedArrayGeneratorFingerprint.exception @@ -88,12 +68,12 @@ abstract class AbstractCustomPlaybackSpeedPatch( arrayOf( speedLimiterParentResult, speedLimiterResult - ).forEach { result -> - result.mutableMethod.apply { + ).forEach { + it.mutableMethod.apply { val limiterMinConstIndex = - implementation!!.instructions.indexOfFirst { (it as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() } + indexOfFirstInstruction { (this as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() } val limiterMaxConstIndex = - implementation!!.instructions.indexOfFirst { (it as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() } + indexOfFirstInstruction { (this as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() } val limiterMinConstDestination = getInstruction(limiterMinConstIndex).registerA diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/customspeed/SpeedArrayGeneratorFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/customspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/customspeed/SpeedArrayGeneratorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/customspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt index 4899e7f34..64125aeb6 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/customspeed/SpeedArrayGeneratorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/customspeed/fingerprints/SpeedArrayGeneratorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.customspeed +package app.revanced.patches.shared.customspeed.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/customspeed/SpeedLimiterFallBackFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/customspeed/fingerprints/SpeedLimiterFallBackFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/customspeed/SpeedLimiterFallBackFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/customspeed/fingerprints/SpeedLimiterFallBackFingerprint.kt index 26d8ecf72..79d76d45b 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/customspeed/SpeedLimiterFallBackFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/customspeed/fingerprints/SpeedLimiterFallBackFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.customspeed +package app.revanced.patches.shared.customspeed.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/customspeed/SpeedLimiterFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/customspeed/fingerprints/SpeedLimiterFingerprint.kt similarity index 88% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/customspeed/SpeedLimiterFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/customspeed/fingerprints/SpeedLimiterFingerprint.kt index 87b1f3bb3..efd40f8bd 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/customspeed/SpeedLimiterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/customspeed/fingerprints/SpeedLimiterFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.customspeed +package app.revanced.patches.shared.customspeed.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/dialog/AbstractRemoveViewerDiscretionDialogPatch.kt b/src/main/kotlin/app/revanced/patches/shared/dialog/AbstractRemoveViewerDiscretionDialogPatch.kt similarity index 70% rename from src/main/kotlin/app/revanced/patches/shared/patch/dialog/AbstractRemoveViewerDiscretionDialogPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/dialog/AbstractRemoveViewerDiscretionDialogPatch.kt index d4ea83dd7..a0b1c66d2 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/dialog/AbstractRemoveViewerDiscretionDialogPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/dialog/AbstractRemoveViewerDiscretionDialogPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.dialog +package app.revanced.patches.shared.dialog import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction @@ -6,11 +6,11 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.fingerprints.dialog.CreateDialogFingerprint +import app.revanced.patches.shared.dialog.fingerprints.CreateDialogFingerprint import app.revanced.util.exception +import app.revanced.util.getTargetIndexWithMethodReferenceName +import app.revanced.util.getWalkerMethod import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference abstract class AbstractRemoveViewerDiscretionDialogPatch( private val classDescriptor: String, @@ -22,9 +22,7 @@ abstract class AbstractRemoveViewerDiscretionDialogPatch( } ) { private fun MutableMethod.invoke(isAgeVerified: Boolean) { - val showDialogIndex = implementation!!.instructions.indexOfFirst { instruction -> - ((instruction as? ReferenceInstruction)?.reference as? MethodReference)?.name == "show" - } + val showDialogIndex = getTargetIndexWithMethodReferenceName("show") val dialogRegister = getInstruction(showDialogIndex).registerC val methodName = @@ -46,11 +44,8 @@ abstract class AbstractRemoveViewerDiscretionDialogPatch( if (additionalFingerprints.isNotEmpty()) { additionalFingerprints.forEach { fingerprint -> fingerprint.result?.let { - val targetMethod = context.toMethodWalker(it.method) - .nextMethod(it.scanResult.patternScanResult!!.endIndex - 1, true) - .getMethod() as MutableMethod - - targetMethod.invoke(true) + it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex - 1) + .invoke(true) } ?: throw fingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/dialog/CreateDialogFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/dialog/fingerprints/CreateDialogFingerprint.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/dialog/CreateDialogFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/dialog/fingerprints/CreateDialogFingerprint.kt index a7b0f0bd9..0cc543eb7 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/dialog/CreateDialogFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/dialog/fingerprints/CreateDialogFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.dialog +package app.revanced.patches.shared.dialog.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags diff --git a/src/main/kotlin/app/revanced/patches/shared/drawable/DrawableColorPatch.kt b/src/main/kotlin/app/revanced/patches/shared/drawable/DrawableColorPatch.kt new file mode 100644 index 000000000..4be705cf7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/drawable/DrawableColorPatch.kt @@ -0,0 +1,44 @@ +package app.revanced.patches.shared.drawable + +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.util.proxy.mutableTypes.MutableMethod +import app.revanced.patches.shared.drawable.fingerprints.DrawableFingerprint +import app.revanced.util.exception +import app.revanced.util.getTargetIndexWithMethodReferenceNameReversed +import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction + +object DrawableColorPatch : BytecodePatch( + setOf(DrawableFingerprint) +) { + override fun execute(context: BytecodeContext) { + + DrawableFingerprint.result?.mutableMethod?.apply { + insertMethod = this + insertIndex = getTargetIndexWithMethodReferenceNameReversed("setColor") + insertRegister = getInstruction(insertIndex).registerD + } ?: throw DrawableFingerprint.exception + } + + private var offset = 0 + + private var insertIndex: Int = 0 + private var insertRegister: Int = 0 + private lateinit var insertMethod: MutableMethod + + + fun injectCall( + methodDescriptor: String + ) { + insertMethod.addInstructions( + insertIndex + offset, """ + invoke-static {v$insertRegister}, $methodDescriptor + move-result v$insertRegister + """ + ) + offset += 2 + } +} + diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/LithoThemeFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/drawable/fingerprints/DrawableFingerprint.kt similarity index 62% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/LithoThemeFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/drawable/fingerprints/DrawableFingerprint.kt index 79f4b781e..2d2dc3205 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/LithoThemeFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/drawable/fingerprints/DrawableFingerprint.kt @@ -1,11 +1,11 @@ -package app.revanced.patches.shared.fingerprints.litho +package app.revanced.patches.shared.drawable.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -object LithoThemeFingerprint : MethodFingerprint( +object DrawableFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL, parameters = listOf("L"), @@ -15,5 +15,8 @@ object LithoThemeFingerprint : MethodFingerprint( Opcode.INVOKE_VIRTUAL, // Paint.setColor: inject point Opcode.RETURN_VOID ), - customFingerprint = { methodDef, _ -> methodDef.name == "onBoundsChange" } + customFingerprint = { methodDef, classDef -> + methodDef.name == "onBoundsChange" + && classDef.superclass == "Landroid/graphics/drawable/Drawable;" + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/elements/AbstractRemoveStringsElementsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/elements/AbstractRemoveStringsElementsPatch.kt similarity index 93% rename from src/main/kotlin/app/revanced/patches/shared/patch/elements/AbstractRemoveStringsElementsPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/elements/AbstractRemoveStringsElementsPatch.kt index a31d7f303..73a2b7f17 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/elements/AbstractRemoveStringsElementsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/elements/AbstractRemoveStringsElementsPatch.kt @@ -1,9 +1,10 @@ -package app.revanced.patches.shared.patch.elements +package app.revanced.patches.shared.elements import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import kotlin.io.path.exists +@Suppress("DEPRECATION") abstract class AbstractRemoveStringsElementsPatch( private val paths: Array, private val replacements: Array diff --git a/src/main/kotlin/app/revanced/patches/shared/integrations/BaseIntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/integrations/BaseIntegrationsPatch.kt new file mode 100644 index 000000000..27c2c9be0 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/integrations/BaseIntegrationsPatch.kt @@ -0,0 +1,106 @@ +package app.revanced.patches.shared.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.BaseIntegrationsPatch.IntegrationsFingerprint.IRegisterResolver +import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_UTILS_CLASS_DESCRIPTOR +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 BaseIntegrationsPatch( + private val hooks: Set, +) : BytecodePatch(hooks) { + + @Deprecated( + "Use the constructor without the integrationsDescriptor parameter", + ReplaceWith("BaseIntegrationsPatch(hooks)"), + ) + @Suppress("UNUSED_PARAMETER") + constructor( + integrationsDescriptor: String, + hooks: Set, + ) : this(hooks) + + override fun execute(context: BytecodeContext) { + if (context.findClass(INTEGRATIONS_UTILS_CLASS_DESCRIPTOR) == null) { + throw PatchException( + "Integrations have not been merged yet. This patch can not succeed without merging the integrations.", + ) + } + + hooks.forEach { hook -> + hook.invoke(INTEGRATIONS_UTILS_CLASS_DESCRIPTOR) + } + } + + /** + * [MethodFingerprint] for integrations. + * + * @param contextRegisterResolver A [IRegisterResolver] to get the register. + * @see MethodFingerprint + */ + abstract class IntegrationsFingerprint( + returnType: String? = null, + accessFlags: Int? = null, + parameters: Iterable? = null, + opcodes: Iterable? = null, + strings: Iterable? = null, + customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null, + private val insertIndexResolver: ((Method) -> Int) = object : IHookInsertIndexResolver {}, + private val contextRegisterResolver: (Method) -> Int = object : IRegisterResolver {} + ) : MethodFingerprint( + returnType, + accessFlags, + parameters, + opcodes, + strings, + customFingerprint, + ) { + @Deprecated("Previous constructor that is missing the insert index." + + "Here only for binary compatibility, " + + "and this can be removed after the next major version update.") + constructor( + returnType: String? = null, + accessFlags: Int? = null, + parameters: Iterable? = null, + opcodes: Iterable? = null, + strings: Iterable? = null, + customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null, + contextRegisterResolver: (Method) -> Int = object : IRegisterResolver {} + ) : this( + returnType, + accessFlags, + parameters, + opcodes, + strings, + customFingerprint, + object : IHookInsertIndexResolver {}, + contextRegisterResolver + ) + + fun invoke(integrationsDescriptor: String) { + result?.mutableMethod?.let { method -> + val insertIndex = insertIndexResolver(method) + val contextRegister = contextRegisterResolver(method) + + method.addInstruction( + insertIndex, + "invoke-static/range { v$contextRegister .. v$contextRegister }, " + + "$integrationsDescriptor->setContext(Landroid/content/Context;)V", + ) + } ?: throw PatchException("Could not find hook target fingerprint.") + } + + interface IHookInsertIndexResolver : (Method) -> Int { + override operator fun invoke(method: Method) = 0 + } + + interface IRegisterResolver : (Method) -> Int { + override operator fun invoke(method: Method) = method.implementation!!.registerCount - 1 + } + } +} diff --git a/src/main/kotlin/app/revanced/patches/shared/integrations/Constants.kt b/src/main/kotlin/app/revanced/patches/shared/integrations/Constants.kt new file mode 100644 index 000000000..8c2bc18e7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/integrations/Constants.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.shared.integrations + +@Suppress("MemberVisibilityCanBePrivate") +object Constants { + const val INTEGRATIONS_PATH = "Lapp/revanced/integrations/shared" + const val COMPONENTS_PATH = "$INTEGRATIONS_PATH/patches/components" + + const val INTEGRATIONS_SETTING_CLASS_DESCRIPTOR = "$INTEGRATIONS_PATH/settings/Setting;" + const val INTEGRATIONS_UTILS_CLASS_DESCRIPTOR = "$INTEGRATIONS_PATH/utils/Utils;" +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/litho/LithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/shared/litho/LithoFilterPatch.kt new file mode 100644 index 000000000..a592330f8 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/litho/LithoFilterPatch.kt @@ -0,0 +1,119 @@ +package app.revanced.patches.shared.litho + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.shared.integrations.Constants.COMPONENTS_PATH +import app.revanced.patches.shared.litho.fingerprints.LithoFilterPatchConstructorFingerprint +import app.revanced.patches.shared.litho.fingerprints.PathBuilderFingerprint +import app.revanced.patches.shared.litho.fingerprints.SetByteBufferFingerprint +import app.revanced.util.exception +import app.revanced.util.getEmptyStringInstructionIndex +import app.revanced.util.getTargetIndex +import app.revanced.util.getTargetIndexReversed +import app.revanced.util.getTargetIndexWithFieldReferenceType +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c +import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction +import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction +import java.io.Closeable + +@Suppress("unused") +object LithoFilterPatch : BytecodePatch( + setOf( + LithoFilterPatchConstructorFingerprint, + PathBuilderFingerprint, + SetByteBufferFingerprint + ) +), Closeable { + private const val INTEGRATIONS_LITHO_FILER_CLASS_DESCRIPTOR = + "$COMPONENTS_PATH/LithoFilterPatch;" + + private const val INTEGRATIONS_FILER_CLASS_DESCRIPTOR = + "$COMPONENTS_PATH/Filter;" + + internal lateinit var addFilter: (String) -> Unit + private set + + private var filterCount = 0 + + override fun execute(context: BytecodeContext) { + + SetByteBufferFingerprint.result?.let { + it.mutableMethod.apply { + val insertIndex = getTargetIndex(Opcode.IF_EQZ) + 1 + + addInstruction( + insertIndex, + "invoke-static { p2 }, $INTEGRATIONS_LITHO_FILER_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V" + ) + } + } ?: throw SetByteBufferFingerprint.exception + + PathBuilderFingerprint.result?.let { + it.mutableMethod.apply { + val emptyComponentMethodIndex = it.scanResult.patternScanResult!!.startIndex + 1 + val emptyComponentMethodReference = + getInstruction(emptyComponentMethodIndex).reference + val emptyComponentFieldReference = + getInstruction(emptyComponentMethodIndex + 2).reference + + val stringBuilderIndex = getTargetIndexWithFieldReferenceType("Ljava/lang/StringBuilder;") + val stringBuilderRegister = getInstruction(stringBuilderIndex).registerA + + val emptyStringIndex = getEmptyStringInstructionIndex() + + val identifierIndex = getTargetIndexReversed(emptyStringIndex, Opcode.IPUT_OBJECT) + val identifierRegister = getInstruction(identifierIndex).registerA + + val objectIndex = getTargetIndex(emptyStringIndex, Opcode.INVOKE_VIRTUAL) + val objectRegister = getInstruction(objectIndex).registerC + + val insertIndex = stringBuilderIndex + 1 + + addInstructionsWithLabels( + insertIndex, """ + invoke-static {v$stringBuilderRegister, v$identifierRegister, v$objectRegister}, $INTEGRATIONS_LITHO_FILER_CLASS_DESCRIPTOR->filter(Ljava/lang/StringBuilder;Ljava/lang/String;Ljava/lang/Object;)Z + move-result v$stringBuilderRegister + if-eqz v$stringBuilderRegister, :filter + move-object/from16 v0, p1 + invoke-static {v0}, $emptyComponentMethodReference + move-result-object v0 + iget-object v0, v0, $emptyComponentFieldReference + return-object v0 + """, ExternalLabel("filter", getInstruction(insertIndex)) + ) + } + } ?: throw PathBuilderFingerprint.exception + + LithoFilterPatchConstructorFingerprint.result?.let { + it.mutableMethod.apply { + removeInstructions(0, 6) + + addFilter = { classDescriptor -> + addInstructions( + 0, """ + new-instance v1, $classDescriptor + invoke-direct {v1}, $classDescriptor->()V + const/16 v2, ${filterCount++} + aput-object v1, v0, v2 + """ + ) + } + } + } ?: throw LithoFilterPatchConstructorFingerprint.exception + } + + override fun close() = LithoFilterPatchConstructorFingerprint.result!! + .mutableMethod.addInstructions( + 0, """ + const/16 v0, $filterCount + new-array v0, v0, [$INTEGRATIONS_FILER_CLASS_DESCRIPTOR + """ + ) +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/utils/litho/fingerprints/LithoFilterFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/LithoFilterPatchConstructorFingerprint.kt similarity index 66% rename from src/main/kotlin/app/revanced/patches/music/utils/litho/fingerprints/LithoFilterFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/LithoFilterPatchConstructorFingerprint.kt index d4358bad6..1bb8a72b4 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/litho/fingerprints/LithoFilterFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/LithoFilterPatchConstructorFingerprint.kt @@ -1,11 +1,11 @@ -package app.revanced.patches.music.utils.litho.fingerprints +package app.revanced.patches.shared.litho.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint -import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH +import app.revanced.patches.shared.integrations.Constants.COMPONENTS_PATH import com.android.tools.smali.dexlib2.AccessFlags -object LithoFilterFingerprint : MethodFingerprint( +object LithoFilterPatchConstructorFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.CONSTRUCTOR, customFingerprint = { methodDef, _ -> diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/EmptyComponentBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/PathBuilderFingerprint.kt similarity index 80% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/EmptyComponentBuilderFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/PathBuilderFingerprint.kt index 272ad16e4..ac73b9fab 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/EmptyComponentBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/PathBuilderFingerprint.kt @@ -1,11 +1,11 @@ -package app.revanced.patches.shared.fingerprints.litho +package app.revanced.patches.shared.litho.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -object EmptyComponentBuilderFingerprint : MethodFingerprint( +object PathBuilderFingerprint : MethodFingerprint( returnType = "L", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, opcodes = listOf( diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/GeneralByteBufferFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/SetByteBufferFingerprint.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/GeneralByteBufferFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/SetByteBufferFingerprint.kt index 6471bf128..5a544bc9c 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/litho/GeneralByteBufferFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/SetByteBufferFingerprint.kt @@ -1,11 +1,11 @@ -package app.revanced.patches.shared.fingerprints.litho +package app.revanced.patches.shared.litho.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode -object GeneralByteBufferFingerprint : MethodFingerprint( +object SetByteBufferFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("I", "Ljava/nio/ByteBuffer;"), @@ -26,5 +26,10 @@ object GeneralByteBufferFingerprint : MethodFingerprint( Opcode.IPUT, Opcode.IPUT, Opcode.GOTO - ) + ), + // Check method count and field count to support both YouTube and YouTube Music + customFingerprint = { _, classDef -> + classDef.methods.count() > 6 + && classDef.fields.count() > 4 + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/mapping/ResourceMappingPatch.kt b/src/main/kotlin/app/revanced/patches/shared/mapping/ResourceMappingPatch.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/shared/patch/mapping/ResourceMappingPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/mapping/ResourceMappingPatch.kt index 1722361f0..4bfa2a3fe 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/mapping/ResourceMappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/mapping/ResourceMappingPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.mapping +package app.revanced.patches.shared.mapping import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch @@ -7,6 +7,7 @@ import java.util.Collections import java.util.concurrent.Executors import java.util.concurrent.TimeUnit +@Suppress("DEPRECATION") object ResourceMappingPatch : ResourcePatch() { internal lateinit var resourceMappings: List private set @@ -58,4 +59,8 @@ object ResourceMappingPatch : ResourcePatch() { } data class ResourceElement(val type: String, val name: String, val id: Long) + + fun getId(resourceType: ResourceType, resourceName: String) = resourceMappings + .find { it.type == resourceType.value && it.name == resourceName }?.id + ?: -1 } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/mapping/ResourceType.kt b/src/main/kotlin/app/revanced/patches/shared/mapping/ResourceType.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/shared/patch/mapping/ResourceType.kt rename to src/main/kotlin/app/revanced/patches/shared/mapping/ResourceType.kt index 6742e83d0..e1cd02943 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/mapping/ResourceType.kt +++ b/src/main/kotlin/app/revanced/patches/shared/mapping/ResourceType.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.mapping +package app.revanced.patches.shared.mapping enum class ResourceType(val value: String) { ATTR("attr"), diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/microg/Constants.kt b/src/main/kotlin/app/revanced/patches/shared/microg/Constants.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/shared/patch/microg/Constants.kt rename to src/main/kotlin/app/revanced/patches/shared/microg/Constants.kt index 8a54ab4d9..6900e795a 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/microg/Constants.kt +++ b/src/main/kotlin/app/revanced/patches/shared/microg/Constants.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.microg +package app.revanced.patches.shared.microg /** * constants for microG builds with signature spoofing diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/microg/MicroGBytecodeHelper.kt b/src/main/kotlin/app/revanced/patches/shared/microg/MicroGBytecodeHelper.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/shared/patch/microg/MicroGBytecodeHelper.kt rename to src/main/kotlin/app/revanced/patches/shared/microg/MicroGBytecodeHelper.kt index 933a6a38f..8700e9089 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/microg/MicroGBytecodeHelper.kt +++ b/src/main/kotlin/app/revanced/patches/shared/microg/MicroGBytecodeHelper.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.microg +package app.revanced.patches.shared.microg import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -6,10 +6,10 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.patch.microg.Constants.ACTIONS -import app.revanced.patches.shared.patch.microg.Constants.AUTHORITIES -import app.revanced.patches.shared.patch.microg.Constants.MICROG_VENDOR -import app.revanced.patches.shared.patch.microg.Constants.PERMISSIONS +import app.revanced.patches.shared.microg.Constants.ACTIONS +import app.revanced.patches.shared.microg.Constants.AUTHORITIES +import app.revanced.patches.shared.microg.Constants.MICROG_VENDOR +import app.revanced.patches.shared.microg.Constants.PERMISSIONS import app.revanced.util.exception import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/microg/MicroGManifestHelper.kt b/src/main/kotlin/app/revanced/patches/shared/microg/MicroGManifestHelper.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/shared/patch/microg/MicroGManifestHelper.kt rename to src/main/kotlin/app/revanced/patches/shared/microg/MicroGManifestHelper.kt index 2ef387a06..513253507 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/microg/MicroGManifestHelper.kt +++ b/src/main/kotlin/app/revanced/patches/shared/microg/MicroGManifestHelper.kt @@ -1,16 +1,17 @@ -package app.revanced.patches.shared.patch.microg +package app.revanced.patches.shared.microg import app.revanced.patcher.data.ResourceContext -import app.revanced.patches.shared.patch.microg.Constants.META_GMS_PACKAGE_NAME -import app.revanced.patches.shared.patch.microg.Constants.META_SPOOFED_PACKAGE_NAME -import app.revanced.patches.shared.patch.microg.Constants.META_SPOOFED_PACKAGE_SIGNATURE -import app.revanced.patches.shared.patch.microg.Constants.MICROG_VENDOR +import app.revanced.patches.shared.microg.Constants.META_GMS_PACKAGE_NAME +import app.revanced.patches.shared.microg.Constants.META_SPOOFED_PACKAGE_NAME +import app.revanced.patches.shared.microg.Constants.META_SPOOFED_PACKAGE_SIGNATURE +import app.revanced.patches.shared.microg.Constants.MICROG_VENDOR import org.w3c.dom.Element import org.w3c.dom.Node /** * helper class for adding manifest metadata needed for microG builds with signature spoofing */ +@Suppress("DEPRECATION") object MicroGManifestHelper { /** diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/microg/MicroGResourceHelper.kt b/src/main/kotlin/app/revanced/patches/shared/microg/MicroGResourceHelper.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/shared/patch/microg/MicroGResourceHelper.kt rename to src/main/kotlin/app/revanced/patches/shared/microg/MicroGResourceHelper.kt index c149e53b1..f6213742b 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/microg/MicroGResourceHelper.kt +++ b/src/main/kotlin/app/revanced/patches/shared/microg/MicroGResourceHelper.kt @@ -1,10 +1,11 @@ -package app.revanced.patches.shared.patch.microg +package app.revanced.patches.shared.microg import app.revanced.patcher.data.ResourceContext /** * Helper class for applying resource patches needed for the microg-support patches. */ +@Suppress("DEPRECATION") object MicroGResourceHelper { /** * Patch the manifest to work with MicroG. diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/opus/AbstractOpusCodecsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/opus/AbstractOpusCodecsPatch.kt similarity index 91% rename from src/main/kotlin/app/revanced/patches/shared/patch/opus/AbstractOpusCodecsPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/opus/AbstractOpusCodecsPatch.kt index f89ae4e51..94f3a9088 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/opus/AbstractOpusCodecsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/opus/AbstractOpusCodecsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.opus +package app.revanced.patches.shared.opus import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels @@ -6,8 +6,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.fingerprints.opus.CodecReferenceFingerprint -import app.revanced.patches.shared.fingerprints.opus.CodecSelectorFingerprint +import app.revanced.patches.shared.opus.fingerprints.CodecReferenceFingerprint +import app.revanced.patches.shared.opus.fingerprints.CodecSelectorFingerprint import app.revanced.util.exception import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @@ -62,5 +62,5 @@ abstract class AbstractOpusCodecsPatch( } - lateinit var targetReference: Reference + private lateinit var targetReference: Reference } diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecReferenceFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/opus/fingerprints/CodecReferenceFingerprint.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecReferenceFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/opus/fingerprints/CodecReferenceFingerprint.kt index e7d098b80..e687ff5a0 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecReferenceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/opus/fingerprints/CodecReferenceFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.opus +package app.revanced.patches.shared.opus.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecSelectorFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/opus/fingerprints/CodecSelectorFingerprint.kt similarity index 90% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecSelectorFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/opus/fingerprints/CodecSelectorFingerprint.kt index d3774139f..62ded6635 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/opus/CodecSelectorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/opus/fingerprints/CodecSelectorFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.opus +package app.revanced.patches.shared.opus.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/overlaybackground/AbstractOverlayBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/shared/overlaybackground/AbstractOverlayBackgroundPatch.kt similarity index 94% rename from src/main/kotlin/app/revanced/patches/shared/patch/overlaybackground/AbstractOverlayBackgroundPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/overlaybackground/AbstractOverlayBackgroundPatch.kt index 94a88f589..0f2e64619 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/overlaybackground/AbstractOverlayBackgroundPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/overlaybackground/AbstractOverlayBackgroundPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.overlaybackground +package app.revanced.patches.shared.overlaybackground import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch @@ -6,6 +6,7 @@ import app.revanced.util.doRecursively import org.w3c.dom.Element import kotlin.io.path.exists +@Suppress("DEPRECATION") abstract class AbstractOverlayBackgroundPatch( private val files: Array, private val targetId: Array, diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/packagename/PackageNamePatch.kt b/src/main/kotlin/app/revanced/patches/shared/packagename/PackageNamePatch.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/shared/patch/packagename/PackageNamePatch.kt rename to src/main/kotlin/app/revanced/patches/shared/packagename/PackageNamePatch.kt index be9e8e30d..0094e212b 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/packagename/PackageNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/packagename/PackageNamePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.packagename +package app.revanced.patches.shared.packagename import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/ads/AbstractAdsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/ads/AbstractAdsPatch.kt deleted file mode 100644 index 06b6a2523..000000000 --- a/src/main/kotlin/app/revanced/patches/shared/patch/ads/AbstractAdsPatch.kt +++ /dev/null @@ -1,50 +0,0 @@ -package app.revanced.patches.shared.patch.ads - -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.fingerprints.ads.LegacyAdsFingerprint -import app.revanced.patches.shared.fingerprints.ads.MainstreamAdsFingerprint -import app.revanced.util.exception - -abstract class AbstractAdsPatch( - private val descriptor: String -) : BytecodePatch( - setOf( - LegacyAdsFingerprint, - MainstreamAdsFingerprint - ) -) { - override fun execute(context: BytecodeContext) { - LegacyAdsFingerprint.result?.let { - (context.toMethodWalker(it.method) - .nextMethod(13, true) - .getMethod() as MutableMethod).apply { - addInstructions( - 0, """ - invoke-static {}, $descriptor - move-result v1 - """ - ) - } - } ?: throw LegacyAdsFingerprint.exception - - MainstreamAdsFingerprint.result?.let { - it.mutableMethod.apply { - addInstructionsWithLabels( - 0, """ - invoke-static {}, $descriptor - move-result v0 - if-nez v0, :show_ads - return-void - """, ExternalLabel("show_ads", getInstruction(0)) - ) - } - } - - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/integrations/AbstractIntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/integrations/AbstractIntegrationsPatch.kt deleted file mode 100644 index f1384227f..000000000 --- a/src/main/kotlin/app/revanced/patches/shared/patch/integrations/AbstractIntegrationsPatch.kt +++ /dev/null @@ -1,64 +0,0 @@ -package app.revanced.patches.shared.patch.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.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint.RegisterResolver -import app.revanced.util.exception -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( - private val integrationsDescriptor: String, - private val hooks: Set -) : BytecodePatch(hooks) { - /** - * [MethodFingerprint] for integrations. - * - * @param contextRegisterResolver A [RegisterResolver] to get the register. - * @see MethodFingerprint - */ - abstract class IntegrationsFingerprint( - returnType: String? = null, - accessFlags: Int? = null, - parameters: Iterable? = null, - opcodes: Iterable? = null, - strings: Iterable? = null, - customFingerprint: ((methodDef: Method, classDef: ClassDef) -> Boolean)? = null, - private val contextRegisterResolver: (Method) -> Int = object : RegisterResolver {} - ) : MethodFingerprint( - returnType, - accessFlags, - parameters, - opcodes, - strings, - customFingerprint - ) { - fun invoke(integrationsDescriptor: String) { - result?.mutableMethod?.let { method -> - val contextRegister = contextRegisterResolver(method) - - method.addInstruction( - 0, - "sput-object v$contextRegister, " + - "$integrationsDescriptor->context:Landroid/content/Context;" - ) - } ?: throw exception - } - - interface RegisterResolver : (Method) -> Int { - override operator fun invoke(method: Method) = method.implementation!!.registerCount - 1 - } - } - - override fun execute(context: BytecodeContext) { - if (context.findClass(integrationsDescriptor) == null) throw PatchException( - "Integrations have not been merged yet. This patch can not succeed without merging the integrations." - ) - - for (hook in hooks) hook.invoke(integrationsDescriptor) - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt deleted file mode 100644 index 75da0e027..000000000 --- a/src/main/kotlin/app/revanced/patches/shared/patch/litho/ComponentParserPatch.kt +++ /dev/null @@ -1,106 +0,0 @@ -package app.revanced.patches.shared.patch.litho - -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.shared.fingerprints.litho.EmptyComponentBuilderFingerprint -import app.revanced.patches.shared.fingerprints.litho.GeneralByteBufferFingerprint -import app.revanced.util.exception -import app.revanced.util.getEmptyStringInstructionIndex -import app.revanced.util.getReference -import app.revanced.util.getTargetIndex -import app.revanced.util.getTargetIndexReversed -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c -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 -import kotlin.properties.Delegates - -object ComponentParserPatch : BytecodePatch( - setOf( - EmptyComponentBuilderFingerprint, - GeneralByteBufferFingerprint - ) -) { - private lateinit var emptyComponentLabel: String - private lateinit var byteBufferMethod: MutableMethod - internal lateinit var pathBuilderMethod: MutableMethod - - private var emptyComponentIndex by Delegates.notNull() - private var insertIndex by Delegates.notNull() - - private var identifierRegister by Delegates.notNull() - private var objectRegister by Delegates.notNull() - private var stringBuilderRegister by Delegates.notNull() - - internal fun injectCall(descriptor: String) { - byteBufferMethod.apply { - val insertIndex = getTargetIndex(0, Opcode.IF_EQZ) + 1 - - addInstruction( - insertIndex, - "invoke-static { p2 }, $descriptor->setProtoBuffer(Ljava/nio/ByteBuffer;)V" - ) - } - - pathBuilderMethod.apply { - addInstructionsWithLabels( - insertIndex, """ - invoke-static {v$stringBuilderRegister, v$identifierRegister, v$objectRegister}, $descriptor->filter(Ljava/lang/StringBuilder;Ljava/lang/String;Ljava/lang/Object;)Z - move-result v$stringBuilderRegister - if-eqz v$stringBuilderRegister, :filter - """ + emptyComponentLabel, - ExternalLabel("filter", getInstruction(insertIndex)) - ) - } - } - - override fun execute(context: BytecodeContext) { - - byteBufferMethod = GeneralByteBufferFingerprint.result?.mutableMethod - ?: throw GeneralByteBufferFingerprint.exception - - EmptyComponentBuilderFingerprint.result?.let { - it.mutableMethod.apply { - pathBuilderMethod = this - emptyComponentIndex = it.scanResult.patternScanResult!!.startIndex + 1 - - val builderMethodDescriptor = - getInstruction(emptyComponentIndex).reference - val emptyComponentFieldDescriptor = - getInstruction(emptyComponentIndex + 2).reference - - emptyComponentLabel = """ - move-object/from16 v0, p1 - invoke-static {v0}, $builderMethodDescriptor - move-result-object v0 - iget-object v0, v0, $emptyComponentFieldDescriptor - return-object v0 - """ - - val stringBuilderIndex = - implementation!!.instructions.indexOfFirst { instruction -> - instruction.getReference()?.type == "Ljava/lang/StringBuilder;" - } - - stringBuilderRegister = - getInstruction(stringBuilderIndex).registerA - - insertIndex = stringBuilderIndex + 1 - - val emptyStringIndex = getEmptyStringInstructionIndex() - val identifierIndex = getTargetIndexReversed(emptyStringIndex, Opcode.IPUT_OBJECT) - identifierRegister = - getInstruction(identifierIndex).registerA - - val objectIndex = getTargetIndex(emptyStringIndex, Opcode.INVOKE_VIRTUAL) - objectRegister = getInstruction(objectIndex).registerC - } - } ?: throw EmptyComponentBuilderFingerprint.exception - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/litho/LithoThemePatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/litho/LithoThemePatch.kt deleted file mode 100644 index 066e6090e..000000000 --- a/src/main/kotlin/app/revanced/patches/shared/patch/litho/LithoThemePatch.kt +++ /dev/null @@ -1,52 +0,0 @@ -package app.revanced.patches.shared.patch.litho - -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.fingerprints.litho.LithoThemeFingerprint -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 - -object LithoThemePatch : BytecodePatch( - setOf(LithoThemeFingerprint) -) { - override fun execute(context: BytecodeContext) { - - LithoThemeFingerprint.result?.mutableMethod?.let { - with(it.implementation!!.instructions) { - for (index in size - 1 downTo 0) { - val invokeInstruction = this[index] as? ReferenceInstruction ?: continue - if ((invokeInstruction.reference as MethodReference).name != "setColor") continue - insertIndex = index - insertRegister = (this[index] as Instruction35c).registerD - insertMethod = it - break - } - } - } ?: throw LithoThemeFingerprint.exception - - } - - private var offset = 0 - - private var insertIndex: Int = 0 - private var insertRegister: Int = 0 - private lateinit var insertMethod: MutableMethod - - - fun injectCall( - methodDescriptor: String - ) { - insertMethod.addInstructions( - insertIndex + offset, """ - invoke-static {v$insertRegister}, $methodDescriptor - move-result v$insertRegister - """ - ) - offset += 2 - } -} - diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/versionspoof/AbstractVersionSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/shared/patch/versionspoof/AbstractVersionSpoofPatch.kt deleted file mode 100644 index 0bfe49ced..000000000 --- a/src/main/kotlin/app/revanced/patches/shared/patch/versionspoof/AbstractVersionSpoofPatch.kt +++ /dev/null @@ -1,58 +0,0 @@ -package app.revanced.patches.shared.patch.versionspoof - -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patches.shared.fingerprints.versionspoof.ClientInfoFingerprint -import app.revanced.patches.shared.fingerprints.versionspoof.ClientInfoParentFingerprint -import app.revanced.util.exception -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.dexbacked.reference.DexBackedFieldReference -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction - -abstract class AbstractVersionSpoofPatch( - private val descriptor: String -) : BytecodePatch( - setOf(ClientInfoParentFingerprint) -) { - override fun execute(context: BytecodeContext) { - - ClientInfoParentFingerprint.result?.let { parentResult -> - ClientInfoFingerprint.also { - it.resolve( - context, - parentResult.classDef - ) - }.result?.mutableMethod?.let { - it.apply { - var insertIndex = 0 - val insertInstructions = implementation!!.instructions - val targetString = "Landroid/os/Build\$VERSION;->RELEASE:Ljava/lang/String;" - - for ((index, instruction) in insertInstructions.withIndex()) { - if (instruction.opcode != Opcode.SGET_OBJECT) continue - - val indexString = - ((instruction as? ReferenceInstruction)?.reference as? DexBackedFieldReference).toString() - - if (indexString != targetString) continue - - val targetRegister = (instruction as OneRegisterInstruction).registerA - insertIndex = index - 1 - - addInstructions( - insertIndex, """ - invoke-static {v$targetRegister}, $descriptor - move-result-object v$targetRegister - """ - ) - break - } - if (insertIndex <= 0) throw ClientInfoFingerprint.exception - } - } ?: throw ClientInfoFingerprint.exception - } ?: throw ClientInfoParentFingerprint.exception - - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt index ef31db2ff..d7775bfbb 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/settings/AbstractSettingsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/settings/AbstractSettingsResourcePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.settings +package app.revanced.patches.shared.settings import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch diff --git a/src/main/kotlin/app/revanced/patches/shared/settings/fingerprints/SharedSettingFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/settings/fingerprints/SharedSettingFingerprint.kt new file mode 100644 index 000000000..928564446 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/settings/fingerprints/SharedSettingFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.shared.settings.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_SETTING_CLASS_DESCRIPTOR + +object SharedSettingFingerprint : MethodFingerprint( + returnType = "V", + customFingerprint = { methodDef, _ -> + methodDef.definingClass == INTEGRATIONS_SETTING_CLASS_DESCRIPTOR + && methodDef.name == "" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/tracking/AbstractSanitizeUrlQueryPatch.kt b/src/main/kotlin/app/revanced/patches/shared/tracking/AbstractSanitizeUrlQueryPatch.kt similarity index 96% rename from src/main/kotlin/app/revanced/patches/shared/patch/tracking/AbstractSanitizeUrlQueryPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/tracking/AbstractSanitizeUrlQueryPatch.kt index f9fc7b392..c07d1b484 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/tracking/AbstractSanitizeUrlQueryPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/tracking/AbstractSanitizeUrlQueryPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.tracking +package app.revanced.patches.shared.tracking import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/tracking/CopyTextEndpointFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/tracking/fingerprints/CopyTextEndpointFingerprint.kt similarity index 91% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/tracking/CopyTextEndpointFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/tracking/fingerprints/CopyTextEndpointFingerprint.kt index 7e54120aa..752687d59 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/tracking/CopyTextEndpointFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/tracking/fingerprints/CopyTextEndpointFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.tracking +package app.revanced.patches.shared.tracking.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/transformation/BaseTransformInstructionsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/transformation/BaseTransformInstructionsPatch.kt similarity index 97% rename from src/main/kotlin/app/revanced/patches/shared/patch/transformation/BaseTransformInstructionsPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/transformation/BaseTransformInstructionsPatch.kt index d7887fd38..12663c9d5 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/transformation/BaseTransformInstructionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/transformation/BaseTransformInstructionsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.transformation +package app.revanced.patches.shared.transformation import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.patch.BytecodePatch diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/transformation/MethodCall.kt b/src/main/kotlin/app/revanced/patches/shared/transformation/MethodCall.kt similarity index 98% rename from src/main/kotlin/app/revanced/patches/shared/patch/transformation/MethodCall.kt rename to src/main/kotlin/app/revanced/patches/shared/transformation/MethodCall.kt index 816ef9155..8621bbf2b 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/transformation/MethodCall.kt +++ b/src/main/kotlin/app/revanced/patches/shared/transformation/MethodCall.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.transformation +package app.revanced.patches.shared.transformation import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/translations/AbstractTranslationsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/translations/AbstractTranslationsPatch.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/shared/patch/translations/AbstractTranslationsPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/translations/AbstractTranslationsPatch.kt index 632ba73b8..1b8bb166c 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/translations/AbstractTranslationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/translations/AbstractTranslationsPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.patch.translations +package app.revanced.patches.shared.translations import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch @@ -6,6 +6,7 @@ import app.revanced.util.classLoader import java.nio.file.Files import java.nio.file.StandardCopyOption +@Suppress("DEPRECATION") abstract class AbstractTranslationsPatch( private val sourceDirectory: String, private val languageArray: Array diff --git a/src/main/kotlin/app/revanced/patches/shared/versionspoof/AbstractVersionSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/shared/versionspoof/AbstractVersionSpoofPatch.kt new file mode 100644 index 000000000..56320ab55 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/versionspoof/AbstractVersionSpoofPatch.kt @@ -0,0 +1,42 @@ +package app.revanced.patches.shared.versionspoof + +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.patches.shared.versionspoof.fingerprints.ClientInfoFingerprint +import app.revanced.patches.shared.versionspoof.fingerprints.ClientInfoParentFingerprint +import app.revanced.util.exception +import app.revanced.util.getTargetIndexReversed +import app.revanced.util.getTargetIndexWithFieldReferenceName +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction + +abstract class AbstractVersionSpoofPatch( + private val descriptor: String +) : BytecodePatch( + setOf(ClientInfoParentFingerprint) +) { + override fun execute(context: BytecodeContext) { + + ClientInfoParentFingerprint.result?.let { parentResult -> + ClientInfoFingerprint.resolve(context, parentResult.classDef) + + ClientInfoFingerprint.result?.let { + it.mutableMethod.apply { + val versionIndex = getTargetIndexWithFieldReferenceName("RELEASE") + 1 + val insertIndex = getTargetIndexReversed(versionIndex, Opcode.IPUT_OBJECT) + val insertRegister = getInstruction(insertIndex).registerA + + addInstructions( + insertIndex, """ + invoke-static {v$insertRegister}, $descriptor + move-result-object v$insertRegister + """ + ) + } + } ?: throw ClientInfoFingerprint.exception + } ?: throw ClientInfoParentFingerprint.exception + + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/versionspoof/fingerprints/ClientInfoFingerprint.kt similarity index 86% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/versionspoof/fingerprints/ClientInfoFingerprint.kt index d2b9d8c51..762d97920 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/versionspoof/fingerprints/ClientInfoFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.versionspoof +package app.revanced.patches.shared.versionspoof.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/versionspoof/fingerprints/ClientInfoParentFingerprint.kt similarity index 74% rename from src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/versionspoof/fingerprints/ClientInfoParentFingerprint.kt index 215b281d3..9a875e581 100644 --- a/src/main/kotlin/app/revanced/patches/shared/fingerprints/versionspoof/ClientInfoParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/versionspoof/fingerprints/ClientInfoParentFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.shared.fingerprints.versionspoof +package app.revanced.patches.shared.versionspoof.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/shared/patch/voicesearch/AbstractVoiceSearchButtonPatch.kt b/src/main/kotlin/app/revanced/patches/shared/voicesearch/AbstractVoiceSearchButtonPatch.kt similarity index 95% rename from src/main/kotlin/app/revanced/patches/shared/patch/voicesearch/AbstractVoiceSearchButtonPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/voicesearch/AbstractVoiceSearchButtonPatch.kt index f3ff28e82..0eb482f2a 100644 --- a/src/main/kotlin/app/revanced/patches/shared/patch/voicesearch/AbstractVoiceSearchButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/voicesearch/AbstractVoiceSearchButtonPatch.kt @@ -1,10 +1,11 @@ -package app.revanced.patches.shared.patch.voicesearch +package app.revanced.patches.shared.voicesearch import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import org.w3c.dom.Element import kotlin.io.path.exists +@Suppress("DEPRECATION") abstract class AbstractVoiceSearchButtonPatch( private val paths: Array, private val replacements: Array diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/general/GeneralAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/general/GeneralAdsPatch.kt index c3812799c..c15e7fbe3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/general/GeneralAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/general/GeneralAdsPatch.kt @@ -4,12 +4,12 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.ads.fullscreen.FullscreenAdsPatch import app.revanced.patches.youtube.ads.getpremium.HideGetPremiumPatch import app.revanced.patches.youtube.utils.fix.doublebacktoclose.DoubleBackToClosePatch import app.revanced.patches.youtube.utils.fix.swiperefresh.SwipeRefreshPatch import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.copyXmlNode import app.revanced.util.doRecursively diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/getpremium/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/getpremium/HideGetPremiumPatch.kt index 89526b004..0ce9e7550 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/getpremium/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/getpremium/HideGetPremiumPatch.kt @@ -5,7 +5,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.music.utils.integrations.Constants import app.revanced.patches.youtube.ads.getpremium.fingerprints.CompactYpcOfferModuleViewFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.util.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/ads/video/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ads/video/VideoAdsPatch.kt index 2bed54e9e..f944e88d7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ads/video/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ads/video/VideoAdsPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.ads.video import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.ads.AbstractAdsPatch +import app.revanced.patches.shared.ads.AbstractAdsPatch import app.revanced.patches.youtube.utils.integrations.Constants.ADS_PATH import app.revanced.patches.youtube.utils.settings.SettingsPatch @@ -43,7 +43,8 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch ) @Suppress("unused") object VideoAdsPatch : AbstractAdsPatch( - "$ADS_PATH/VideoAdsPatch;->hideVideoAds()Z" + "$ADS_PATH/VideoAdsPatch;", + "hideVideoAds" ) { override fun execute(context: BytecodeContext) { super.execute(context) diff --git a/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/ButtonContainerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/ButtonContainerPatch.kt index 05c74c66b..ce4fe5ef9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/ButtonContainerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/buttoncontainer/ButtonContainerPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.data.BytecodeContext 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.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch @Patch( diff --git a/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/CommentComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/CommentComponentPatch.kt index 4c26d1e5b..4fbd80a5c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/CommentComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/buttomplayer/comment/CommentComponentPatch.kt @@ -8,12 +8,12 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.buttomplayer.comment.fingerprints.ShortsLiveStreamEmojiPickerOnClickListenerFingerprint import app.revanced.patches.youtube.buttomplayer.comment.fingerprints.ShortsLiveStreamEmojiPickerOpacityFingerprint import app.revanced.patches.youtube.buttomplayer.comment.fingerprints.ShortsLiveStreamThanksFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.BOTTOM_PLAYER import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/OldQualityLayoutPatch.kt index 86f1faf3d..aa595e0e5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldqualitylayout/OldQualityLayoutPatch.kt @@ -9,11 +9,11 @@ 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.smali.ExternalLabel +import app.revanced.patches.shared.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.fingerprints.QualityMenuViewInflateFingerprint import app.revanced.patches.youtube.utils.fingerprints.VideoQualitySetterFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.FLYOUT_PANEL -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldspeedlayout/OldSpeedLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldspeedlayout/OldSpeedLayoutPatch.kt index d7012a771..079457c84 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldspeedlayout/OldSpeedLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/oldspeedlayout/OldSpeedLayoutPatch.kt @@ -9,11 +9,11 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.CustomPlaybackSpeedIntegrationsFingerprint import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.PlaybackRateBottomSheetClassFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.VIDEO_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch import app.revanced.util.exception import com.android.tools.smali.dexlib2.AccessFlags diff --git a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/player/PlayerFlyoutPanelPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/player/PlayerFlyoutPanelPatch.kt index 1f5da91ac..1b8e5b87c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/player/PlayerFlyoutPanelPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/player/PlayerFlyoutPanelPatch.kt @@ -7,12 +7,12 @@ import app.revanced.patcher.fingerprint.MethodFingerprint 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.litho.LithoFilterPatch import app.revanced.patches.youtube.flyoutpanel.player.fingerprints.AdvancedQualityBottomSheetFingerprint import app.revanced.patches.youtube.flyoutpanel.player.fingerprints.CaptionsBottomSheetFingerprint import app.revanced.patches.youtube.utils.fingerprints.QualityMenuViewInflateFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.FLYOUT_PANEL -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.BottomSheetFooterText diff --git a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/QuickActionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/QuickActionsPatch.kt index 03be41a44..63bef40de 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/QuickActionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/fullscreen/quickactions/QuickActionsPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.data.BytecodeContext 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.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.quickactions.QuickActionsHookPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/AutoCaptionsPatch.kt index 7dbb3c01c..deb0d1a57 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/autocaptions/AutoCaptionsPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.general.autocaptions import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.captions.AbstractAutoCaptionsPatch +import app.revanced.patches.shared.captions.AbstractAutoCaptionsPatch import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.videoid.general.VideoIdPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/ChannelListSubMenuPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/ChannelListSubMenuPatch.kt index cad4075b3..4a4f5ce1e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/ChannelListSubMenuPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/channellistsubmenu/ChannelListSubMenuPatch.kt @@ -6,10 +6,10 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.general.channellistsubmenu.fingerprints.ChannelListSubMenuFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/ChannelProfileComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/ChannelProfileComponentsPatch.kt index dd0c75aea..933807f80 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/ChannelProfileComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/ChannelProfileComponentsPatch.kt @@ -6,9 +6,9 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.general.channelprofile.fingerprints.DefaultsTabsBarFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TabsBarTextTabView import app.revanced.patches.youtube.utils.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/descriptions/DescriptionComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/descriptions/DescriptionComponentsPatch.kt index 19738cfd0..0d03a42e6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/descriptions/DescriptionComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/descriptions/DescriptionComponentsPatch.kt @@ -6,10 +6,10 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.general.descriptions.fingerprints.TextViewComponentFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/dialog/RemoveViewerDiscretionDialogPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/dialog/RemoveViewerDiscretionDialogPatch.kt index 89557e350..3a9d38890 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/dialog/RemoveViewerDiscretionDialogPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/dialog/RemoveViewerDiscretionDialogPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.general.dialog import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.dialog.AbstractRemoveViewerDiscretionDialogPatch +import app.revanced.patches.shared.dialog.AbstractRemoveViewerDiscretionDialogPatch import app.revanced.patches.youtube.general.dialog.fingerprints.AgeVerifiedFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL import app.revanced.patches.youtube.utils.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/handle/HideHandlePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/handle/HideHandlePatch.kt index 864fd31c3..b6457be59 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/handle/HideHandlePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/handle/HideHandlePatch.kt @@ -6,10 +6,10 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.general.handle.fingerprints.AccountSwitcherAccessibilityLabelFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AccountSwitcherAccessibility import app.revanced.patches.youtube.utils.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/layout/LayoutComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/layout/LayoutComponentsPatch.kt index 3387caad3..a5cd34b15 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/layout/LayoutComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/layout/LayoutComponentsPatch.kt @@ -4,8 +4,8 @@ import app.revanced.patcher.data.BytecodeContext 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.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch @Patch( diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/MixPlaylistsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/MixPlaylistsPatch.kt index 9d98fcd51..f8823ac89 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/MixPlaylistsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/mixplaylists/MixPlaylistsPatch.kt @@ -9,10 +9,10 @@ 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.smali.ExternalLabel +import app.revanced.patches.shared.litho.LithoFilterPatch import app.revanced.patches.youtube.general.mixplaylists.fingerprints.ElementParserFingerprint import app.revanced.patches.youtube.general.mixplaylists.fingerprints.EmptyFlatBufferFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.exception import app.revanced.util.getStringInstructionIndex diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/suggestions/SuggestionsShelfPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/suggestions/SuggestionsShelfPatch.kt index 486cb7f7f..297250bd0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/suggestions/SuggestionsShelfPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/suggestions/SuggestionsShelfPatch.kt @@ -6,9 +6,9 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.general.suggestions.fingerprints.BreakingNewsFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.navbarindex.NavBarIndexHookPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/CustomBrandingNamePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/CustomBrandingNamePatch.kt index 00cdca917..f4e3ca43d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/CustomBrandingNamePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/CustomBrandingNamePatch.kt @@ -5,7 +5,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.patch.options.PatchOption.PatchExtensions.stringPatchOption -import app.revanced.patches.shared.patch.elements.AbstractRemoveStringsElementsPatch +import app.revanced.patches.shared.elements.AbstractRemoveStringsElementsPatch import app.revanced.patches.youtube.utils.integrations.Constants.LANGUAGE_LIST import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusLabel import app.revanced.patches.youtube.utils.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/DoubleTapOverlayBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/DoubleTapOverlayBackgroundPatch.kt index 93c1e2b54..387304df9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/DoubleTapOverlayBackgroundPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/doubletapbackground/DoubleTapOverlayBackgroundPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.doubletapbackground import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.overlaybackground.AbstractOverlayBackgroundPatch +import app.revanced.patches.shared.overlaybackground.AbstractOverlayBackgroundPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch @Patch( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/GeneralThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/GeneralThemePatch.kt index faf3b7ffe..a1d072a12 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/GeneralThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/GeneralThemePatch.kt @@ -3,15 +3,15 @@ package app.revanced.patches.youtube.layout.theme import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.litho.LithoThemePatch +import app.revanced.patches.shared.drawable.DrawableColorPatch import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH import org.w3c.dom.Element -@Patch(dependencies = [LithoThemePatch::class]) -object GeneralThemePatch : ResourcePatch() { +@Patch(dependencies = [DrawableColorPatch::class]) +object ThemeBytecodePatch : ResourcePatch() { override fun execute(context: ResourceContext) { - LithoThemePatch.injectCall("$UTILS_PATH/LithoThemePatch;->applyLithoTheme(I)I") + DrawableColorPatch.injectCall("$UTILS_PATH/DrawableColorPatch;->getColor(I)I") // edit the resource files to change the splash screen color val attrsPath = "res/values/attrs.xml" diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/materialyou/MaterialYouPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/MaterialYouPatch.kt similarity index 89% rename from src/main/kotlin/app/revanced/patches/youtube/layout/materialyou/MaterialYouPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/theme/MaterialYouPatch.kt index 2ba172e0a..28bb10050 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/materialyou/MaterialYouPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/MaterialYouPatch.kt @@ -1,11 +1,10 @@ -package app.revanced.patches.youtube.layout.materialyou +package app.revanced.patches.youtube.layout.theme 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.youtube.layout.theme.GeneralThemePatch -import app.revanced.patches.youtube.layout.theme.GeneralThemePatch.isMonetPatchIncluded +import app.revanced.patches.youtube.layout.theme.ThemeBytecodePatch.isMonetPatchIncluded import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusTheme import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.ResourceGroup @@ -16,8 +15,8 @@ import app.revanced.util.copyXmlNode name = "MaterialYou", description = "Enables MaterialYou theme for Android 12+", dependencies = [ - GeneralThemePatch::class, - SettingsPatch::class + SettingsPatch::class, + ThemeBytecodePatch::class ], compatiblePackages = [ CompatiblePackage( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt index b266f7df6..e3deba145 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/ThemePatch.kt @@ -6,7 +6,7 @@ import app.revanced.patcher.patch.ResourcePatch 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.youtube.layout.theme.GeneralThemePatch.isMonetPatchIncluded +import app.revanced.patches.youtube.layout.theme.ThemeBytecodePatch.isMonetPatchIncluded import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusTheme import app.revanced.patches.youtube.utils.settings.SettingsPatch import org.w3c.dom.Element @@ -15,8 +15,8 @@ import org.w3c.dom.Element name = "Theme", description = "Change the app's theme to the values specified in options.json.", dependencies = [ - GeneralThemePatch::class, - SettingsPatch::class + SettingsPatch::class, + ThemeBytecodePatch::class ], compatiblePackages = [ CompatiblePackage( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/voicesearch/VoiceSearchButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/voicesearch/VoiceSearchButtonPatch.kt index 37dc1d2a2..09b854315 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/voicesearch/VoiceSearchButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/voicesearch/VoiceSearchButtonPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.layout.voicesearch import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.voicesearch.AbstractVoiceSearchButtonPatch +import app.revanced.patches.shared.voicesearch.AbstractVoiceSearchButtonPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch @Patch( diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/codec/audio/ForceOpusCodecPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/codec/audio/ForceOpusCodecPatch.kt index 16e60a0ac..27dbc452f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/codec/audio/ForceOpusCodecPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/codec/audio/ForceOpusCodecPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.misc.codec.audio import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.opus.AbstractOpusCodecsPatch +import app.revanced.patches.shared.opus.AbstractOpusCodecsPatch import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH import app.revanced.patches.youtube.utils.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/ExternalBrowserPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/ExternalBrowserPatch.kt index a40470ef4..86b6d8b15 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/ExternalBrowserPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/externalbrowser/ExternalBrowserPatch.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.patch.transformation.BaseTransformInstructionsPatch +import app.revanced.patches.shared.transformation.BaseTransformInstructionsPatch import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH import app.revanced.patches.youtube.utils.settings.SettingsPatch import com.android.tools.smali.dexlib2.iface.ClassDef diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/SpoofAppVersionPatch.kt index 990854da3..7011fb80c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/spoofappversion/SpoofAppVersionPatch.kt @@ -4,7 +4,7 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.versionspoof.AbstractVersionSpoofPatch +import app.revanced.patches.shared.versionspoof.AbstractVersionSpoofPatch import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/tracking/SanitizeUrlQueryPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/tracking/SanitizeUrlQueryPatch.kt index 490ce7748..d606d4364 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/tracking/SanitizeUrlQueryPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/tracking/SanitizeUrlQueryPatch.kt @@ -5,8 +5,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.fingerprints.tracking.CopyTextEndpointFingerprint -import app.revanced.patches.shared.patch.tracking.AbstractSanitizeUrlQueryPatch +import app.revanced.patches.shared.tracking.AbstractSanitizeUrlQueryPatch +import app.revanced.patches.shared.tracking.fingerprints.CopyTextEndpointFingerprint import app.revanced.patches.youtube.misc.tracking.fingerprints.ShareLinkFormatterFingerprint import app.revanced.patches.youtube.misc.tracking.fingerprints.SystemShareLinkFormatterFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/translations/TranslationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/translations/TranslationsPatch.kt index e0a9ca3a5..740dab08f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/translations/TranslationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/translations/TranslationsPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.misc.translations import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.translations.AbstractTranslationsPatch +import app.revanced.patches.shared.translations.AbstractTranslationsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch @Patch( diff --git a/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/download/pip/DisablePiPPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/download/pip/DisablePiPPatch.kt index eb806f6af..0975f8ed7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/download/pip/DisablePiPPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/overlaybutton/download/pip/DisablePiPPatch.kt @@ -16,8 +16,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction object DisablePiPPatch : BytecodePatch( setOf(PiPPlaybackFingerprint) ) { - private const val INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR = - "$INTEGRATIONS_PATH/utils/VideoHelpers;" + private const val INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR = + "$INTEGRATIONS_PATH/utils/VideoUtils;" override fun execute(context: BytecodeContext) { PiPPlaybackFingerprint.result?.let { @@ -27,7 +27,7 @@ object DisablePiPPatch : BytecodePatch( addInstructions( insertIndex, """ - invoke-static {v$insertRegister}, $INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR->isPiPAvailable(Z)Z + invoke-static {v$insertRegister}, $INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR->isPiPAvailable(Z)Z move-result v$insertRegister """ ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/HideCaptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/HideCaptionsButtonPatch.kt index 962d7dad5..0c9bfad83 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/HideCaptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/captionsbutton/HideCaptionsButtonPatch.kt @@ -7,11 +7,11 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.player.captionsbutton.fingerprints.LithoSubtitleButtonConfigFingerprint import app.revanced.patches.youtube.player.captionsbutton.fingerprints.YouTubeControlsOverlaySubtitleButtonFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/HideCollapseButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/HideCollapseButtonPatch.kt index a78a1ebce..deabc3e27 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/HideCollapseButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/HideCollapseButtonPatch.kt @@ -1,19 +1,27 @@ package app.revanced.patches.youtube.player.collapsebutton -import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.ResourcePatch +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.utils.playerbutton.PlayerButtonHookPatch +import app.revanced.patches.youtube.player.collapsebutton.fingerprints.LiveChatFingerprint +import app.revanced.patches.youtube.utils.integrations.Constants +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch +import app.revanced.util.exception +import app.revanced.util.findMutableMethodOf +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c +import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c @Patch( name = "Hide collapse button", description = "Adds an option to hide the collapse button in the video player.", - dependencies = - [ - PlayerButtonHookPatch::class, - SettingsPatch::class + dependencies = [ + SettingsPatch::class, + SharedResourceIdPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -46,8 +54,48 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch ] ) @Suppress("unused") -object HideCollapseButtonPatch : ResourcePatch() { - override fun execute(context: ResourceContext) { +object HideCollapseButtonPatch : BytecodePatch( + setOf(LiveChatFingerprint) +) { + override fun execute(context: BytecodeContext) { + + LiveChatFingerprint.result?.let { + val endIndex = it.scanResult.patternScanResult!!.endIndex + val instructions = it.mutableMethod.getInstruction(endIndex) + val imageButtonClass = context + .findClass((instructions as BuilderInstruction21c).reference.toString())!! + .mutableClass + + for (method in imageButtonClass.methods) { + imageButtonClass.findMutableMethodOf(method).apply { + var jumpInstruction = true + + implementation!!.instructions.forEachIndexed { index, instructions -> + if (instructions.opcode == Opcode.INVOKE_VIRTUAL) { + val definedInstruction = (instructions as? BuilderInstruction35c) + + if (definedInstruction?.reference.toString() == + "Landroid/view/View;->setVisibility(I)V" + ) { + + jumpInstruction = !jumpInstruction + if (jumpInstruction) return@forEachIndexed + + val firstRegister = definedInstruction?.registerC + val secondRegister = definedInstruction?.registerD + + addInstructions( + index, """ + invoke-static {v$firstRegister, v$secondRegister}, ${Constants.PLAYER}->hidePlayerButton(Landroid/view/View;I)I + move-result v$secondRegister + """ + ) + } + } + } + } + } + } ?: throw LiveChatFingerprint.exception /** * Add settings diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/fingerprints/LiveChatFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/fingerprints/LiveChatFingerprint.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/fingerprints/LiveChatFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/fingerprints/LiveChatFingerprint.kt index ea834712a..b49320af9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/fingerprints/LiveChatFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/collapsebutton/fingerprints/LiveChatFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.utils.playerbutton.fingerprints +package app.revanced.patches.youtube.player.collapsebutton.fingerprints import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.LiveChatButton import app.revanced.util.fingerprint.LiteralValueFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/infocards/HideInfoCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/infocards/HideInfoCardsPatch.kt index 4c4253396..9e570eb02 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/infocards/HideInfoCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/infocards/HideInfoCardsPatch.kt @@ -6,10 +6,10 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.player.infocards.fingerprints.InfoCardsIncognitoFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/SuggestedActionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/SuggestedActionsPatch.kt index d1886c2bf..39c5914ed 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/SuggestedActionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/suggestactions/SuggestedActionsPatch.kt @@ -6,9 +6,9 @@ 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.litho.LithoFilterPatch import app.revanced.patches.youtube.player.suggestactions.fingerprints.SuggestedActionsFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/watermark/HideChannelWatermarkPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/HideChannelWatermarkPatch.kt index 13bbaa83d..3b367f803 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/watermark/HideChannelWatermarkPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/watermark/HideChannelWatermarkPatch.kt @@ -7,11 +7,11 @@ import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction 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.litho.LithoFilterPatch import app.revanced.patches.youtube.player.watermark.fingerprints.HideWatermarkFingerprint import app.revanced.patches.youtube.player.watermark.fingerprints.HideWatermarkParentFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/seekbar/color/SeekbarColorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/seekbar/color/SeekbarColorPatch.kt index bcd42cd82..4902186bd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/seekbar/color/SeekbarColorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/seekbar/color/SeekbarColorPatch.kt @@ -8,7 +8,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.patch.litho.LithoThemePatch +import app.revanced.patches.shared.drawable.DrawableColorPatch import app.revanced.patches.youtube.seekbar.color.fingerprints.ControlsOverlayStyleFingerprint import app.revanced.patches.youtube.seekbar.color.fingerprints.ShortsSeekbarColorFingerprint import app.revanced.patches.youtube.utils.fingerprints.PlayerSeekbarColorFingerprint @@ -29,7 +29,7 @@ import org.w3c.dom.Element name = "Custom seekbar color", description = "Adds an option to customize seekbar colors in video players and video thumbnails.", dependencies = [ - LithoThemePatch::class, + DrawableColorPatch::class, SettingsPatch::class, SharedResourceIdPatch::class, ], @@ -99,7 +99,7 @@ object SeekbarColorPatch : BytecodePatch( } } ?: throw ControlsOverlayStyleFingerprint.exception - LithoThemePatch.injectCall("$SEEKBAR->getLithoColor(I)I") + DrawableColorPatch.injectCall("$SEEKBAR->getColor(I)I") contexts.xmlEditor["res/drawable/resume_playback_progressbar_drawable.xml"].use { val layerList = it.file.getElementsByTagName("layer-list").item(0) as Element diff --git a/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt index a9d019ba5..4dea5d89b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shorts/components/ShortsComponentPatch.kt @@ -11,6 +11,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.patcher.util.smali.ExternalLabel +import app.revanced.patches.shared.litho.LithoFilterPatch import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsButtonFingerprint import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsInfoPanelFingerprint import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPaidPromotionFingerprint @@ -19,7 +20,6 @@ import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPivotLe import app.revanced.patches.youtube.utils.browseid.BrowseIdHookPatch import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelDynRemix diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/browseid/BrowseIdHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/browseid/BrowseIdHookPatch.kt index 44b7b9808..9f607068a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/browseid/BrowseIdHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/browseid/BrowseIdHookPatch.kt @@ -7,10 +7,10 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.litho.ComponentParserPatch +import app.revanced.patches.shared.litho.LithoFilterPatch +import app.revanced.patches.shared.litho.fingerprints.PathBuilderFingerprint import app.revanced.patches.youtube.utils.browseid.fingerprints.BrowseIdClassFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.util.exception import app.revanced.util.getStringInstructionIndex @@ -26,7 +26,10 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference ] ) object BrowseIdHookPatch : BytecodePatch( - setOf(BrowseIdClassFingerprint) + setOf( + BrowseIdClassFingerprint, + PathBuilderFingerprint + ) ) { private const val INTEGRATIONS_CLASS_DESCRIPTOR = "$UTILS_PATH/BrowseIdPatch;" @@ -62,11 +65,13 @@ object BrowseIdHookPatch : BytecodePatch( /** * Set BrowseId to integrations. */ - ComponentParserPatch.pathBuilderMethod.apply { - addInstruction( - 0, - "invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->setBrowseIdFromField()V" - ) - } + PathBuilderFingerprint.result?.let { + it.mutableMethod.apply { + addInstruction( + 0, + "invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->setBrowseIdFromField()V" + ) + } + } ?: throw PathBuilderFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/ClientSpoofPatch.kt index 8a6a207b4..9e7789472 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/clientspoof/ClientSpoofPatch.kt @@ -1,5 +1,5 @@ package app.revanced.patches.youtube.utils.fix.clientspoof -import app.revanced.patches.shared.patch.clientspoof.AbstractClientSpoofPatch +import app.revanced.patches.shared.clientspoof.AbstractClientSpoofPatch object ClientSpoofPatch : AbstractClientSpoofPatch("com.google.android.youtube") \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/SpoofPlayerParameterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/SpoofPlayerParameterPatch.kt index c8e94815e..13280fb0b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/SpoofPlayerParameterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/SpoofPlayerParameterPatch.kt @@ -26,8 +26,8 @@ import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.videoid.general.VideoIdPatch import app.revanced.util.exception -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( name = "Spoof player parameters", diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelGeneralStoryboardRendererFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelGeneralStoryboardRendererFingerprint.kt index accfd3d94..06911917c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelGeneralStoryboardRendererFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelGeneralStoryboardRendererFingerprint.kt @@ -1,8 +1,8 @@ package app.revanced.patches.youtube.utils.fix.parameter.fingerprints -import app.revanced.util.containsWideLiteralInstructionIndex import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.util.containsWideLiteralInstructionIndex import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelLiveStreamStoryboardRendererFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelLiveStreamStoryboardRendererFingerprint.kt index a546c22bc..649193d2c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelLiveStreamStoryboardRendererFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelLiveStreamStoryboardRendererFingerprint.kt @@ -1,8 +1,8 @@ package app.revanced.patches.youtube.utils.fix.parameter.fingerprints -import app.revanced.util.containsWideLiteralInstructionIndex import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.util.containsWideLiteralInstructionIndex import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelStoryboardRecommendedLevelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelStoryboardRecommendedLevelFingerprint.kt index fec6b8a1f..c472c9126 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelStoryboardRecommendedLevelFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/parameter/fingerprints/PlayerResponseModelStoryboardRecommendedLevelFingerprint.kt @@ -1,8 +1,8 @@ package app.revanced.patches.youtube.utils.fix.parameter.fingerprints -import app.revanced.util.containsWideLiteralInstructionIndex import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.util.containsWideLiteralInstructionIndex import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/IntegrationsPatch.kt index 6326786f5..a807e6edb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/IntegrationsPatch.kt @@ -1,8 +1,7 @@ package app.revanced.patches.youtube.utils.integrations import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch -import app.revanced.patches.youtube.utils.integrations.Constants.INTEGRATIONS_PATH +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch import app.revanced.patches.youtube.utils.integrations.fingerprints.APIPlayerServiceFingerprint import app.revanced.patches.youtube.utils.integrations.fingerprints.ApplicationInitFingerprint import app.revanced.patches.youtube.utils.integrations.fingerprints.EmbeddedPlayerControlsOverlayFingerprint @@ -12,8 +11,7 @@ import app.revanced.patches.youtube.utils.integrations.fingerprints.RemoteEmbedd import app.revanced.patches.youtube.utils.integrations.fingerprints.StandalonePlayerActivityFingerprint @Patch(requiresIntegrations = true) -object IntegrationsPatch : AbstractIntegrationsPatch( - "$INTEGRATIONS_PATH/utils/ReVancedUtils;", +object IntegrationsPatch : BaseIntegrationsPatch( setOf( ApplicationInitFingerprint, StandalonePlayerActivityFingerprint, diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt index 33ccd5695..e395e37b1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/APIPlayerServiceFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.utils.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** @@ -9,6 +9,7 @@ import com.android.tools.smali.dexlib2.AccessFlags * It appears this hook may no longer be needed as one of the constructor parameters is the already hooked * [EmbeddedPlayerControlsOverlayFingerprint] */ +@Suppress("DEPRECATION") object APIPlayerServiceFingerprint : IntegrationsFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/service/jar/ApiPlayerService;" }, diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/ApplicationInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/ApplicationInitFingerprint.kt index 946c50897..5e0fbd36c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/ApplicationInitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/ApplicationInitFingerprint.kt @@ -1,10 +1,11 @@ package app.revanced.patches.youtube.utils.integrations.fingerprints -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint /** * Hooks the context when the app is launched as a regular application (and is not an embedded video playback). */ +@Suppress("DEPRECATION") object ApplicationInitFingerprint : IntegrationsFingerprint( strings = listOf("Application creation", "Application.onCreate"), // Integrations context is the Activity itself. diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt index 1579894d8..65a5988b4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerControlsOverlayFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.utils.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** @@ -10,6 +10,7 @@ import com.android.tools.smali.dexlib2.AccessFlags * Note: this fingerprint may no longer be needed, as it appears * [RemoteEmbedFragmentFingerprint] may be set before this hook is called. */ +@Suppress("DEPRECATION") object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint( accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR, returnType = "V", diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt index b8d29769f..b95c8157d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/EmbeddedPlayerFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.utils.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** @@ -10,6 +10,7 @@ import com.android.tools.smali.dexlib2.AccessFlags * Note: this fingerprint may or may not be needed, as * [RemoteEmbedFragmentFingerprint] might be set before this is called. */ +@Suppress("DEPRECATION") object EmbeddedPlayerFingerprint : IntegrationsFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, returnType = "L", diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt index 9ead13602..102474393 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbedFragmentFingerprint.kt @@ -1,12 +1,13 @@ package app.revanced.patches.youtube.utils.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** * For embedded playback. Likely covers Google Play store and other Google products. */ +@Suppress("DEPRECATION") object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, returnType = "V", diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt index 1364099d6..20f7d7de8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/RemoteEmbeddedPlayerFingerprint.kt @@ -1,12 +1,13 @@ package app.revanced.patches.youtube.utils.integrations.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import com.android.tools.smali.dexlib2.AccessFlags /** * For embedded playback inside 3rd party android app (such as 3rd party Reddit apps). */ +@Suppress("DEPRECATION") object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint( accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR, returnType = "V", diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt index 5705c50f2..af5bb17d7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/integrations/fingerprints/StandalonePlayerActivityFingerprint.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.utils.integrations.fingerprints -import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint +import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint /** * Old API activity to embed YouTube into 3rd party Android apps. @@ -9,6 +9,7 @@ import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch. * but this may still be used by older apps: * https://developers.google.com/youtube/android/player */ +@Suppress("DEPRECATION") object StandalonePlayerActivityFingerprint : IntegrationsFingerprint( customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/youtube/api/StandalonePlayerActivity;" diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/litho/LithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/litho/LithoFilterPatch.kt deleted file mode 100644 index 2cd1a7cd1..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/litho/LithoFilterPatch.kt +++ /dev/null @@ -1,53 +0,0 @@ -package app.revanced.patches.youtube.utils.litho - -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.litho.ComponentParserPatch -import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import app.revanced.patches.youtube.utils.litho.fingerprints.LithoFilterFingerprint -import app.revanced.util.exception -import java.io.Closeable - -@Patch(dependencies = [ComponentParserPatch::class]) -@Suppress("unused") -object LithoFilterPatch : BytecodePatch( - setOf(LithoFilterFingerprint) -), Closeable { - private const val INTEGRATIONS_CLASS_DESCRIPTOR = - "$COMPONENTS_PATH/LithoFilterPatch;" - - internal lateinit var addFilter: (String) -> Unit - private set - - private var filterCount = 0 - override fun execute(context: BytecodeContext) { - ComponentParserPatch.injectCall(INTEGRATIONS_CLASS_DESCRIPTOR) - - LithoFilterFingerprint.result?.mutableMethod?.apply { - removeInstructions(0, 6) - - addFilter = { classDescriptor -> - addInstructions( - 0, """ - new-instance v1, $classDescriptor - invoke-direct {v1}, $classDescriptor->()V - const/16 v2, ${filterCount++} - aput-object v1, v0, v2 - """ - ) - } - } ?: throw LithoFilterFingerprint.exception - - } - - override fun close() = LithoFilterFingerprint.result!! - .mutableMethod.addInstructions( - 0, """ - const/16 v0, $filterCount - new-array v0, v0, [$COMPONENTS_PATH/Filter; - """ - ) -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/litho/fingerprints/LithoFilterFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/litho/fingerprints/LithoFilterFingerprint.kt deleted file mode 100644 index fa37557fb..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/litho/fingerprints/LithoFilterFingerprint.kt +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.patches.youtube.utils.litho.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.MethodFingerprint -import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH -import com.android.tools.smali.dexlib2.AccessFlags - -object LithoFilterFingerprint : MethodFingerprint( - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.CONSTRUCTOR, - customFingerprint = { methodDef, _ -> - methodDef.definingClass == "$COMPONENTS_PATH/LithoFilterPatch;" - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/microg/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/MicroGBytecodePatch.kt index ff6489ce7..56572f8e2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/microg/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/MicroGBytecodePatch.kt @@ -4,8 +4,8 @@ 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.patch.microg.MicroGBytecodeHelper -import app.revanced.patches.shared.patch.packagename.PackageNamePatch +import app.revanced.patches.shared.microg.MicroGBytecodeHelper +import app.revanced.patches.shared.packagename.PackageNamePatch import app.revanced.patches.youtube.utils.fix.clientspoof.ClientSpoofPatch import app.revanced.patches.youtube.utils.fix.parameter.SpoofPlayerParameterPatch import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/microg/MicroGPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/MicroGPatch.kt index f997dbcc7..9d61192a0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/microg/MicroGPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/microg/MicroGPatch.kt @@ -5,10 +5,10 @@ import app.revanced.patcher.patch.PatchException 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.patch.microg.MicroGManifestHelper.addSpoofingMetadata -import app.revanced.patches.shared.patch.microg.MicroGResourceHelper.patchManifest -import app.revanced.patches.shared.patch.microg.MicroGResourceHelper.patchSetting -import app.revanced.patches.shared.patch.packagename.PackageNamePatch +import app.revanced.patches.shared.microg.MicroGManifestHelper.addSpoofingMetadata +import app.revanced.patches.shared.microg.MicroGResourceHelper.patchManifest +import app.revanced.patches.shared.microg.MicroGResourceHelper.patchSetting +import app.revanced.patches.shared.packagename.PackageNamePatch import app.revanced.patches.youtube.utils.microg.Constants.PACKAGE_NAME import app.revanced.patches.youtube.utils.microg.Constants.SPOOFED_PACKAGE_NAME import app.revanced.patches.youtube.utils.microg.Constants.SPOOFED_PACKAGE_SIGNATURE diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/overridequality/OverrideQualityHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/overridequality/OverrideQualityHookPatch.kt index 507a19a0e..b5c034dfc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/overridequality/OverrideQualityHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/overridequality/OverrideQualityHookPatch.kt @@ -67,7 +67,7 @@ object OverrideQualityHookPatch : BytecodePatch( addInstruction( qualityAutoIndex + 1, - "sput-object v$qualityAutoRegister, $INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR->qualityAutoString:Ljava/lang/String;" + "sput-object v$qualityAutoRegister, $INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR->qualityAutoString:Ljava/lang/String;" ) } } ?: throw VideoQualityListFingerprint.exception @@ -102,7 +102,7 @@ object OverrideQualityHookPatch : BytecodePatch( addInstruction( textIndex + 1, - "sput-object v$textRegister, $INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR->currentQuality:Ljava/lang/String;" + "sput-object v$textRegister, $INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR->currentQuality:Ljava/lang/String;" ) } } ?: throw VideoQualityTextFingerprint.exception @@ -111,8 +111,8 @@ object OverrideQualityHookPatch : BytecodePatch( private const val INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR = "$VIDEO_PATH/VideoQualityPatch;" - private const val INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR = - "$INTEGRATIONS_PATH/utils/VideoHelpers;" + private const val INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR = + "$INTEGRATIONS_PATH/utils/VideoUtils;" private lateinit var QUALITY_CLASS: String private lateinit var QUALITY_METHOD: String diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/OverrideSpeedHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/OverrideSpeedHookPatch.kt index 9f249a831..363e19784 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/OverrideSpeedHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/overridespeed/OverrideSpeedHookPatch.kt @@ -91,7 +91,7 @@ object OverrideSpeedHookPatch : BytecodePatch( ) { addInstruction( this.implementation!!.instructions.size - 1, - "sput p1, $INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR->currentSpeed:F" + "sput p1, $INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR->currentSpeed:F" ) } } @@ -146,8 +146,8 @@ object OverrideSpeedHookPatch : BytecodePatch( private const val INTEGRATIONS_PLAYBACK_SPEED_CLASS_DESCRIPTOR = "$VIDEO_PATH/PlaybackSpeedPatch;" - private const val INTEGRATIONS_VIDEO_HELPER_CLASS_DESCRIPTOR = - "$INTEGRATIONS_PATH/utils/VideoHelpers;" + private const val INTEGRATIONS_VIDEO_UTILS_CLASS_DESCRIPTOR = + "$INTEGRATIONS_PATH/utils/VideoUtils;" lateinit var playbackSpeedChangedResult: MethodFingerprintResult diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/PlayerButtonHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/PlayerButtonHookPatch.kt deleted file mode 100644 index 2cb9c5107..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/playerbutton/PlayerButtonHookPatch.kt +++ /dev/null @@ -1,66 +0,0 @@ -package app.revanced.patches.youtube.utils.playerbutton - -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.Patch -import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER -import app.revanced.patches.youtube.utils.playerbutton.fingerprints.LiveChatFingerprint -import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch -import app.revanced.util.exception -import app.revanced.util.findMutableMethodOf -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c -import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c - -@Patch(dependencies = [SharedResourceIdPatch::class]) -object PlayerButtonHookPatch : BytecodePatch( - setOf(LiveChatFingerprint) -) { - override fun execute(context: BytecodeContext) { - - LiveChatFingerprint.result?.let { - val endIndex = it.scanResult.patternScanResult!!.endIndex - val instructions = it.mutableMethod.getInstruction(endIndex) - val imageButtonClass = - context - .findClass( - (instructions as BuilderInstruction21c) - .reference.toString() - )!! - .mutableClass - - for (method in imageButtonClass.methods) { - imageButtonClass.findMutableMethodOf(method).apply { - var jumpInstruction = true - - implementation!!.instructions.forEachIndexed { index, instructions -> - if (instructions.opcode == Opcode.INVOKE_VIRTUAL) { - val definedInstruction = (instructions as? BuilderInstruction35c) - - if (definedInstruction?.reference.toString() == - "Landroid/view/View;->setVisibility(I)V" - ) { - - jumpInstruction = !jumpInstruction - if (jumpInstruction) return@forEachIndexed - - val firstRegister = definedInstruction?.registerC - val secondRegister = definedInstruction?.registerD - - addInstructions( - index, """ - invoke-static {v$firstRegister, v$secondRegister}, $PLAYER->hidePlayerButton(Landroid/view/View;I)I - move-result v$secondRegister - """ - ) - } - } - } - } - } - } ?: throw LiveChatFingerprint.exception - - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/PlayerControlsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/PlayerControlsPatch.kt index 807c43620..9f9fcef9f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/PlayerControlsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/PlayerControlsPatch.kt @@ -198,7 +198,7 @@ object PlayerControlsPatch : BytecodePatch( addInstruction( endIndex + 1, - "invoke-static {v$viewRegister}, $descriptor->initialize(Ljava/lang/Object;)V" + "invoke-static {v$viewRegister}, $descriptor->initialize(Landroid/view/View;)V" ) } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt index 5a8cdb4d6..4fbef6ca9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt @@ -3,16 +3,16 @@ package app.revanced.patches.youtube.utils.resourceid import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch -import app.revanced.patches.shared.patch.mapping.ResourceType -import app.revanced.patches.shared.patch.mapping.ResourceType.COLOR -import app.revanced.patches.shared.patch.mapping.ResourceType.DIMEN -import app.revanced.patches.shared.patch.mapping.ResourceType.DRAWABLE -import app.revanced.patches.shared.patch.mapping.ResourceType.ID -import app.revanced.patches.shared.patch.mapping.ResourceType.INTEGER -import app.revanced.patches.shared.patch.mapping.ResourceType.LAYOUT -import app.revanced.patches.shared.patch.mapping.ResourceType.STRING -import app.revanced.patches.shared.patch.mapping.ResourceType.STYLE +import app.revanced.patches.shared.mapping.ResourceMappingPatch +import app.revanced.patches.shared.mapping.ResourceType +import app.revanced.patches.shared.mapping.ResourceType.COLOR +import app.revanced.patches.shared.mapping.ResourceType.DIMEN +import app.revanced.patches.shared.mapping.ResourceType.DRAWABLE +import app.revanced.patches.shared.mapping.ResourceType.ID +import app.revanced.patches.shared.mapping.ResourceType.INTEGER +import app.revanced.patches.shared.mapping.ResourceType.LAYOUT +import app.revanced.patches.shared.mapping.ResourceType.STRING +import app.revanced.patches.shared.mapping.ResourceType.STYLE @Patch(dependencies = [ResourceMappingPatch::class]) object SharedResourceIdPatch : ResourcePatch() { diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/ReturnYouTubeDislikePatch.kt index 194798957..b68f85e27 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/general/ReturnYouTubeDislikePatch.kt @@ -7,9 +7,9 @@ import app.revanced.patcher.fingerprint.MethodFingerprint 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.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH -import app.revanced.patches.youtube.utils.litho.LithoFilterPatch import app.revanced.patches.youtube.utils.playerresponse.PlayerResponsePatch import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.DislikeFingerprint import app.revanced.patches.youtube.utils.returnyoutubedislike.general.fingerprints.LikeFingerprint @@ -136,7 +136,7 @@ object ReturnYouTubeDislikePatch : BytecodePatch( /** * Add ReVanced Extended Settings */ - SettingsPatch.addReVancedPreference("ryd_settings") + SettingsPatch.addPreferenceFragment("revanced_ryd_settings") SettingsPatch.updatePatchStatus("Return YouTube Dislike") diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/rollingnumber/fingerprints/RollingNumberMeasureAnimatedTextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/rollingnumber/fingerprints/RollingNumberMeasureAnimatedTextFingerprint.kt index 8705d27d6..6b431193e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/rollingnumber/fingerprints/RollingNumberMeasureAnimatedTextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubedislike/rollingnumber/fingerprints/RollingNumberMeasureAnimatedTextFingerprint.kt @@ -1,13 +1,12 @@ package app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints -import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.util.fingerprint.ReferenceFingerprint import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction /** * Compatible with YouTube v18.30.xx to v18.49.xx */ -object RollingNumberMeasureAnimatedTextFingerprint : MethodFingerprint( +object RollingNumberMeasureAnimatedTextFingerprint : ReferenceFingerprint( opcodes = listOf( Opcode.INVOKE_VIRTUAL, Opcode.MOVE_RESULT, @@ -15,20 +14,5 @@ object RollingNumberMeasureAnimatedTextFingerprint : MethodFingerprint( Opcode.ADD_INT_LIT8, Opcode.GOTO ), - customFingerprint = custom@{ methodDef, _ -> - if (methodDef.implementation == null) - return@custom false - - for (instruction in methodDef.implementation!!.instructions) { - if (instruction.opcode != Opcode.INVOKE_VIRTUAL) - continue - - val invokeInstruction = instruction as ReferenceInstruction - if (!invokeInstruction.reference.toString().endsWith("Landroid/text/TextPaint;->measureText([CII)F")) - continue - - return@custom true - } - return@custom false - } + reference = { "Landroid/text/TextPaint;->measureText([CII)F" } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/ResourceUtils.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/ResourceUtils.kt index 1f7012db1..37d8ecd38 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/ResourceUtils.kt @@ -91,7 +91,7 @@ object ResourceUtils { } } - fun ResourceContext.addReVancedPreference(key: String) { + fun ResourceContext.addPreferenceFragment(key: String) { val targetClass = "com.google.android.apps.youtube.app.settings.videoquality.VideoQualitySettingsActivity" @@ -102,14 +102,14 @@ object ResourceUtils { it.getAttributeNode("android:key")?.let { attribute -> if (attribute.textContent == "@string/about_key" && it.getAttributeNode("app:iconSpaceReserved").textContent == "false") { it.insertNode("Preference", it) { - setAttribute("android:title", "@string/revanced_" + key + "_title") + setAttribute("android:title", "@string/" + key + "_title") this.appendChild( ownerDocument.createElement("intent").also { intentNode -> intentNode.setAttribute( "android:targetPackage", targetPackage ) - intentNode.setAttribute("android:data", key) + intentNode.setAttribute("android:data", key + "_intent") intentNode.setAttribute("android:targetClass", targetClass) }) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsBytecodePatch.kt index a6c48c6f8..abbf669b8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsBytecodePatch.kt @@ -7,7 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch +import app.revanced.patches.shared.mapping.ResourceMappingPatch import app.revanced.patches.youtube.utils.integrations.Constants.INTEGRATIONS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH import app.revanced.patches.youtube.utils.integrations.IntegrationsPatch @@ -32,7 +32,7 @@ object SettingsBytecodePatch : BytecodePatch( "$UTILS_PATH/InitializationPatch;" private const val INTEGRATIONS_THEME_METHOD_DESCRIPTOR = - "$INTEGRATIONS_PATH/utils/ThemeHelper;->setTheme(Ljava/lang/Object;)V" + "$INTEGRATIONS_PATH/utils/ThemeUtils;->setTheme(Ljava/lang/Enum;)V" internal lateinit var contexts: BytecodeContext diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt index 3e42afa33..276b145c0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt @@ -3,12 +3,12 @@ package app.revanced.patches.youtube.utils.settings import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch -import app.revanced.patches.shared.patch.settings.AbstractSettingsResourcePatch +import app.revanced.patches.shared.mapping.ResourceMappingPatch +import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch import app.revanced.patches.youtube.utils.integrations.IntegrationsPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference -import app.revanced.patches.youtube.utils.settings.ResourceUtils.addReVancedPreference +import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreferenceFragment import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatus import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusSettings import app.revanced.util.ResourceGroup @@ -60,7 +60,7 @@ import java.util.jar.Manifest ], requiresIntegrations = true ) -@Suppress("unused") +@Suppress("DEPRECATION", "unused") object SettingsPatch : AbstractSettingsResourcePatch( "youtube/settings" ), Closeable { @@ -139,7 +139,7 @@ object SettingsPatch : AbstractSettingsResourcePatch( /** * initialize ReVanced Extended Settings */ - addReVancedPreference("extended_settings") + addPreferenceFragment("revanced_extended_settings") /** * remove ReVanced Extended Settings divider @@ -171,8 +171,8 @@ object SettingsPatch : AbstractSettingsResourcePatch( contexts.addPreference(settingArray) } - internal fun addReVancedPreference(key: String) { - contexts.addReVancedPreference(key) + internal fun addPreferenceFragment(key: String) { + contexts.addPreferenceFragment(key) } internal fun updatePatchStatus(patchTitle: String) { diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/SponsorBlockPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/SponsorBlockPatch.kt index a71daba34..915efeb03 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/SponsorBlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/sponsorblock/SponsorBlockPatch.kt @@ -47,7 +47,7 @@ import app.revanced.util.copyXmlNode ) ] ) -@Suppress("unused") +@Suppress("DEPRECATION", "unused") object SponsorBlockPatch : ResourcePatch() { private val OutlineIcon by booleanPatchOption( key = "OutlineIcon", @@ -64,13 +64,13 @@ object SponsorBlockPatch : ResourcePatch() { arrayOf( ResourceGroup( "layout", - "inline_sponsor_overlay.xml", - "skip_sponsor_button.xml" + "revanced_sb_inline_sponsor_overlay.xml", + "revanced_sb_skip_sponsor_button.xml" ), ResourceGroup( "drawable", - "ns_bg.xml", - "sb_btn_bg.xml" + "revanced_sb_new_segment_background.xml", + "revanced_sb_skip_sponsor_button_background.xml" ) ).forEach { resourceGroup -> context.copyResources("youtube/sponsorblock/shared", resourceGroup) @@ -80,18 +80,18 @@ object SponsorBlockPatch : ResourcePatch() { arrayOf( ResourceGroup( "layout", - "new_segment.xml" + "revanced_sb_new_segment.xml" ), ResourceGroup( "drawable", - "ic_sb_adjust.xml", - "ic_sb_backward.xml", - "ic_sb_compare.xml", - "ic_sb_edit.xml", - "ic_sb_forward.xml", - "ic_sb_logo.xml", - "ic_sb_publish.xml", - "ic_sb_voting.xml" + "revanced_sb_adjust.xml", + "revanced_sb_backward.xml", + "revanced_sb_compare.xml", + "revanced_sb_edit.xml", + "revanced_sb_forward.xml", + "revanced_sb_logo.xml", + "revanced_sb_publish.xml", + "revanced_sb_voting.xml" ) ).forEach { resourceGroup -> context.copyResources("youtube/sponsorblock/outline", resourceGroup) @@ -100,16 +100,16 @@ object SponsorBlockPatch : ResourcePatch() { arrayOf( ResourceGroup( "layout", - "new_segment.xml" + "revanced_sb_new_segment.xml" ), ResourceGroup( "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" ) ).forEach { resourceGroup -> context.copyResources("youtube/sponsorblock/default", resourceGroup) @@ -125,6 +125,9 @@ object SponsorBlockPatch : ResourcePatch() { val targetXmlEditor = context.xmlEditor["res/layout/youtube_controls_layout.xml"] + // voting button id from the voting button view from the youtube_controls_layout.xml host file + val votingButtonId = "@+id/revanced_sb_voting_button" + "RelativeLayout".copyXmlNode( context.xmlEditor[hostingResourceStream], targetXmlEditor @@ -137,13 +140,10 @@ object SponsorBlockPatch : ResourcePatch() { val view = children.item(i) // Replace the attribute for a specific node only - if (!(view.hasAttributes() && view.attributes.getNamedItem("android:id").nodeValue.endsWith( - "player_video_heading" - )) - ) continue - - // voting button id from the voting button view from the youtube_controls_layout.xml host file - val votingButtonId = "@+id/sb_voting_button" + if (!view.hasAttributes()) + continue + if (!view.attributes.getNamedItem("android:id").nodeValue.endsWith("player_video_heading")) + continue view.attributes.getNamedItem("android:layout_toStartOf").nodeValue = votingButtonId @@ -156,7 +156,7 @@ object SponsorBlockPatch : ResourcePatch() { /** * Add ReVanced Extended Settings */ - SettingsPatch.addReVancedPreference("sponsorblock_settings") + SettingsPatch.addPreferenceFragment("revanced_sb_settings") SettingsPatch.updatePatchStatus("SponsorBlock") diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/CustomPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/CustomPlaybackSpeedPatch.kt index 12af5ecae..e44e11c50 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/CustomPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/customspeed/CustomPlaybackSpeedPatch.kt @@ -3,7 +3,7 @@ package app.revanced.patches.youtube.video.customspeed import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.shared.patch.customspeed.AbstractCustomPlaybackSpeedPatch +import app.revanced.patches.shared.customspeed.AbstractCustomPlaybackSpeedPatch import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.OldSpeedLayoutPatch import app.revanced.patches.youtube.utils.integrations.Constants.VIDEO_PATH import app.revanced.patches.youtube.utils.overridespeed.OverrideSpeedHookPatch diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/VideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/VideoQualityPatch.kt index bdd060086..54204c09c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/VideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/VideoQualityPatch.kt @@ -8,6 +8,8 @@ import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.youtube.utils.fingerprints.NewVideoQualityChangedFingerprint +import app.revanced.patches.youtube.utils.fingerprints.VideoQualitySetterFingerprint +import app.revanced.patches.youtube.utils.fix.shortsplayback.ShortsPlaybackPatch import app.revanced.patches.youtube.utils.integrations.Constants.VIDEO_PATH import app.revanced.patches.youtube.utils.overridequality.OverrideQualityHookPatch import app.revanced.patches.youtube.utils.overridespeed.OverrideSpeedHookPatch @@ -16,8 +18,6 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts import app.revanced.patches.youtube.utils.videoid.general.VideoIdPatch import app.revanced.patches.youtube.utils.videoid.withoutshorts.VideoIdWithoutShortsPatch -import app.revanced.patches.youtube.utils.fingerprints.VideoQualitySetterFingerprint -import app.revanced.patches.youtube.utils.fix.shortsplayback.ShortsPlaybackPatch import app.revanced.util.copyXmlNode import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt index 37652dff7..d90b6473c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/PlaybackSpeedPatch.kt @@ -14,8 +14,8 @@ import app.revanced.patches.youtube.utils.integrations.Constants.VIDEO_PATH import app.revanced.patches.youtube.utils.overridespeed.OverrideSpeedHookPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.videocpn.VideoCpnPatch -import app.revanced.patches.youtube.video.speed.fingerprints.PlaybackSpeedInitializeFingerprint import app.revanced.patches.youtube.video.speed.fingerprints.NewPlaybackSpeedChangedFingerprint +import app.revanced.patches.youtube.video.speed.fingerprints.PlaybackSpeedInitializeFingerprint import app.revanced.util.exception import app.revanced.util.updatePatchStatus import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction diff --git a/src/main/kotlin/app/revanced/util/BytecodeUtils.kt b/src/main/kotlin/app/revanced/util/BytecodeUtils.kt index fee2428e2..77b12a012 100644 --- a/src/main/kotlin/app/revanced/util/BytecodeUtils.kt +++ b/src/main/kotlin/app/revanced/util/BytecodeUtils.kt @@ -7,6 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patcher.patch.PatchException import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableField @@ -172,6 +173,33 @@ fun MutableMethod.getTargetIndexReversed(startIndex: Int, opcode: Opcode): Int { return -1 } +fun Method.getTargetIndexWithFieldReferenceName(filedName: String) = implementation?.let { + it.instructions.indexOfFirst { instruction -> + instruction.getReference()?.name == filedName + } +} ?: -1 + +fun MutableMethod.getTargetIndexWithFieldReferenceNameReversed(returnType: String) + = getTargetIndexWithFieldReferenceTypeReversed(implementation!!.instructions.size - 1, returnType) + +fun MutableMethod.getTargetIndexWithFieldReferenceName(startIndex: Int, filedName: String) = + implementation!!.instructions.let { + startIndex + it.subList(startIndex, it.size - 1).indexOfFirst { instruction -> + instruction.getReference()?.name == filedName + } + } + +fun MutableMethod.getTargetIndexWithFieldReferenceNameReversed(startIndex: Int, filedName: String): Int { + for (index in startIndex downTo 0) { + val instruction = getInstruction(index) + if (instruction.getReference()?.name != filedName) + continue + + return index + } + return -1 +} + fun Method.getTargetIndexWithFieldReferenceType(returnType: String) = implementation?.let { it.instructions.indexOfFirst { instruction -> instruction.getReference()?.type == returnType @@ -257,6 +285,9 @@ fun MutableMethod.getTargetIndexWithReferenceReversed(startIndex: Int, reference return -1 } +fun MethodFingerprintResult.getWalkerMethod(context: BytecodeContext, index: Int) = + mutableMethod.getWalkerMethod(context, index) + fun MutableMethod.getWalkerMethod(context: BytecodeContext, index: Int) = context.toMethodWalker(this) .nextMethod(index, true) diff --git a/src/main/kotlin/app/revanced/util/fingerprint/ReferenceFingerprint.kt b/src/main/kotlin/app/revanced/util/fingerprint/ReferenceFingerprint.kt new file mode 100644 index 000000000..69cb6b057 --- /dev/null +++ b/src/main/kotlin/app/revanced/util/fingerprint/ReferenceFingerprint.kt @@ -0,0 +1,34 @@ +package app.revanced.util.fingerprint + +import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.util.containsReferenceInstructionIndex +import com.android.tools.smali.dexlib2.Opcode + +/** + * A fingerprint to resolve methods that contain a specific reference value. + * + * @param returnType The method's return type compared using String.startsWith. + * @param accessFlags The method's exact access flags using values of AccessFlags. + * @param parameters The parameters of the method. Partial matches allowed and follow the same rules as returnType. + * @param opcodes An opcode pattern of the method's instructions. Wildcard or unknown opcodes can be specified by null. + * @param strings A list of the method's strings compared each using String.contains. + * @param reference A supplier for the reference value to check for. + */ +abstract class ReferenceFingerprint( + returnType: String? = null, + accessFlags: Int? = null, + parameters: Iterable? = null, + opcodes: Iterable? = null, + strings: Iterable? = null, + // Has to be a supplier because the fingerprint is created before patches can check reference. + reference: () -> String +) : MethodFingerprint( + returnType = returnType, + accessFlags = accessFlags, + parameters = parameters, + opcodes = opcodes, + strings = strings, + customFingerprint = { methodDef, _ -> + methodDef.containsReferenceInstructionIndex(reference()) + } +) \ No newline at end of file diff --git a/src/main/resources/music/settings/host/values/strings.xml b/src/main/resources/music/settings/host/values/strings.xml index 0b7291802..330fc11e3 100644 --- a/src/main/resources/music/settings/host/values/strings.xml +++ b/src/main/resources/music/settings/host/values/strings.xml @@ -24,8 +24,6 @@ Change start page Configure which components to filter, separated by new lines. Edit custom filter - Invalid custom filter. Filter reset to default. - Invalid custom filter (must be ASCII only): %s. Invalid custom filter: %s. Enables the custom filter to hide layout components. Enable custom filter @@ -91,6 +89,7 @@ Some features may not work properly in the old player layout." Import failed: %s. Settings reset to default. Imported %d settings. + Reset %s is not installed. Please install it. Package name of your installed external downloader app, such as NewPipe or YTDLnis. External downloader package name @@ -220,7 +219,6 @@ Known issue: If one or more music that cannot be played in the playlist, it does Remember repeat state Remembers the state of the shuffle toggle. Remember shuffle state - Reset About Data is provided by the Return YouTube Dislike API. Tap here to learn more. Hides the separator of the like button. @@ -253,65 +251,65 @@ Known issue: If one or more music that cannot be played in the playlist, it does Spoof app version Invalid video url. - Enable SponsorBlock - SponsorBlock is a crowd-sourced system for skipping annoying parts of YouTube videos. + Enable SponsorBlock + SponsorBlock is a crowd-sourced system for skipping annoying parts of YouTube videos. - Show a toast if API is unavailable - Shows a toast if the SponsorBlock API is unavailable. + Show a toast if API is not available + Shows a toast if the SponsorBlock API is unavailable. - Show a toast when skipping automatically - Shows a toast when a segment is automatically skipped. + Show a toast when skipping automatically + Shows a toast when a segment is automatically skipped. - 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. + 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. - 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. - 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. + 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. + 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. - Skipped sponsor. - Skipped self promotion. - Skipped annoying reminder. - Skipped intro. - Skipped intermission. - Skipped intermission. - Skipped outro. - Skipped preview. - Skipped preview. - Skipped recap. - Skipped filler. - Skipped a non-music section. - Skipped multiple segments. - Skip automatically - Disable + Skipped sponsor. + Skipped self promotion. + Skipped annoying reminder. + Skipped intro. + Skipped intermission. + Skipped intermission. + Skipped outro. + Skipped preview. + Skipped preview. + Skipped recap. + Skipped filler. + Skipped a non-music section. + Skipped multiple segments. + Skip automatically + Disable - SponsorBlock is temporarily unavailable. - SponsorBlock is temporarily unavailable (status %d). - SponsorBlock is temporarily unavailable (API timed out). + SponsorBlock is temporarily unavailable. + SponsorBlock is temporarily unavailable (status %d). + SponsorBlock is temporarily unavailable (API timed out). - Color: - Color changed. - Color reset. - Invalid color code. Color reset to default. - Reset color - Data is provided by the SponsorBlock API. Tap here to learn more and see downloads for other platforms. + Color: + Color changed. + Color reset. + Invalid color code. Color reset to default. + Reset color + Data is provided by the SponsorBlock API. Tap here to learn more and see downloads for other platforms. - About + About diff --git a/src/main/resources/music/settings/values-v21/strings.xml b/src/main/resources/music/settings/values-v21/strings.xml index bf7eb97f7..3a7009460 100644 --- a/src/main/resources/music/settings/values-v21/strings.xml +++ b/src/main/resources/music/settings/values-v21/strings.xml @@ -11,5 +11,5 @@ Return YouTube Dislike SponsorBlock - sponsor.ajay.app + sponsor.ajay.app diff --git a/src/main/resources/music/sponsorblock/xml/sponsorblock_prefs.xml b/src/main/resources/music/sponsorblock/xml/sponsorblock_prefs.xml index dfdceb521..dab6789bb 100644 --- a/src/main/resources/music/sponsorblock/xml/sponsorblock_prefs.xml +++ b/src/main/resources/music/sponsorblock/xml/sponsorblock_prefs.xml @@ -1,40 +1,40 @@ - - - - + + + + - - + + - + - + - + - + - + - + - + - - + + diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index e8bfcd235..7a58f35f6 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -82,8 +82,6 @@ Tap here to learn more about DeArrow." Comments Configure which components to filter, separated by new lines. Edit custom filter - Invalid custom filter. Filter reset to default. - Invalid custom filter (must be ASCII only): %s. Invalid custom filter: %s. Custom filter is disabled. Custom filter is enabled. @@ -259,6 +257,7 @@ You tab > View channel > Menu > Settings." Settings were successfully imported. Import settings from saved file. Import settings + Reset Download app Installed Not installed @@ -753,6 +752,7 @@ This does not bypass the age restriction. It just accepts it automatically."Remove viewer discretion dialog Restart to load the layout normally Refresh and restart + About Dislike data is provided by the Return YouTube Dislike API. Tap here to learn more. Like button styled for best appearance. @@ -855,187 +855,195 @@ Known issues: Tool used Video - Enable SponsorBlock - SponsorBlock is a crowd-sourced system for skipping annoying parts of YouTube videos. + 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. + 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. + 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 + 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. + 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. - User id cannot be blank. - 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. - Copy - Your SponsorBlock JSON configuration that can be imported / exported to ReVanced Extended and other SponsorBlock platforms. %s - This includes your private user id. Be sure to share this wisely. - Import / Export settings - Settings imported successfully. - Failed to import: %s. - Failed to export: %s. + 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. + Copy + Import / Export settings + Your SponsorBlock JSON configuration that can be imported / exported to ReVanced Extended 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 + 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. + 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 outro - Skip preview - Skip filler - Skip non-music - Skip segment + 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 outro. - Skipped preview. - Skipped filler. - Skipped a non-music section. - Skipped unsubmitted segment. - Skipped multiple segments. + 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 + Skip automatically + Skip automatically once + Show a skip button + Show in seek bar + Disable - SponsorBlock temporarily not available. - SponsorBlock temporarily not available (status %d). - SponsorBlock temporarily not available (API timed out). + SponsorBlock temporarily not available. + SponsorBlock temporarily not available (status %d). + SponsorBlock temporarily not available (API timed out). - Can\'t submit the segment: %s. - Unable to submit segments (API timed out). - Unable to submit segments (status: %d %s). - Can\'t submit the 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. + 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. - 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. + 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. + 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). - 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 + 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 + Color: + Color changed. + Color reset. + Invalid color code. + Reset color - About - Reset - - Data is provided by the SponsorBlock API. Tap here to learn more and see downloads for other platforms. + Reset + About + Data is provided by the SponsorBlock API. Tap here to learn more and see downloads for other platforms. \ No newline at end of file diff --git a/src/main/resources/youtube/settings/values-v21/strings.xml b/src/main/resources/youtube/settings/values-v21/strings.xml index 2131a9afe..a98e1e47a 100644 --- a/src/main/resources/youtube/settings/values-v21/strings.xml +++ b/src/main/resources/youtube/settings/values-v21/strings.xml @@ -75,19 +75,9 @@ Return YouTube Dislike - SponsorBlock + SponsorBlock Stock - sponsor.ajay.app - @string/sb_skip_button_intro_beginning - @string/sb_skip_button_intro_beginning - @string/sb_skip_button_preview_beginning - @string/sb_skip_button_preview_beginning - @string/sb_skipped_intro_beginning - @string/sb_skipped_intro_beginning - @string/sb_skipped_preview_beginning - @string/sb_skipped_preview_beginning - - @string/aag_widget_loading + sponsor.ajay.app diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 92e277586..a36f4401f 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -31,13 +31,13 @@ + SETTINGS: HIDE_FEED_FLYOUT_PANEL --> @@ -163,7 +163,7 @@ - SETTINGS: QUICK_ACTIONS_COMPONENTS --> + SETTINGS: QUICK_ACTIONS_COMPONENTS --> @@ -179,7 +179,7 @@ + SETTINGS: KEEP_LANDSCAPE_MODE --> @@ -210,7 +210,7 @@ + SETTINGS: HIDE_ACCOUNT_MENU --> @@ -265,7 +265,7 @@ + SETTINGS: SPOOF_APP_VERSION --> @@ -572,7 +572,7 @@ - + PREFERENCE: OVERLAY_BUTTONS --> @@ -582,7 +582,7 @@ PREFERENCE: PLAYER_SETTINGS --> + SETTINGS: CUSTOM_PLAYER_OVERLAY_OPACITY --> @@ -653,7 +653,7 @@ + SETTINGS: CUSTOM_SEEKBAR_COLOR --> @@ -725,10 +725,10 @@ - - - - SETTINGS: SWIPE_CONTROLS --> + + + + SETTINGS: SWIPE_CONTROLS --> @@ -757,7 +757,7 @@ + SETTINGS: CUSTOM_PLAYBACK_SPEED --> diff --git a/src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_adjust.xml b/src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_adjust.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_adjust.xml rename to src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_adjust.xml diff --git a/src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_compare.xml b/src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_compare.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_compare.xml rename to src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_compare.xml diff --git a/src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_edit.xml b/src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_edit.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_edit.xml rename to src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_edit.xml diff --git a/src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_logo.xml b/src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_logo.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_logo.xml rename to src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_logo.xml diff --git a/src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_publish.xml b/src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_publish.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_publish.xml rename to src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_publish.xml diff --git a/src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_voting.xml b/src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_voting.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/default/drawable/ic_sb_voting.xml rename to src/main/resources/youtube/sponsorblock/default/drawable/revanced_sb_voting.xml diff --git a/src/main/resources/youtube/sponsorblock/default/layout/new_segment.xml b/src/main/resources/youtube/sponsorblock/default/layout/revanced_sb_new_segment.xml similarity index 83% rename from src/main/resources/youtube/sponsorblock/default/layout/new_segment.xml rename to src/main/resources/youtube/sponsorblock/default/layout/revanced_sb_new_segment.xml index d82460904..75eb9acfb 100644 --- a/src/main/resources/youtube/sponsorblock/default/layout/new_segment.xml +++ b/src/main/resources/youtube/sponsorblock/default/layout/revanced_sb_new_segment.xml @@ -3,10 +3,10 @@ xmlns:yt="http://schemas.android.com/apk/res-auto"> @@ -15,7 +15,7 @@ android:layout_height="36.0dip"> + 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/youtube/sponsorblock/outline/drawable/ic_sb_adjust.xml b/src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_adjust.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_adjust.xml rename to src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_adjust.xml diff --git a/src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_backward.xml b/src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_backward.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_backward.xml rename to src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_backward.xml diff --git a/src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_compare.xml b/src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_compare.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_compare.xml rename to src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_compare.xml diff --git a/src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_edit.xml b/src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_edit.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_edit.xml rename to src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_edit.xml diff --git a/src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_forward.xml b/src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_forward.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_forward.xml rename to src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_forward.xml diff --git a/src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_logo.xml b/src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_logo.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_logo.xml rename to src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_logo.xml diff --git a/src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_publish.xml b/src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_publish.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_publish.xml rename to src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_publish.xml diff --git a/src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_voting.xml b/src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_voting.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/outline/drawable/ic_sb_voting.xml rename to src/main/resources/youtube/sponsorblock/outline/drawable/revanced_sb_voting.xml diff --git a/src/main/resources/youtube/sponsorblock/outline/layout/new_segment.xml b/src/main/resources/youtube/sponsorblock/outline/layout/revanced_sb_new_segment.xml similarity index 80% rename from src/main/resources/youtube/sponsorblock/outline/layout/new_segment.xml rename to src/main/resources/youtube/sponsorblock/outline/layout/revanced_sb_new_segment.xml index 0b0e15ffa..b5fa848fb 100644 --- a/src/main/resources/youtube/sponsorblock/outline/layout/new_segment.xml +++ b/src/main/resources/youtube/sponsorblock/outline/layout/revanced_sb_new_segment.xml @@ -3,10 +3,10 @@ xmlns:yt="http://schemas.android.com/apk/res-auto"> @@ -15,7 +15,7 @@ android:layout_height="36.0dip"> + android:src="@drawable/revanced_sb_backward" /> + android:src="@drawable/revanced_sb_forward" /> + 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/youtube/sponsorblock/shared/drawable/ns_bg.xml b/src/main/resources/youtube/sponsorblock/shared/drawable/revanced_sb_new_segment_background.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/shared/drawable/ns_bg.xml rename to src/main/resources/youtube/sponsorblock/shared/drawable/revanced_sb_new_segment_background.xml diff --git a/src/main/resources/youtube/sponsorblock/shared/drawable/sb_btn_bg.xml b/src/main/resources/youtube/sponsorblock/shared/drawable/revanced_sb_skip_sponsor_button_background.xml similarity index 100% rename from src/main/resources/youtube/sponsorblock/shared/drawable/sb_btn_bg.xml rename to src/main/resources/youtube/sponsorblock/shared/drawable/revanced_sb_skip_sponsor_button_background.xml diff --git a/src/main/resources/youtube/sponsorblock/shared/host/layout/youtube_controls_layout.xml b/src/main/resources/youtube/sponsorblock/shared/host/layout/youtube_controls_layout.xml index 612a8fe58..59cf92d41 100644 --- a/src/main/resources/youtube/sponsorblock/shared/host/layout/youtube_controls_layout.xml +++ b/src/main/resources/youtube/sponsorblock/shared/host/layout/youtube_controls_layout.xml @@ -1,6 +1,6 @@ + android:src="@drawable/revanced_sb_logo" /> + android:src="@drawable/revanced_sb_voting" /> diff --git a/src/main/resources/youtube/sponsorblock/shared/layout/inline_sponsor_overlay.xml b/src/main/resources/youtube/sponsorblock/shared/layout/revanced_sb_inline_sponsor_overlay.xml similarity index 81% rename from src/main/resources/youtube/sponsorblock/shared/layout/inline_sponsor_overlay.xml rename to src/main/resources/youtube/sponsorblock/shared/layout/revanced_sb_inline_sponsor_overlay.xml index e0ecba392..9f83867b1 100644 --- a/src/main/resources/youtube/sponsorblock/shared/layout/inline_sponsor_overlay.xml +++ b/src/main/resources/youtube/sponsorblock/shared/layout/revanced_sb_inline_sponsor_overlay.xml @@ -2,8 +2,8 @@ \ No newline at end of file