From 3964a36bb690006a43b6916b458abb1541fd59ef Mon Sep 17 00:00:00 2001 From: inotia00 Date: Mon, 10 Apr 2023 00:54:41 +0900 Subject: [PATCH] add `hide-double-tap-overlay-filter` patch https://github.com/inotia00/ReVanced_Extended/issues/258 --- .../patch/DoubleTapOverlayBackgroundPatch.kt | 46 +++++++++++++++++++ .../youtube/settings/xml/revanced_prefs.xml | 1 + 2 files changed, 47 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/etc/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/etc/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt new file mode 100644 index 000000000..d16a4a5f6 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/etc/doubletapbackground/patch/DoubleTapOverlayBackgroundPatch.kt @@ -0,0 +1,46 @@ +package app.revanced.patches.youtube.layout.etc.doubletapbackground.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.ResourcePatch +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch + +@Patch(false) +@Name("hide-double-tap-overlay-filter") +@Description("Remove the double tap dark filter layer.") +@DependsOn([SettingsPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class DoubleTapOverlayBackgroundPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + context.xmlEditor[RESOURCE_FILE_PATH].use { + it.file.getElementsByTagName("merge").item(0).childNodes.apply { + for (i in 1 until length) { + val view = item(i) + if ( + view.hasAttributes() && + view.attributes.getNamedItem("android:id").nodeValue.endsWith("dark_background") + ) { + view.attributes.getNamedItem("android:src").nodeValue = "@color/full_transparent" + break + } + } + } + } + + SettingsPatch.updatePatchStatus("hide-double-tap-overlay-filter") + + return PatchResultSuccess() + } + + private companion object { + const val RESOURCE_FILE_PATH = "res/layout/quick_seek_overlay.xml" + } +} \ No newline at end of file diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 16bd2e3d1..cc9dd2a3a 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -543,6 +543,7 @@ +