mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-11 12:04:39 +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(
|
object BottomNavScreenFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("L", "L", "Z", "L", "L"),
|
parameters = emptyList(),
|
||||||
opcodes = listOf(
|
opcodes = listOf(
|
||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.INVOKE_VIRTUAL,
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
Opcode.RETURN_VOID
|
||||||
Opcode.INVOKE_INTERFACE,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT
|
|
||||||
),
|
),
|
||||||
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.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
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.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.bytecode.patch.SettingsBytecodePatch.Companion.updateSettingsStatus
|
||||||
import app.revanced.patches.reddit.utils.settings.resource.patch.SettingsPatch
|
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
|
SettingsPatch::class
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@NavigationButtonsCompatibility
|
@RedditCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class CreateButtonPatch : BytecodePatch() {
|
class CreateButtonPatch : BytecodePatch() {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
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.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
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.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.bytecode.patch.SettingsBytecodePatch.Companion.updateSettingsStatus
|
||||||
import app.revanced.patches.reddit.utils.settings.resource.patch.SettingsPatch
|
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
|
SettingsPatch::class
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@NavigationButtonsCompatibility
|
@RedditCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class DiscoverButtonPatch : BytecodePatch() {
|
class DiscoverButtonPatch : BytecodePatch() {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
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.extensions.toErrorResult
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
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.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultError
|
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patches.reddit.layout.navigation.fingerprints.BottomNavScreenFingerprint
|
import app.revanced.patches.reddit.layout.navigation.fingerprints.BottomNavScreenFingerprint
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
|
||||||
|
|
||||||
class NavigationButtonsPatch : BytecodePatch(
|
class NavigationButtonsPatch : BytecodePatch(
|
||||||
listOf(BottomNavScreenFingerprint)
|
listOf(BottomNavScreenFingerprint)
|
||||||
@ -21,21 +18,12 @@ class NavigationButtonsPatch : BytecodePatch(
|
|||||||
BottomNavScreenFingerprint.result?.let {
|
BottomNavScreenFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||||
val reference =
|
val targetRegister =
|
||||||
getInstruction<ReferenceInstruction>(startIndex).reference.toString()
|
getInstruction<FiveRegisterInstruction>(startIndex).registerC
|
||||||
|
|
||||||
if (!reference.endsWith("Ljava/util/List;"))
|
addInstruction(
|
||||||
return PatchResultError("Invalid reference: $reference")
|
startIndex + 1,
|
||||||
|
"invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR"
|
||||||
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
|
|
||||||
"""
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: return BottomNavScreenFingerprint.toErrorResult()
|
} ?: return BottomNavScreenFingerprint.toErrorResult()
|
||||||
@ -46,7 +34,7 @@ class NavigationButtonsPatch : BytecodePatch(
|
|||||||
companion object {
|
companion object {
|
||||||
const val INTEGRATIONS_METHOD_DESCRIPTOR =
|
const val INTEGRATIONS_METHOD_DESCRIPTOR =
|
||||||
"Lapp/revanced/reddit/patches/NavigationButtonsPatch;" +
|
"Lapp/revanced/reddit/patches/NavigationButtonsPatch;" +
|
||||||
"->hideNavigationButtons(Ljava/util/List;)Ljava/util/List;"
|
"->hideNavigationButtons(Landroid/view/ViewGroup;)V"
|
||||||
|
|
||||||
internal fun BytecodeContext.setValue(patch: String) {
|
internal fun BytecodeContext.setValue(patch: String) {
|
||||||
this.classes.forEach { classDef ->
|
this.classes.forEach { classDef ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user