Skip to content

Commit

Permalink
fix(Twitter): Missing download option in immersive view
Browse files Browse the repository at this point in the history
  • Loading branch information
Swakshan committed Jul 12, 2024
1 parent 39ade4b commit 6b0aa2c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package crimera.patches.twitter.premium.unlockdownloads

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
Expand All @@ -17,6 +18,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint
import crimera.patches.twitter.premium.unlockdownloads.fingerprints.DownloadPatchFingerprint
import crimera.patches.twitter.premium.unlockdownloads.fingerprints.FIleDownloaderFingerprint
import crimera.patches.twitter.premium.unlockdownloads.fingerprints.ImmersiveBottomSheetPatchFingerprint
import crimera.patches.twitter.premium.unlockdownloads.fingerprints.MediaEntityFingerprint

// Credits to @iKirby
Expand All @@ -27,7 +29,7 @@ import crimera.patches.twitter.premium.unlockdownloads.fingerprints.MediaEntityF
)
@Suppress("unused")
object DownloadPatch : BytecodePatch(
setOf(DownloadPatchFingerprint,FIleDownloaderFingerprint,MediaEntityFingerprint, SettingsStatusLoadFingerprint)
setOf(DownloadPatchFingerprint,FIleDownloaderFingerprint,MediaEntityFingerprint, SettingsStatusLoadFingerprint,ImmersiveBottomSheetPatchFingerprint)
) {
override fun execute(context: BytecodeContext) {
val result = DownloadPatchFingerprint.result
Expand Down Expand Up @@ -86,7 +88,18 @@ object DownloadPatch : BytecodePatch(
const v$r4, true
""".trimIndent())

//force add download option in immersive bottomsheet
val f4Result = ImmersiveBottomSheetPatchFingerprint.result
?: throw PatchException("ImmersiveBottomSheetPatchFingerprint not found")

val method4 = f4Result.mutableMethod
val instructions4 = method4.getInstructions()

val last_iput_loc = instructions4.last { it.opcode == Opcode.IPUT_BOOLEAN }.location.index
val iput_reg = method4.getInstruction<OneRegisterInstruction>(last_iput_loc).registerA
method4.addInstruction(last_iput_loc,"""
const v${iput_reg}, 0x1
""".trimIndent())

SettingsStatusLoadFingerprint.enableSettings("enableVidDownload")
//end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package crimera.patches.twitter.premium.unlockdownloads.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import app.revanced.patcher.extensions.or

//credits @revanced
object ImmersiveBottomSheetPatchFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
strings = listOf("captionsState")
)

0 comments on commit 6b0aa2c

Please sign in to comment.