Skip to content

Commit

Permalink
feat(Twitter): Added Customise post font size patch
Browse files Browse the repository at this point in the history
  • Loading branch information
swakwork committed Nov 11, 2024
1 parent 5cde246 commit ea608e0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
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")
}
}
1 change: 1 addition & 0 deletions src/main/resources/twitter/settings/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
<string name="piko_pref_customisation_inlinetabs">Inline bar items to hide</string>
<string name="piko_pref_customisation_reply_sorting">Default reply sorting filter</string>
<string name="piko_pref_customisation_reply_sorting_remember">Previously selected</string>
<string name="piko_pref_customisation_post_font_size">Post font size</string>

<!-- Backup and Restore -->
<string name="piko_title_backup">Backup and restore</string>
Expand Down

0 comments on commit ea608e0

Please sign in to comment.