From 3cd1c90a293e050294a1aed0cf0430d7c1f8b705 Mon Sep 17 00:00:00 2001 From: Canny <94744045+Canny1913@users.noreply.github.com> Date: Sat, 27 Aug 2022 04:21:53 +0300 Subject: [PATCH] feat: add debug switch (#391) --- .../patch/EnableDebuggingPatch.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/enabledebugging/patch/EnableDebuggingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/enabledebugging/patch/EnableDebuggingPatch.kt index 7eaf2a1d6..9bf03cce1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/enabledebugging/patch/EnableDebuggingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/enabledebugging/patch/EnableDebuggingPatch.kt @@ -6,18 +6,34 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.impl.ResourceData 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.patcher.patch.impl.ResourcePatch 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 @Patch(false) @Name("enable-debugging") +@DependsOn([IntegrationsPatch::class, SettingsPatch::class]) @Description("Enables app debugging by patching the manifest file.") @EnableDebuggingCompatibility @Version("0.0.1") class EnableDebuggingPatch : ResourcePatch() { 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 data.xmlEditor["AndroidManifest.xml"].use { dom -> // get the application node