From c02b923404b9036f9954582afc9dd02a46d7d864 Mon Sep 17 00:00:00 2001 From: inotia00 Date: Sun, 8 Jan 2023 03:11:02 +0900 Subject: [PATCH] add `custom-seekbar-color` patch --- .../patch/CustomSeekbarColorBytecodePatch.kt} | 15 ++++++++------- .../resource/patch/CustomSeekbarColorPatch.kt} | 16 ++++++++-------- .../youtube/settings/host/values/strings.xml | 8 +++++--- .../youtube/settings/xml/revanced_prefs.xml | 7 ++++--- 4 files changed, 25 insertions(+), 21 deletions(-) rename src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/{oldseekbarcolor/bytecode/patch/OldSeekbarColorBytecodePatch.kt => customseekbarcolor/bytecode/patch/CustomSeekbarColorBytecodePatch.kt} (83%) rename src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/{oldseekbarcolor/resource/patch/OldSeekbarColorPatch.kt => customseekbarcolor/resource/patch/CustomSeekbarColorPatch.kt} (71%) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/oldseekbarcolor/bytecode/patch/OldSeekbarColorBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/bytecode/patch/CustomSeekbarColorBytecodePatch.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/oldseekbarcolor/bytecode/patch/OldSeekbarColorBytecodePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/bytecode/patch/CustomSeekbarColorBytecodePatch.kt index 87841e98b..339ff89fc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/oldseekbarcolor/bytecode/patch/OldSeekbarColorBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/bytecode/patch/CustomSeekbarColorBytecodePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.seekbar.oldseekbarcolor.bytecode.patch +package app.revanced.patches.youtube.layout.seekbar.customseekbarcolor.bytecode.patch import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version @@ -13,13 +13,14 @@ import app.revanced.shared.extensions.toResult import app.revanced.shared.patches.mapping.ResourceMappingPatch import app.revanced.shared.util.integrations.Constants.SEEKBAR_LAYOUT import org.jf.dexlib2.Opcode +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.formats.Instruction31i @DependsOn([ResourceMappingPatch::class]) -@Name("old-seekbar-color-bytecode-patch") +@Name("custom-seekbar-color-bytecode-patch") @YouTubeCompatibility @Version("0.0.1") -class OldSeekbarColorBytecodePatch : BytecodePatch() { +class CustomSeekbarColorBytecodePatch : BytecodePatch() { // list of resource names to get the id of private val resourceIds = arrayOf( @@ -38,15 +39,15 @@ class OldSeekbarColorBytecodePatch : BytecodePatch() { Opcode.CONST -> { when ((instruction as Instruction31i).wideLiteral) { resourceIds[0] -> { // seekbar color - val insertIndex = index + 1 + val registerIndex = index + 2 val mutableMethod = context.proxy(classDef).mutableClass.findMutableMethodOf(method) - val viewRegister = (instructions.elementAt(index) as Instruction31i).registerA + val viewRegister = (instructions.elementAt(registerIndex) as OneRegisterInstruction).registerA mutableMethod.addInstructions( - insertIndex, """ - invoke-static {v$viewRegister}, $SEEKBAR_LAYOUT->enableOldSeekbarColor(I)I + registerIndex + 1, """ + invoke-static {v$viewRegister}, $SEEKBAR_LAYOUT->enableCustomSeekbarColor(I)I move-result v$viewRegister """ ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/oldseekbarcolor/resource/patch/OldSeekbarColorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/resource/patch/CustomSeekbarColorPatch.kt similarity index 71% rename from src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/oldseekbarcolor/resource/patch/OldSeekbarColorPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/resource/patch/CustomSeekbarColorPatch.kt index 54d37d9d9..0d85e5fc7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/oldseekbarcolor/resource/patch/OldSeekbarColorPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/customseekbarcolor/resource/patch/CustomSeekbarColorPatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.seekbar.oldseekbarcolor.resource.patch +package app.revanced.patches.youtube.layout.seekbar.customseekbarcolor.resource.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -9,23 +9,23 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patches.youtube.layout.seekbar.oldseekbarcolor.bytecode.patch.OldSeekbarColorBytecodePatch +import app.revanced.patches.youtube.layout.seekbar.customseekbarcolor.bytecode.patch.CustomSeekbarColorBytecodePatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.shared.annotation.YouTubeCompatibility import app.revanced.shared.util.resources.ResourceHelper @Patch -@Name("enable-old-seekbar-color") -@Description("Enable old seekbar color in dark mode.") +@Name("custom-seekbar-color") +@Description("Change seekbar color in dark mode.") @DependsOn( [ - OldSeekbarColorBytecodePatch::class, + CustomSeekbarColorBytecodePatch::class, SettingsPatch::class ] ) @YouTubeCompatibility @Version("0.0.1") -class OldSeekbarColorPatch : ResourcePatch { +class CustomSeekbarColorPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { /* @@ -36,12 +36,12 @@ class OldSeekbarColorPatch : ResourcePatch { "PREFERENCE_CATEGORY: REVANCED_SETTINGS", "PREFERENCE: LAYOUT_SETTINGS", "PREFERENCE_HEADER: SEEKBAR", - "SETTINGS: ENABLE_OLD_SEEKBAR_COLOR" + "SETTINGS: CUSTOM_SEEKBAR_COLOR" ) ResourceHelper.patchSuccess( context, - "enable-old-seekbar-color" + "custom-seekbar-color" ) return PatchResultSuccess() diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index e2ee161de..3817e2927 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -160,6 +160,8 @@ Is it ready to submit?" Web search panels are shown Web search panels are hidden Hide web search panels + Type the color hex code of the seekbar to use in dark mode + Custom seekbar color value The maximum duration of media that the player will attempt to buffer Maximum buffer size The duration of media that must be buffered for playback to start or resume following a user action such as seeking @@ -206,6 +208,9 @@ Is it ready to submit?" Disable swipe gestures when player controls are visible Enable always swipe gestures regardless of player controls visible or not Enable always swipe gesture + Custom seekbar color is disabled + Custom seekbar color is enabled + Enable custom seekbar color in dark mode Custom video speed is disabled Custom video speed is enabled Enable custom video speed @@ -224,9 +229,6 @@ Is it ready to submit?" New style quality settings are shown Old style quality settings are shown Enable old style quality layout - New seekbar color is used - Old seekbar color is used - Enable old seekbar color URL redirect (youtube.com/redirect) is used when opening links in video descriptions Bypass URL redirects (youtube.com/redirect) when opening links in video descriptions Enable open links directly diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index c26dba799..411647eba 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -238,8 +238,9 @@ - + @@ -391,7 +392,7 @@ - +