Skip to content

Commit 68dabfe

Browse files
authored
Merge pull request #464 from swakwork/dev
feat(Twitter): Added `Customise post font size` patch
2 parents f985623 + 89350bb commit 68dabfe

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
}

src/main/resources/twitter/settings/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
<string name="piko_pref_customisation_inlinetabs">Inline bar items to hide</string>
122122
<string name="piko_pref_customisation_reply_sorting">Default reply sorting filter</string>
123123
<string name="piko_pref_customisation_reply_sorting_remember">Previously selected</string>
124+
<string name="piko_pref_customisation_post_font_size">Post font size</string>
124125

125126
<!-- Backup and Restore -->
126127
<string name="piko_title_backup">Backup and restore</string>

0 commit comments

Comments
 (0)