Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Twitter): Added Customise post font size patch #464

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading