generated from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Twitter): Added
Customise post font size
patch
- Loading branch information
swakwork
committed
Nov 11, 2024
1 parent
5cde246
commit ea608e0
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/main/kotlin/crimera/patches/twitter/misc/customize/postFontSize/CustomizePostFontSize.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package crimera.patches.twitter.misc.customize.postFontSize | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
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.AccessFlags | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import crimera.patches.twitter.misc.settings.SettingsPatch | ||
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint | ||
|
||
object CustomizePostFontSizeFingerprint : MethodFingerprint( | ||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, | ||
customFingerprint = { methodDef, _ -> | ||
methodDef.definingClass.endsWith("TextContentView;") | ||
}, | ||
) | ||
|
||
@Patch( | ||
name = "Customise post font size", | ||
description = "", | ||
dependencies = [SettingsPatch::class], | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
use = true, | ||
) | ||
object CustomizePostFontSize : BytecodePatch( | ||
setOf(CustomizePostFontSizeFingerprint, SettingsStatusLoadFingerprint), | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
val result1 = | ||
CustomizePostFontSizeFingerprint.result | ||
?: throw PatchException("CustomizePostFontSizeFingerprint not found") | ||
|
||
val method1 = result1.mutableMethod | ||
|
||
val index1 = | ||
method1 | ||
.getInstructions() | ||
.last { it.opcode == Opcode.MOVE_RESULT } | ||
.location.index | ||
method1.addInstruction(index1 + 1, "sget p1, ${SettingsPatch.PREF_DESCRIPTOR};->POST_FONT_SIZE:F") | ||
|
||
SettingsStatusLoadFingerprint.enableSettings("customPostFontSize") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters