mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-08 02:24:35 +02:00
feat(reddit/hide-navigation-buttons): supports the latest version
This commit is contained in:
parent
dea655e3b6
commit
6b826bd0f7
@ -1,8 +0,0 @@
|
||||
package app.revanced.patches.reddit.layout.navigation.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility([Package("com.reddit.frontpage", arrayOf("2023.16.1"))])
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
internal annotation class NavigationButtonsCompatibility
|
@ -8,12 +8,12 @@ import org.jf.dexlib2.Opcode
|
||||
object BottomNavScreenFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "L", "Z", "L", "L"),
|
||||
parameters = emptyList(),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
Opcode.RETURN_VOID
|
||||
),
|
||||
customFingerprint = { _, classDef -> classDef.type.startsWith("Lcom/reddit/launch/bottomnav/BottomNavScreen\$") }
|
||||
customFingerprint = { methodDef, classDef ->
|
||||
methodDef.name == "onGlobalLayout"
|
||||
&& classDef.type.startsWith("Lcom/reddit/launch/bottomnav/BottomNavScreen\$") }
|
||||
)
|
@ -9,8 +9,8 @@ import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.reddit.layout.navigation.annotations.NavigationButtonsCompatibility
|
||||
import app.revanced.patches.reddit.layout.navigation.patch.NavigationButtonsPatch.Companion.setValue
|
||||
import app.revanced.patches.reddit.utils.annotations.RedditCompatibility
|
||||
import app.revanced.patches.reddit.utils.settings.bytecode.patch.SettingsBytecodePatch.Companion.updateSettingsStatus
|
||||
import app.revanced.patches.reddit.utils.settings.resource.patch.SettingsPatch
|
||||
|
||||
@ -23,7 +23,7 @@ import app.revanced.patches.reddit.utils.settings.resource.patch.SettingsPatch
|
||||
SettingsPatch::class
|
||||
]
|
||||
)
|
||||
@NavigationButtonsCompatibility
|
||||
@RedditCompatibility
|
||||
@Version("0.0.1")
|
||||
class CreateButtonPatch : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
@ -9,8 +9,8 @@ import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.reddit.layout.navigation.annotations.NavigationButtonsCompatibility
|
||||
import app.revanced.patches.reddit.layout.navigation.patch.NavigationButtonsPatch.Companion.setValue
|
||||
import app.revanced.patches.reddit.utils.annotations.RedditCompatibility
|
||||
import app.revanced.patches.reddit.utils.settings.bytecode.patch.SettingsBytecodePatch.Companion.updateSettingsStatus
|
||||
import app.revanced.patches.reddit.utils.settings.resource.patch.SettingsPatch
|
||||
|
||||
@ -23,7 +23,7 @@ import app.revanced.patches.reddit.utils.settings.resource.patch.SettingsPatch
|
||||
SettingsPatch::class
|
||||
]
|
||||
)
|
||||
@NavigationButtonsCompatibility
|
||||
@RedditCompatibility
|
||||
@Version("0.0.1")
|
||||
class DiscoverButtonPatch : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
@ -3,15 +3,12 @@ package app.revanced.patches.reddit.layout.navigation.patch
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.layout.navigation.fingerprints.BottomNavScreenFingerprint
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
|
||||
class NavigationButtonsPatch : BytecodePatch(
|
||||
listOf(BottomNavScreenFingerprint)
|
||||
@ -21,21 +18,12 @@ class NavigationButtonsPatch : BytecodePatch(
|
||||
BottomNavScreenFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val reference =
|
||||
getInstruction<ReferenceInstruction>(startIndex).reference.toString()
|
||||
val targetRegister =
|
||||
getInstruction<FiveRegisterInstruction>(startIndex).registerC
|
||||
|
||||
if (!reference.endsWith("Ljava/util/List;"))
|
||||
return PatchResultError("Invalid reference: $reference")
|
||||
|
||||
val insertIndex = startIndex + 2
|
||||
val insertRegister =
|
||||
getInstruction<OneRegisterInstruction>(startIndex + 1).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$insertRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR
|
||||
move-result-object v$insertRegister
|
||||
"""
|
||||
addInstruction(
|
||||
startIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR"
|
||||
)
|
||||
}
|
||||
} ?: return BottomNavScreenFingerprint.toErrorResult()
|
||||
@ -46,7 +34,7 @@ class NavigationButtonsPatch : BytecodePatch(
|
||||
companion object {
|
||||
const val INTEGRATIONS_METHOD_DESCRIPTOR =
|
||||
"Lapp/revanced/reddit/patches/NavigationButtonsPatch;" +
|
||||
"->hideNavigationButtons(Ljava/util/List;)Ljava/util/List;"
|
||||
"->hideNavigationButtons(Landroid/view/ViewGroup;)V"
|
||||
|
||||
internal fun BytecodeContext.setValue(patch: String) {
|
||||
this.classes.forEach { classDef ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user