fix(youtube): swipe gesture on home screen

Fixes #610
This commit is contained in:
oSumAtrIX 2022-12-02 04:03:16 +01:00
parent 6a90efcf0d
commit cfe765e991
4 changed files with 59 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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;") }
)

View file

@ -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()
}
}