From 3fa8af9fe534b59ad093c36f1927f56f549a330d Mon Sep 17 00:00:00 2001 From: Zain Date: Sun, 29 Sep 2024 07:32:17 +0700 Subject: [PATCH] feat(YouTube - Disable precise seeking gesture): Hide "pull up" label that shows up when swiping (#3668) Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Co-authored-by: oSumAtrIX --- .../DisablePreciseSeekingGesturePatch.kt | 61 ++++++++++++------- .../AllowSwipingUpGestureFingerprint.kt | 14 +++++ .../fingerprints/IsSwipingUpFingerprint.kt | 13 ---- .../ShowSwipingUpGuideFingerprint.kt | 14 +++++ .../SwipingUpGestureParentFingerprint.kt | 12 ++++ 5 files changed, 80 insertions(+), 34 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AllowSwipingUpGestureFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/IsSwipingUpFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/ShowSwipingUpGuideFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SwipingUpGestureParentFingerprint.kt 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 4923a6c4e..dd3a07ae7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt @@ -1,18 +1,20 @@ package app.revanced.patches.youtube.interaction.seekbar import app.revanced.patcher.data.BytecodeContext +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.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.misc.settings.preference.SwitchPreference -import app.revanced.patches.youtube.interaction.seekbar.fingerprints.IsSwipingUpFingerprint +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.util.exception -import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction +import app.revanced.util.alsoResolve @Patch( name = "Disable precise seeking gesture", @@ -52,11 +54,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction ) @Suppress("unused") object DisablePreciseSeekingGesturePatch : BytecodePatch( - setOf(IsSwipingUpFingerprint) + setOf(SwipingUpGestureParentFingerprint) ) { - private const val INTEGRATIONS_METHOD_DESCRIPTOR = - "Lapp/revanced/integrations/youtube/patches/DisablePreciseSeekingGesturePatch;->" + - "disableGesture(Landroid/view/VelocityTracker;Landroid/view/MotionEvent;)V" + private const val INTEGRATIONS_CLASS_DESCRIPTOR = + "Lapp/revanced/integrations/youtube/patches/DisablePreciseSeekingGesturePatch;" override fun execute(context: BytecodeContext) { AddResourcesPatch(this::class) @@ -65,19 +66,37 @@ object DisablePreciseSeekingGesturePatch : BytecodePatch( SwitchPreference("revanced_disable_precise_seeking_gesture") ) - IsSwipingUpFingerprint.result?.let { - val addMovementIndex = it.scanResult.patternScanResult!!.startIndex - 1 + AllowSwipingUpGestureFingerprint.alsoResolve( + context, + SwipingUpGestureParentFingerprint + ).mutableMethod.apply { + addInstructionsWithLabels( + 0, + """ + invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->isGestureDisabled()Z + move-result v0 + if-eqz v0, :disabled + return-void + """, + ExternalLabel("disabled", getInstruction(0)) + ) + } - it.mutableMethod.apply { - val addMovementInstruction = getInstruction(addMovementIndex) - val trackerRegister = addMovementInstruction.registerC - val eventRegister = addMovementInstruction.registerD - - replaceInstruction( - addMovementIndex, - "invoke-static {v$trackerRegister, v$eventRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR" - ) - } - } ?: throw IsSwipingUpFingerprint.exception + ShowSwipingUpGuideFingerprint.alsoResolve( + context, + SwipingUpGestureParentFingerprint + ).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)) + ) + } } } \ 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 new file mode 100644 index 000000000..1f92a7275 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/AllowSwipingUpGestureFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.youtube.interaction.seekbar.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +/** + * Resolves using the class found in [SwipingUpGestureParentFingerprint]. + */ +internal object AllowSwipingUpGestureFingerprint : MethodFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "V", + parameters = listOf("L"), +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/IsSwipingUpFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/IsSwipingUpFingerprint.kt deleted file mode 100644 index 3029925ad..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/IsSwipingUpFingerprint.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.revanced.patches.youtube.interaction.seekbar.fingerprints - -import app.revanced.patcher.fingerprint.MethodFingerprint -import com.android.tools.smali.dexlib2.Opcode - -internal object IsSwipingUpFingerprint : MethodFingerprint( - returnType = "Z", - parameters = listOf("Landroid/view/MotionEvent;", "J"), - opcodes = listOf( - Opcode.SGET_OBJECT, - Opcode.IGET_OBJECT - ) -) \ 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 new file mode 100644 index 000000000..5a8ac9eed --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/ShowSwipingUpGuideFingerprint.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.youtube.interaction.seekbar.fingerprints + +import app.revanced.util.patch.LiteralValueFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +/** + * Resolves using the class found in [SwipingUpGestureParentFingerprint]. + */ +internal object ShowSwipingUpGuideFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.FINAL.value, + returnType = "Z", + parameters = emptyList(), + literalSupplier = { 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 000000000..cb33e72a2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SwipingUpGestureParentFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.youtube.interaction.seekbar.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.util.patch.LiteralValueFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +internal object SwipingUpGestureParentFingerprint : LiteralValueFingerprint( + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + returnType = "Z", + parameters = listOf(), + literalSupplier = { 45379021 } +) \ No newline at end of file