diff --git a/patches/api/patches.api b/patches/api/patches.api index 4c2586c82..a7c4c94da 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -1,3 +1,7 @@ +public final class DisableReelsScrollingPatchKt { + public static final fun getDisableReelsScrollingPatch ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/all/misc/activity/exportall/ExportAllActivitiesPatchKt { public static final fun getExportAllActivitiesPatch ()Lapp/revanced/patcher/patch/ResourcePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/reels/DisableReelsScrollingPatch.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/reels/DisableReelsScrollingPatch.kt new file mode 100644 index 000000000..acb8235fb --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/reels/DisableReelsScrollingPatch.kt @@ -0,0 +1,34 @@ +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patches.instagram.reels.clipsSwipeRefreshLayoutOnInterceptTouchEventFingerprint +import app.revanced.patches.instagram.reels.clipsViewPagerImplGetViewAtIndexFingerprint +import app.revanced.util.returnEarly + +@Suppress("unused") +val disableReelsScrollingPatch = bytecodePatch( + name = "Disable Reels scrolling", + description = "Disables the endless scrolling behavior in Instagram Reels, preventing swiping to the next Reel. " + + "Note: On a clean install, the 'Tip' animation may appear but will stop on its own after a few seconds.", + use = true +) { + compatibleWith("com.instagram.android") + + execute { + val viewPagerField = clipsViewPagerImplGetViewAtIndexFingerprint.classDef.fields.first { + it.type == "Landroidx/viewpager2/widget/ViewPager2;" + } + + // Disable user input on the ViewPager2 to prevent scrolling. + clipsViewPagerImplGetViewAtIndexFingerprint.method.addInstructions( + 0, + """ + iget-object v0, p0, $viewPagerField + const/4 v1, 0x0 + invoke-virtual { v0, v1 }, Landroidx/viewpager2/widget/ViewPager2;->setUserInputEnabled(Z)V + """ + ) + + // Return false in onInterceptTouchEvent to disable pull-to-refresh. + clipsSwipeRefreshLayoutOnInterceptTouchEventFingerprint.method.returnEarly(false) + } +} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/reels/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/reels/Fingerprints.kt new file mode 100644 index 000000000..d0b6b6266 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/reels/Fingerprints.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.instagram.reels + +import app.revanced.patcher.fingerprint + +internal val clipsViewPagerImplGetViewAtIndexFingerprint = fingerprint { + strings("ClipsViewPagerImpl_getViewAtIndex") +} + +internal val clipsSwipeRefreshLayoutOnInterceptTouchEventFingerprint = fingerprint { + parameters("Landroid/view/MotionEvent;") + custom { _, classDef -> classDef.type == "Linstagram/features/clips/viewer/ui/ClipsSwipeRefreshLayout;" } +} +