mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat(reddit/hide-navigation-buttons): split into hide-discover-button
, hide-chat-button
, hide-create-button
This commit is contained in:
@ -0,0 +1,38 @@
|
|||||||
|
package app.revanced.patches.reddit.layout.navigation.patch
|
||||||
|
|
||||||
|
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.patch.BytecodePatch
|
||||||
|
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.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
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("hide-chat-button")
|
||||||
|
@Description("Hide chat button at navigation bar.")
|
||||||
|
@DependsOn(
|
||||||
|
[
|
||||||
|
NavigationButtonsPatch::class,
|
||||||
|
SettingsPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@RedditCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class ChatButtonPatch : BytecodePatch() {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
|
updateSettingsStatus("ChatButtons")
|
||||||
|
|
||||||
|
if (SettingsPatch.AddRedditSettings == "true")
|
||||||
|
context.setValue("ChatButtons")
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package app.revanced.patches.reddit.layout.navigation.patch
|
||||||
|
|
||||||
|
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.patch.BytecodePatch
|
||||||
|
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.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
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("hide-create-button")
|
||||||
|
@Description("Hide create button at navigation bar.")
|
||||||
|
@DependsOn(
|
||||||
|
[
|
||||||
|
NavigationButtonsPatch::class,
|
||||||
|
SettingsPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@RedditCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class CreateButtonPatch : BytecodePatch() {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
|
updateSettingsStatus("CreateButtons")
|
||||||
|
|
||||||
|
if (SettingsPatch.AddRedditSettings == "true")
|
||||||
|
context.setValue("CreateButtons")
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package app.revanced.patches.reddit.layout.navigation.patch
|
||||||
|
|
||||||
|
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.patch.BytecodePatch
|
||||||
|
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.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
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("hide-discover-button")
|
||||||
|
@Description("Hide discover button at navigation bar.")
|
||||||
|
@DependsOn(
|
||||||
|
[
|
||||||
|
NavigationButtonsPatch::class,
|
||||||
|
SettingsPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@RedditCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class DiscoverButtonPatch : BytecodePatch() {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
|
updateSettingsStatus("DiscoverButtons")
|
||||||
|
|
||||||
|
if (SettingsPatch.AddRedditSettings == "true")
|
||||||
|
context.setValue("DiscoverButtons")
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
@ -5,25 +5,20 @@ import app.revanced.patcher.annotation.Description
|
|||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
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.addInstructions
|
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.PatchResultError
|
||||||
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.Patch
|
|
||||||
import app.revanced.patches.reddit.layout.navigation.fingerprints.BottomNavScreenFingerprint
|
import app.revanced.patches.reddit.layout.navigation.fingerprints.BottomNavScreenFingerprint
|
||||||
import app.revanced.patches.reddit.utils.annotations.RedditCompatibility
|
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.OneRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
|
||||||
@Patch
|
|
||||||
@Name("hide-navigation-buttons")
|
@Name("hide-navigation-buttons")
|
||||||
@Description("Hide navigation buttons.")
|
@Description("Hide navigation buttons.")
|
||||||
@DependsOn([SettingsPatch::class])
|
|
||||||
@RedditCompatibility
|
@RedditCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class NavigationButtonsPatch : BytecodePatch(
|
class NavigationButtonsPatch : BytecodePatch(
|
||||||
@ -53,14 +48,28 @@ class NavigationButtonsPatch : BytecodePatch(
|
|||||||
}
|
}
|
||||||
} ?: return BottomNavScreenFingerprint.toErrorResult()
|
} ?: return BottomNavScreenFingerprint.toErrorResult()
|
||||||
|
|
||||||
updateSettingsStatus("NavigationButtons")
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
companion object {
|
||||||
private 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(Ljava/util/List;)Ljava/util/List;"
|
||||||
|
|
||||||
|
internal fun BytecodeContext.setValue(patch: String) {
|
||||||
|
this.classes.forEach { classDef ->
|
||||||
|
classDef.methods.forEach { method ->
|
||||||
|
if (classDef.type == "Lapp/revanced/reddit/settingsmenu/SettingsStatus;" && method.name == patch) {
|
||||||
|
val patchStatusMethod =
|
||||||
|
this.proxy(classDef).mutableClass.methods.first { it.name == patch }
|
||||||
|
|
||||||
|
patchStatusMethod.addInstruction(
|
||||||
|
2,
|
||||||
|
"return-void"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user