From acfda46bce2558df18a6fa562008e058df5ad31e Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 9 Jul 2023 02:07:02 +0200 Subject: [PATCH] fix(youtube/custom-video-speed): don not implicitly depend on `old-video-quality-menu` patch --- .../CreateBottomSheetFingerprint.kt | 4 ++-- .../hook/patch/BottomSheetHookPatch.kt | 2 +- .../patch/BottomSheetHookResourcePatch.kt | 23 +++++++++++++++++++ .../patch/OldVideoQualityMenuResourcePatch.kt | 4 ---- 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookResourcePatch.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/fingerprints/CreateBottomSheetFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/fingerprints/CreateBottomSheetFingerprint.kt index 70c04aa39..6a005a36b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/fingerprints/CreateBottomSheetFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/fingerprints/CreateBottomSheetFingerprint.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.misc.bottomsheet.hook.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.patches.youtube.video.videoqualitymenu.patch.OldVideoQualityMenuResourcePatch +import app.revanced.patches.youtube.misc.bottomsheet.hook.patch.BottomSheetHookResourcePatch import app.revanced.util.patch.LiteralValueFingerprint import org.jf.dexlib2.AccessFlags @@ -9,5 +9,5 @@ object CreateBottomSheetFingerprint : LiteralValueFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = listOf("L"), returnType = "Landroid/widget/LinearLayout;", - literal = OldVideoQualityMenuResourcePatch.bottomSheetMargins + literal = BottomSheetHookResourcePatch.bottomSheetMargins ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt index d72b974ef..73c27a5bd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt @@ -12,7 +12,7 @@ import app.revanced.patches.youtube.misc.bottomsheet.hook.fingerprints.CreateBot import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import org.jf.dexlib2.iface.instruction.OneRegisterInstruction -@DependsOn([IntegrationsPatch::class]) +@DependsOn([IntegrationsPatch::class, BottomSheetHookResourcePatch::class]) class BottomSheetHookPatch : BytecodePatch( listOf(CreateBottomSheetFingerprint) ) { diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookResourcePatch.kt new file mode 100644 index 000000000..e1d7850e5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookResourcePatch.kt @@ -0,0 +1,23 @@ +package app.revanced.patches.youtube.misc.bottomsheet.hook.patch + +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch + +@DependsOn([ResourceMappingPatch::class]) +class BottomSheetHookResourcePatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + bottomSheetMargins = ResourceMappingPatch.resourceMappings.find { it.name == "bottomSheetMargins" }?.id + ?: return PatchResultError("Could not find resource") + + return PatchResultSuccess() + } + + internal companion object { + var bottomSheetMargins = -1L + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuResourcePatch.kt index 52365b74b..c74137a22 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoqualitymenu/patch/OldVideoQualityMenuResourcePatch.kt @@ -29,14 +29,10 @@ class OldVideoQualityMenuResourcePatch : ResourcePatch { // Used for the old type of the video quality menu. videoQualityBottomSheetListFragmentTitle = findResource("video_quality_bottom_sheet_list_fragment_title") - // Used for the new type of the video quality menu. - bottomSheetMargins = findResource("bottom_sheet_margins") - return PatchResultSuccess() } internal companion object { var videoQualityBottomSheetListFragmentTitle = -1L - var bottomSheetMargins = -1L } }