|
| 1 | +package crimera.patches.twitter.misc.customize.postFontSize |
| 2 | + |
| 3 | +import app.revanced.patcher.data.BytecodeContext |
| 4 | +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction |
| 5 | +import app.revanced.patcher.extensions.InstructionExtensions.getInstructions |
| 6 | +import app.revanced.patcher.extensions.or |
| 7 | +import app.revanced.patcher.fingerprint.MethodFingerprint |
| 8 | +import app.revanced.patcher.patch.BytecodePatch |
| 9 | +import app.revanced.patcher.patch.PatchException |
| 10 | +import app.revanced.patcher.patch.annotation.CompatiblePackage |
| 11 | +import app.revanced.patcher.patch.annotation.Patch |
| 12 | +import com.android.tools.smali.dexlib2.AccessFlags |
| 13 | +import com.android.tools.smali.dexlib2.Opcode |
| 14 | +import crimera.patches.twitter.misc.settings.SettingsPatch |
| 15 | +import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint |
| 16 | + |
| 17 | +object CustomizePostFontSizeFingerprint : MethodFingerprint( |
| 18 | + accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, |
| 19 | + customFingerprint = { methodDef, _ -> |
| 20 | + methodDef.definingClass.endsWith("TextContentView;") |
| 21 | + }, |
| 22 | +) |
| 23 | + |
| 24 | +@Patch( |
| 25 | + name = "Customise post font size", |
| 26 | + description = "", |
| 27 | + dependencies = [SettingsPatch::class], |
| 28 | + compatiblePackages = [CompatiblePackage("com.twitter.android")], |
| 29 | + use = true, |
| 30 | +) |
| 31 | +object CustomizePostFontSize : BytecodePatch( |
| 32 | + setOf(CustomizePostFontSizeFingerprint, SettingsStatusLoadFingerprint), |
| 33 | +) { |
| 34 | + override fun execute(context: BytecodeContext) { |
| 35 | + val result1 = |
| 36 | + CustomizePostFontSizeFingerprint.result |
| 37 | + ?: throw PatchException("CustomizePostFontSizeFingerprint not found") |
| 38 | + |
| 39 | + val method1 = result1.mutableMethod |
| 40 | + |
| 41 | + val index1 = |
| 42 | + method1 |
| 43 | + .getInstructions() |
| 44 | + .last { it.opcode == Opcode.MOVE_RESULT } |
| 45 | + .location.index |
| 46 | + method1.addInstruction(index1 + 1, "sget p1, ${SettingsPatch.PREF_DESCRIPTOR};->POST_FONT_SIZE:F") |
| 47 | + |
| 48 | + SettingsStatusLoadFingerprint.enableSettings("customPostFontSize") |
| 49 | + } |
| 50 | +} |
0 commit comments