Skip to content

Commit

Permalink
feat(YouTube Music - Player components): Add `Enable black player bac…
Browse files Browse the repository at this point in the history
…kground` settings
  • Loading branch information
inotia00 authored and anddea committed May 28, 2024
1 parent f4a9c22 commit c91be5a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -138,6 +138,23 @@ object PlayerComponentsPatch : BaseBytecodePatch(

colorMathPlayerInvokeVirtualReference = getInstruction<ReferenceInstruction>(invokeVirtualIndex).reference
colorMathPlayerIGetReference = getInstruction<ReferenceInstruction>(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 {
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/music/settings/host/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ This does not bypass the age restriction. It just accepts it automatically."</st
<!-- PreferenceScreen: Player -->
<string name="revanced_preference_screen_player_title">Player</string>

<string name="revanced_enable_black_player_background_title">Enable black player background</string>
<string name="revanced_enable_black_player_background_summary">Changes the player background color to black.</string>
<string name="revanced_enable_color_match_player_title">Enable color match player</string>
<string name="revanced_enable_color_match_player_summary">Matches the color of the miniplayer to the fullscreen player.</string>
<string name="revanced_enable_force_minimized_player_title">Enable force minimized player</string>
Expand Down

0 comments on commit c91be5a

Please sign in to comment.