Skip to content

Commit 1f0b4cd

Browse files
zainarbaniLisoUseInAIKyriosoSumAtrIX
authored
feat(YouTube - Disable precise seeking gesture): Hide "pull up" label that shows up when swiping (#3668)
Co-authored-by: LisoUseInAIKyrios <[email protected]> Co-authored-by: oSumAtrIX <[email protected]>
1 parent 1fd30c1 commit 1f0b4cd

File tree

5 files changed

+80
-34
lines changed

5 files changed

+80
-34
lines changed

src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/DisablePreciseSeekingGesturePatch.kt

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package app.revanced.patches.youtube.interaction.seekbar
22

33
import app.revanced.patcher.data.BytecodeContext
4+
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
45
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
5-
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
66
import app.revanced.patcher.patch.BytecodePatch
77
import app.revanced.patcher.patch.annotation.CompatiblePackage
88
import app.revanced.patcher.patch.annotation.Patch
9+
import app.revanced.patcher.util.smali.ExternalLabel
910
import app.revanced.patches.all.misc.resources.AddResourcesPatch
1011
import 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
1215
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
1316
import 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")
5456
object 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
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package app.revanced.patches.youtube.interaction.seekbar.fingerprints
2+
3+
import app.revanced.patcher.extensions.or
4+
import app.revanced.patcher.fingerprint.MethodFingerprint
5+
import com.android.tools.smali.dexlib2.AccessFlags
6+
7+
/**
8+
* Resolves using the class found in [SwipingUpGestureParentFingerprint].
9+
*/
10+
internal object AllowSwipingUpGestureFingerprint : MethodFingerprint(
11+
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
12+
returnType = "V",
13+
parameters = listOf("L"),
14+
)

src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/fingerprints/IsSwipingUpFingerprint.kt

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package app.revanced.patches.youtube.interaction.seekbar.fingerprints
2+
3+
import app.revanced.util.patch.LiteralValueFingerprint
4+
import com.android.tools.smali.dexlib2.AccessFlags
5+
6+
/**
7+
* Resolves using the class found in [SwipingUpGestureParentFingerprint].
8+
*/
9+
internal object ShowSwipingUpGuideFingerprint : LiteralValueFingerprint(
10+
accessFlags = AccessFlags.FINAL.value,
11+
returnType = "Z",
12+
parameters = emptyList(),
13+
literalSupplier = { 1L }
14+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package app.revanced.patches.youtube.interaction.seekbar.fingerprints
2+
3+
import app.revanced.patcher.extensions.or
4+
import app.revanced.util.patch.LiteralValueFingerprint
5+
import com.android.tools.smali.dexlib2.AccessFlags
6+
7+
internal object SwipingUpGestureParentFingerprint : LiteralValueFingerprint(
8+
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
9+
returnType = "Z",
10+
parameters = listOf(),
11+
literalSupplier = { 45379021 }
12+
)

0 commit comments

Comments
 (0)