11package app.revanced.patches.youtube.interaction.seekbar
22
33import app.revanced.patcher.data.BytecodeContext
4+ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
45import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
5- import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
66import app.revanced.patcher.patch.BytecodePatch
77import app.revanced.patcher.patch.annotation.CompatiblePackage
88import app.revanced.patcher.patch.annotation.Patch
9+ import app.revanced.patcher.util.smali.ExternalLabel
910import app.revanced.patches.all.misc.resources.AddResourcesPatch
1011import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
11- import app.revanced.patches.youtube.interaction.seekbar.fingerprints.IsSwipingUpFingerprint
12+ import app.revanced.patches.youtube.interaction.seekbar.fingerprints.AllowSwipingUpGestureFingerprint
13+ import app.revanced.patches.youtube.interaction.seekbar.fingerprints.ShowSwipingUpGuideFingerprint
14+ import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SwipingUpGestureParentFingerprint
1215import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
1316import app.revanced.patches.youtube.misc.settings.SettingsPatch
14- import app.revanced.util.exception
15- import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
17+ import app.revanced.util.alsoResolve
1618
1719@Patch(
1820 name = " Disable precise seeking gesture" ,
@@ -52,11 +54,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
5254)
5355@Suppress(" unused" )
5456object DisablePreciseSeekingGesturePatch : BytecodePatch(
55- setOf(IsSwipingUpFingerprint )
57+ setOf(SwipingUpGestureParentFingerprint )
5658) {
57- private const val INTEGRATIONS_METHOD_DESCRIPTOR =
58- " Lapp/revanced/integrations/youtube/patches/DisablePreciseSeekingGesturePatch;->" +
59- " disableGesture(Landroid/view/VelocityTracker;Landroid/view/MotionEvent;)V"
59+ private const val INTEGRATIONS_CLASS_DESCRIPTOR =
60+ " Lapp/revanced/integrations/youtube/patches/DisablePreciseSeekingGesturePatch;"
6061
6162 override fun execute (context : BytecodeContext ) {
6263 AddResourcesPatch (this ::class )
@@ -65,19 +66,37 @@ object DisablePreciseSeekingGesturePatch : BytecodePatch(
6566 SwitchPreference (" revanced_disable_precise_seeking_gesture" )
6667 )
6768
68- IsSwipingUpFingerprint .result?.let {
69- val addMovementIndex = it.scanResult.patternScanResult!! .startIndex - 1
69+ AllowSwipingUpGestureFingerprint .alsoResolve(
70+ context,
71+ SwipingUpGestureParentFingerprint
72+ ).mutableMethod.apply {
73+ addInstructionsWithLabels(
74+ 0 ,
75+ """
76+ invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR ->isGestureDisabled()Z
77+ move-result v0
78+ if-eqz v0, :disabled
79+ return-void
80+ """ ,
81+ ExternalLabel (" disabled" , getInstruction(0 ))
82+ )
83+ }
7084
71- it.mutableMethod.apply {
72- val addMovementInstruction = getInstruction<FiveRegisterInstruction >(addMovementIndex)
73- val trackerRegister = addMovementInstruction.registerC
74- val eventRegister = addMovementInstruction.registerD
75-
76- replaceInstruction(
77- addMovementIndex,
78- " invoke-static {v$trackerRegister , v$eventRegister }, $INTEGRATIONS_METHOD_DESCRIPTOR "
79- )
80- }
81- } ? : throw IsSwipingUpFingerprint .exception
85+ ShowSwipingUpGuideFingerprint .alsoResolve(
86+ context,
87+ SwipingUpGestureParentFingerprint
88+ ).mutableMethod.apply {
89+ addInstructionsWithLabels(
90+ 0 ,
91+ """
92+ invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR ->isGestureDisabled()Z
93+ move-result v0
94+ if-eqz v0, :disabled
95+ const/4 v0, 0x0
96+ return v0
97+ """ ,
98+ ExternalLabel (" disabled" , getInstruction(0 ))
99+ )
100+ }
82101 }
83102}
0 commit comments