Skip to content

Commit

Permalink
feat(YouTube - Disable precise seeking gesture): Hide "pull up" label…
Browse files Browse the repository at this point in the history
… that shows up when swiping (#3668)

Co-authored-by: LisoUseInAIKyrios <[email protected]>
Co-authored-by: oSumAtrIX <[email protected]>
  • Loading branch information
3 people authored Sep 29, 2024
1 parent 84f6d12 commit 3fa8af9
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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)
Expand All @@ -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<FiveRegisterInstruction>(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))
)
}
}
}
Original file line number Diff line number Diff line change
@@ -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"),
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 }
)
Original file line number Diff line number Diff line change
@@ -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 }
)

0 comments on commit 3fa8af9

Please sign in to comment.