Skip to content

Commit

Permalink
fix(youtube): swipe gesture on home screen
Browse files Browse the repository at this point in the history
Fixes #610
  • Loading branch information
oSumAtrIX committed Dec 2, 2022
1 parent 6a90efc commit cfe765e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction35c


@Patch
@DependsOn([GeneralAdsResourcePatch::class])
@DependsOn([GeneralAdsResourcePatch::class, VerticalScrollPatch::class])
@Name("general-ads")
@Description("Removes general ads.")
@GeneralAdsCompatibility
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package app.revanced.patches.youtube.misc.fix.verticalscroll.annotations

import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package

@Compatibility(
[
Package("com.google.android.youtube"),
]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class VerticalScrollCompatibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package app.revanced.patches.youtube.misc.fix.verticalscroll.fingerprints


import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode

object CanScrollVerticallyFingerprint : MethodFingerprint(
"Z",
parameters = emptyList(),
opcodes = listOf(Opcode.INSTANCE_OF),
customFingerprint = { methodDef -> methodDef.definingClass.endsWith("SwipeRefreshLayout;") }
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package app.revanced.patches.youtube.misc.fix.verticalscroll.patch

import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.youtube.misc.fix.verticalscroll.annotations.VerticalScrollCompatibility
import app.revanced.patches.youtube.misc.fix.verticalscroll.fingerprints.CanScrollVerticallyFingerprint

@Description("Fixes issues with scrolling on the home screen when the first component is of type EmptyComponent.")
@VerticalScrollCompatibility
@Version("0.0.1")
class VerticalScrollPatch : BytecodePatch(
listOf(CanScrollVerticallyFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
val result = CanScrollVerticallyFingerprint.result ?: return CanScrollVerticallyFingerprint.toErrorResult()

result.mutableMethod.addInstructions(
0,
"""
const/4 v0, 0x0
return v0
"""
)

return PatchResultSuccess()
}
}

0 comments on commit cfe765e

Please sign in to comment.