From 4fd2577a8fac04f2434ab29bab5ba0d15e6a003e Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Mon, 27 May 2024 23:39:03 +0900 Subject: [PATCH] feat(YouTube Music/Player components): add `Enable black player background` settings https://github.com/inotia00/ReVanced_Extended/issues/1374 --- .../components/PlayerComponentsPatch.kt | 24 ++++++++++++++++++- .../music/settings/host/values/strings.xml | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/app/revanced/patches/music/player/components/PlayerComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/music/player/components/PlayerComponentsPatch.kt index ae003f73e..c6f790238 100644 --- a/src/main/kotlin/app/revanced/patches/music/player/components/PlayerComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/player/components/PlayerComponentsPatch.kt @@ -117,7 +117,7 @@ object PlayerComponentsPatch : BaseBytecodePatch( override fun execute(context: BytecodeContext) { - // region patch for enable color match player + // region patch for enable color match player and enable black player background lateinit var colorMathPlayerInvokeVirtualReference: Reference lateinit var colorMathPlayerIGetReference: Reference @@ -138,6 +138,23 @@ object PlayerComponentsPatch : BaseBytecodePatch( colorMathPlayerInvokeVirtualReference = getInstruction(invokeVirtualIndex).reference colorMathPlayerIGetReference = getInstruction(iGetIndex).reference + + // black player background + val invokeDirectIndex = getTargetIndex(Opcode.INVOKE_DIRECT) + val targetMethod = getWalkerMethod(context, invokeDirectIndex) + + targetMethod.apply { + val insertIndex = getTargetIndex(0, Opcode.IF_NE) + + addInstructions( + insertIndex, """ + invoke-static {p1}, $PLAYER_CLASS_DESCRIPTOR->enableBlackPlayerBackground(I)I + move-result p1 + invoke-static {p2}, $PLAYER_CLASS_DESCRIPTOR->enableBlackPlayerBackground(I)I + move-result p2 + """ + ) + } } parentResult.mutableMethod.apply { @@ -178,6 +195,11 @@ object PlayerComponentsPatch : BaseBytecodePatch( } } + SettingsPatch.addSwitchPreference( + CategoryType.PLAYER, + "revanced_enable_black_player_background", + "false" + ) SettingsPatch.addSwitchPreference( CategoryType.PLAYER, "revanced_enable_color_match_player", diff --git a/src/main/resources/music/settings/host/values/strings.xml b/src/main/resources/music/settings/host/values/strings.xml index 3c59871db..668e84263 100644 --- a/src/main/resources/music/settings/host/values/strings.xml +++ b/src/main/resources/music/settings/host/values/strings.xml @@ -211,6 +211,8 @@ This does not bypass the age restriction. It just accepts it automatically." Player + Enable black player background + Changes the player background color to black. Enable color match player Matches the color of the miniplayer to the fullscreen player. Enable force minimized player