diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt index 05cec5f593..30443148a9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt @@ -10,9 +10,11 @@ import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.interaction.seekbar.fingerprints.AllowSwipingUpGestureFingerprint import app.revanced.patches.youtube.interaction.seekbar.fingerprints.ShowSwipingUpGuideFingerprint +import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SwipingUpGestureParentFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.util.alsoResolve import app.revanced.util.resultOrThrow @Patch( @@ -53,7 +55,7 @@ import app.revanced.util.resultOrThrow ) @Suppress("unused") object DisablePreciseSeekingGesturePatch : BytecodePatch( - setOf(AllowSwipingUpGestureFingerprint, ShowSwipingUpGuideFingerprint) + setOf(SwipingUpGestureParentFingerprint) ) { private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/DisablePreciseSeekingGesturePatch;" @@ -65,29 +67,37 @@ object DisablePreciseSeekingGesturePatch : BytecodePatch( SwitchPreference("revanced_disable_precise_seeking_gesture") ) - AllowSwipingUpGestureFingerprint.resultOrThrow().mutableMethod.apply { - addInstructionsWithLabels( - 0, - """ - invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->isGestureDisabled()Z - move-result v0 - if-eqz v0, :disabled - return-void - """, ExternalLabel("disabled", getInstruction(0)) - ) - } + with(SwipingUpGestureParentFingerprint.resultOrThrow()) { + val allowSwipingUpGestureMethod = AllowSwipingUpGestureFingerprint + .alsoResolve(context, SwipingUpGestureParentFingerprint).mutableMethod + + val showSwipingUpGuideMethod = ShowSwipingUpGuideFingerprint + .alsoResolve(context, SwipingUpGestureParentFingerprint).mutableMethod + + allowSwipingUpGestureMethod.apply { + addInstructionsWithLabels( + 0, + """ + invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->isGestureDisabled()Z + move-result v0 + if-eqz v0, :disabled + return-void + """, ExternalLabel("disabled", getInstruction(0)) + ) + } - ShowSwipingUpGuideFingerprint.resultOrThrow().mutableMethod.apply { - addInstructionsWithLabels( - 0, - """ - invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->isGestureDisabled()Z - move-result v0 - if-eqz v0, :disabled - const/4 v0, 0x0 - return v0 - """, ExternalLabel("disabled", getInstruction(0)) - ) + showSwipingUpGuideMethod.apply { + addInstructionsWithLabels( + 0, + """ + invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->isGestureDisabled()Z + move-result v0 + if-eqz v0, :disabled + const/4 v0, 0x0 + return v0 + """, ExternalLabel("disabled", getInstruction(0)) + ) + } } } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AllowSwipingUpGestureFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AllowSwipingUpGestureFingerprint.kt index c69b4fdf31..c678208d93 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AllowSwipingUpGestureFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AllowSwipingUpGestureFingerprint.kt @@ -2,16 +2,10 @@ package app.revanced.patches.youtube.interaction.seekbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint -import app.revanced.util.containsWideLiteralInstructionValue import com.android.tools.smali.dexlib2.AccessFlags internal object AllowSwipingUpGestureFingerprint : MethodFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, returnType = "V", parameters = listOf("L"), - customFingerprint = { _, classDef -> - classDef.methods.any { method -> - method.containsWideLiteralInstructionValue(45379021L) - } - } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/ShowSwipingUpGuideFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/ShowSwipingUpGuideFingerprint.kt index 168362fe3b..d03b2487b2 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/ShowSwipingUpGuideFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/ShowSwipingUpGuideFingerprint.kt @@ -8,9 +8,7 @@ internal object ShowSwipingUpGuideFingerprint : MethodFingerprint( accessFlags = AccessFlags.FINAL.value, returnType = "Z", parameters = emptyList(), - customFingerprint = { methodDef, classDef -> - classDef.methods.any { method -> - method.containsWideLiteralInstructionValue(45379021L) - } && methodDef.containsWideLiteralInstructionValue(1L) + customFingerprint = { methodDef, _ -> + methodDef.containsWideLiteralInstructionValue(1L) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SwipingUpGestureParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SwipingUpGestureParentFingerprint.kt new file mode 100644 index 0000000000..56b6490c11 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SwipingUpGestureParentFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.youtube.interaction.seekbar.fingerprints + +import app.revanced.util.patch.LiteralValueFingerprint + +internal object SwipingUpGestureParentFingerprint : LiteralValueFingerprint( + literalSupplier = { 45379021 } +) \ No newline at end of file