From 07c5f9232143bab927030cd872bb93eea12451c2 Mon Sep 17 00:00:00 2001 From: inotia00 Date: Wed, 22 Feb 2023 23:36:41 +0900 Subject: [PATCH] add `hide-seekbar` patch --- .../seekbar/seekbar/patch/HideSeekbarPatch.kt | 60 +++++++++++++++++++ .../youtube/settings/xml/revanced_prefs.xml | 4 ++ 2 files changed, 64 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbar/patch/HideSeekbarPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbar/patch/HideSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbar/patch/HideSeekbarPatch.kt new file mode 100644 index 000000000..7138e2919 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/seekbar/patch/HideSeekbarPatch.kt @@ -0,0 +1,60 @@ +package app.revanced.patches.youtube.layout.seekbar.seekbar.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.extensions.addInstructions +import app.revanced.patcher.extensions.instruction +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.patcher.util.smali.ExternalLabel +import app.revanced.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch +import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch +import app.revanced.util.integrations.Constants.SEEKBAR_LAYOUT + +@Patch +@Name("hide-seekbar") +@Description("Hides the seekbar.") +@DependsOn( + [ + HookTimebarPatch::class, + SettingsPatch::class + ] +) +@YouTubeCompatibility +@Version("0.0.1") +class HideSeekbarPatch : BytecodePatch() { + override fun execute(context: BytecodeContext): PatchResult { + + val insertMethod = HookTimebarPatch.setTimebarMethod + + insertMethod.addInstructions( + 0, """ + invoke-static {}, $SEEKBAR_LAYOUT->hideSeekbar()Z + move-result v0 + if-eqz v0, :show_seekbar + return-void + """, listOf(ExternalLabel("show_seekbar", insertMethod.instruction(0))) + ) + + /* + * Add settings + */ + SettingsPatch.addPreference( + arrayOf( + "PREFERENCE: OTHER_LAYOUT_SETTINGS", + "PREFERENCE_HEADER: SEEKBAR", + "SETTINGS: HIDE_SEEKBAR" + ) + ) + + SettingsPatch.updatePatchStatus("hide-seekbar") + + return PatchResultSuccess() + } +} diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index ffb506eb5..a8c0eea2a 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -284,6 +284,9 @@ + + @@ -418,6 +421,7 @@ +