feat: add debug switch (#391)

This commit is contained in:
Canny 2022-08-27 04:21:53 +03:00 committed by GitHub
parent fe0cdc6e82
commit ee4b7761d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,18 +6,34 @@ import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.impl.ResourceData import app.revanced.patcher.data.impl.ResourceData
import app.revanced.patcher.patch.PatchResult 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.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.impl.ResourcePatch import app.revanced.patcher.patch.impl.ResourcePatch
import app.revanced.patches.youtube.misc.enabledebugging.annotations.EnableDebuggingCompatibility import app.revanced.patches.youtube.misc.enabledebugging.annotations.EnableDebuggingCompatibility
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
import org.w3c.dom.Element import org.w3c.dom.Element
@Patch(false) @Patch(false)
@Name("enable-debugging") @Name("enable-debugging")
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@Description("Enables app debugging by patching the manifest file.") @Description("Enables app debugging by patching the manifest file.")
@EnableDebuggingCompatibility @EnableDebuggingCompatibility
@Version("0.0.1") @Version("0.0.1")
class EnableDebuggingPatch : ResourcePatch() { class EnableDebuggingPatch : ResourcePatch() {
override fun execute(data: ResourceData): PatchResult { override fun execute(data: ResourceData): PatchResult {
SettingsPatch.PreferenceScreen.MISC.addPreferences(
SwitchPreference(
"revanced_debug_enabled",
StringResource("revanced_debug_title", "Debug"),
false,
StringResource("revanced_debug_on", "Debug logs are enabled"),
StringResource("revanced_debug_off", "Debug logs are disabled")
)
)
// create an xml editor instance // create an xml editor instance
data.xmlEditor["AndroidManifest.xml"].use { dom -> data.xmlEditor["AndroidManifest.xml"].use { dom ->
// get the application node // get the application node