mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-07 18:14:36 +02:00
feat(reddit): add hide-navigation-buttons
patch
This commit is contained in:
parent
a1800b8632
commit
921cb552e5
@ -0,0 +1,19 @@
|
||||
package app.revanced.patches.reddit.layout.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object BottomNavScreenFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "L", "Z", "L", "L"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
),
|
||||
customFingerprint = { _, classDef -> classDef.type.startsWith("Lcom/reddit/launch/bottomnav/BottomNavScreen\$") }
|
||||
)
|
@ -0,0 +1,64 @@
|
||||
package app.revanced.patches.reddit.layout.navigation.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
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.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.reddit.layout.navigation.fingerprints.BottomNavScreenFingerprint
|
||||
import app.revanced.patches.reddit.utils.annotations.RedditCompatibility
|
||||
import app.revanced.patches.reddit.utils.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.reddit.utils.settings.bytecode.patch.SettingsPatch.Companion.updateSettingsStatus
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
|
||||
@Patch
|
||||
@Name("hide-navigation-buttons")
|
||||
@Description("Hide navigation buttons.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@RedditCompatibility
|
||||
@Version("0.0.1")
|
||||
class NavigationButtonsPatch : BytecodePatch(
|
||||
listOf(BottomNavScreenFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
BottomNavScreenFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val reference = getInstruction<ReferenceInstruction>(startIndex).reference.toString()
|
||||
|
||||
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
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return BottomNavScreenFingerprint.toErrorResult()
|
||||
|
||||
updateSettingsStatus("NavigationButtons")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val INTEGRATIONS_METHOD_DESCRIPTOR =
|
||||
"Lapp/revanced/reddit/patches/NavigationButtonsPatch;" +
|
||||
"->hideNavigationButtons(Ljava/util/List;)Ljava/util/List;"
|
||||
}
|
||||
}
|
@ -3,6 +3,12 @@
|
||||
<string name="revanced_disable_screenshot_popup_summary">Disables the popup that shows up when taking a screenshot</string>
|
||||
<string name="revanced_disable_screenshot_popup_title">Disable screenshot popup</string>
|
||||
<string name="revanced_extended_settings_title">ReVanced Extended</string>
|
||||
<string name="revanced_hide_chat_button_summary">Hide chat button in navigation</string>
|
||||
<string name="revanced_hide_chat_button_title">Hide chat button</string>
|
||||
<string name="revanced_hide_create_button_summary">Hide create button in navigation</string>
|
||||
<string name="revanced_hide_create_button_title">Hide create button</string>
|
||||
<string name="revanced_hide_discover_button_summary">Hide discover button in navigation</string>
|
||||
<string name="revanced_hide_discover_button_title">Hide discover button</string>
|
||||
<string name="revanced_open_links_directly_summary">Skips over redirection URLs to external links</string>
|
||||
<string name="revanced_open_links_directly_title">Open links directly</string>
|
||||
<string name="revanced_open_links_externally_summary">Open links outside of the app directly in your browser</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user