Skip to content

Commit

Permalink
Merge pull request #33 from Swakshan/dev
Browse files Browse the repository at this point in the history
Mod Settings Updates
  • Loading branch information
crimera committed Mar 17, 2024
2 parents 9f91965 + 86ea20f commit 0b27498
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import crimera.patches.twitter.interaction.downloads.changedirectory.fingerprints.SetDownloadDestinationFingerprint
import crimera.patches.twitter.misc.settings.SettingsPatch
import crimera.patches.twitter.misc.settings.SettingsPatch.UTILS_DESCRIPTOR
import crimera.patches.twitter.misc.settings.SettingsPatch.PREF_DESCRIPTOR
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint

@Patch(
Expand All @@ -27,9 +27,9 @@ object ChangeDownloadDirPatch: BytecodePatch(
setOf(SetDownloadDestinationFingerprint, SettingsStatusLoadFingerprint)
) {
private const val GETFOLDER_DESCRIPTOR =
"invoke-static {p1}, $UTILS_DESCRIPTOR;->getVideoFolder(Ljava/lang/String;)Ljava/lang/String;"
"invoke-static {p1}, $PREF_DESCRIPTOR;->getVideoFolder(Ljava/lang/String;)Ljava/lang/String;"
private const val PUBLICFOLDER_DESCRIPTOR =
"invoke-static {}, $UTILS_DESCRIPTOR;->getPublicFolder()Ljava/lang/String;"
"invoke-static {}, $PREF_DESCRIPTOR;->getPublicFolder()Ljava/lang/String;"

override fun execute(context: BytecodeContext) {
val result = SetDownloadDestinationFingerprint.result
Expand All @@ -51,7 +51,7 @@ object ChangeDownloadDirPatch: BytecodePatch(

SettingsStatusLoadFingerprint.result!!.mutableMethod.addInstruction(
0,
"invoke-static {}, Lapp/revanced/integrations/twitter/settings/SettingsStatus;->enableDownload()V"
"${SettingsPatch.SSTS_DESCRIPTOR}->enableDownloadFolder()V"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFing
@Patch(
name = "Disable chirp font",
use = false,
dependencies = [SettingsPatch::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")]
)
@Suppress("unused")
object DisableChirpFontPatch: BytecodePatch(
setOf(ChirpFontFingerprint)
) {
private const val CHIRP_FONT_DESCRIPTOR =
"invoke-static {}, ${SettingsPatch.UTILS_DESCRIPTOR};->isChirpFontEnabled()Z"
"invoke-static {}, ${SettingsPatch.PREF_DESCRIPTOR};->isChirpFontEnabled()Z"

override fun execute(context: BytecodeContext) {
ChirpFontFingerprint.result!!.mutableMethod.addInstructions(
Expand All @@ -34,7 +35,7 @@ object DisableChirpFontPatch: BytecodePatch(

SettingsStatusLoadFingerprint.result!!.mutableMethod.addInstruction(
0,
"invoke-static {}, Lapp/revanced/integrations/twitter/settings/SettingsStatus;->enableFont()V"
"${SettingsPatch.SSTS_DESCRIPTOR}->enableFont()V"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ object SettingsPatch : BytecodePatch(
) {
private const val INTEGRATIONS_PACKAGE = "Lapp/revanced/integrations/twitter"
const val UTILS_DESCRIPTOR = "$INTEGRATIONS_PACKAGE/Utils"
const val PREF_DESCRIPTOR = "$INTEGRATIONS_PACKAGE/Pref"
private const val ADD_PREF_DESCRIPTOR = "$UTILS_DESCRIPTOR;->addPref([Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;"
const val SSTS_DESCRIPTOR = "invoke-static {}, $INTEGRATIONS_PACKAGE/settings/SettingsStatus;"
private const val START_ACTIVITY_DESCRIPTOR =
"invoke-static {}, $UTILS_DESCRIPTOR;->startActivity()V"
"invoke-static {}, $UTILS_DESCRIPTOR;->startSettingsActivity()V"

override fun execute(context: BytecodeContext) {
val result = SettingsFingerprint.result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import crimera.patches.twitter.timeline.banner.fingerprints.HideBannerFingerprin
@Patch(
name = "Hide Banner",
description = "Hide new post banner",
dependencies = [SettingsPatch::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
use = false
)
Expand All @@ -35,7 +36,7 @@ object HideBannerPatch : BytecodePatch(

// TODO: make the register dynamic
val HIDE_BANNER_DESCRIPTOR =
"invoke-static {}, ${SettingsPatch.UTILS_DESCRIPTOR};->hideBanner()Z"
"invoke-static {}, ${SettingsPatch.PREF_DESCRIPTOR};->hideBanner()Z"

method.addInstructions(loc, """
$HIDE_BANNER_DESCRIPTOR
Expand All @@ -44,7 +45,7 @@ object HideBannerPatch : BytecodePatch(

SettingsStatusLoadFingerprint.result!!.mutableMethod.addInstruction(
0,
"invoke-static {}, Lapp/revanced/integrations/twitter/settings/SettingsStatus;->hideBanner()V"
"${SettingsPatch.SSTS_DESCRIPTOR}->hideBanner()V"
)

// method.removeInstruction(loc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,32 @@ package crimera.patches.twitter.timeline.foryou

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import crimera.patches.twitter.foryou.fingerprints.HideForYouFingerprint
import crimera.patches.twitter.misc.settings.SettingsPatch
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint

@Patch(
name = "Hide For You",
description = "Hides For You tab from timeline",
dependencies = [SettingsPatch::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
use = false
)
@Suppress("unused")
object HideForYouPatch : BytecodePatch(
setOf(HideForYouFingerprint)
setOf(HideForYouFingerprint,SettingsStatusLoadFingerprint)
){

override fun execute(context: BytecodeContext) {
val result = HideForYouFingerprint.result
?: throw PatchException("Fingerprint not found")
Expand All @@ -32,9 +38,16 @@ object HideForYouPatch : BytecodePatch(

val check = instructions.first { it.opcode == Opcode.CONST_16 }.location.index
val reg = method.getInstruction<OneRegisterInstruction>(check).registerA

method.addInstruction(check+1,"""
const/16 v$reg, 0x22
method.removeInstruction(check)
method.addInstructionsWithLabels(check,"""
invoke-static {}, ${SettingsPatch.PREF_DESCRIPTOR};->hideForYou()I
move-result v$reg
""".trimIndent())

SettingsStatusLoadFingerprint.result!!.mutableMethod.addInstruction(
0,
"${SettingsPatch.SSTS_DESCRIPTOR}->hideForYou()V"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import crimera.patches.twitter.timeline.live.fingerprints.HideLiveThreadsFingerp

@Patch(
name = "Hide Live Threads",
dependencies = [SettingsPatch::class],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
use = false
)
Expand All @@ -35,7 +36,7 @@ object HideLiveThreadsPatch : BytecodePatch(
val reg = method.getInstruction<OneRegisterInstruction>(loc).registerA

val HIDE_LIVE_DESCRIPTOR =
"invoke-static {v$reg}, ${SettingsPatch.UTILS_DESCRIPTOR};->liveThread(Ljava/util/ArrayList;)Ljava/util/ArrayList;"
"invoke-static {v$reg}, ${SettingsPatch.PREF_DESCRIPTOR};->liveThread(Ljava/util/ArrayList;)Ljava/util/ArrayList;"

method.addInstructions(loc+1,"""
$HIDE_LIVE_DESCRIPTOR
Expand All @@ -44,7 +45,7 @@ object HideLiveThreadsPatch : BytecodePatch(

SettingsStatusLoadFingerprint.result!!.mutableMethod.addInstruction(
0,
"invoke-static {}, Lapp/revanced/integrations/twitter/settings/SettingsStatus;->hideLiveThreads()V"
"${SettingsPatch.SSTS_DESCRIPTOR}->hideLiveThreads()V"
)
}
}

0 comments on commit 0b27498

Please sign in to comment.