mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-12 04:24:36 +02:00
feat(YouTube Music): add Enable new player background
patch
This commit is contained in:
parent
83b1a00744
commit
119a5c6e5c
@ -0,0 +1,60 @@
|
||||
package app.revanced.patches.music.player.newplayerbackground
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.music.player.newplayerbackground.fingerprints.NewPlayerBackgroundFingerprint
|
||||
import app.revanced.patches.music.utils.playerlayouthook.PlayerLayoutHookPatch
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.util.enum.CategoryType
|
||||
import app.revanced.util.integrations.Constants.MUSIC_PLAYER
|
||||
|
||||
@Patch(
|
||||
name = "Enable new player background",
|
||||
description = "Enable new player background.",
|
||||
dependencies =
|
||||
[
|
||||
PlayerLayoutHookPatch::class,
|
||||
SettingsPatch::class
|
||||
],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.apps.youtube.music",
|
||||
[
|
||||
"6.15.52",
|
||||
"6.20.51",
|
||||
"6.21.51",
|
||||
"6.22.51"
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object NewPlayerBackgroundPatch : BytecodePatch(
|
||||
setOf(NewPlayerBackgroundFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
NewPlayerBackgroundFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
addInstructions(
|
||||
0, """
|
||||
invoke-static {}, $MUSIC_PLAYER->enableNewPlayerBackground()Z
|
||||
move-result v0
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw NewPlayerBackgroundFingerprint.exception
|
||||
|
||||
SettingsPatch.addMusicPreference(
|
||||
CategoryType.PLAYER,
|
||||
"revanced_enable_new_player_background",
|
||||
"false"
|
||||
)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package app.revanced.patches.music.player.newplayerbackground.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.util.bytecode.isWide32LiteralExists
|
||||
|
||||
object NewPlayerBackgroundFingerprint : MethodFingerprint(
|
||||
returnType = "Z",
|
||||
parameters = emptyList(),
|
||||
customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45415319) }
|
||||
)
|
@ -29,6 +29,7 @@ import app.revanced.util.enum.CategoryType
|
||||
)
|
||||
@Suppress("unused")
|
||||
object NewPlayerLayoutPatch : ResourcePatch() {
|
||||
private const val YOUTUBE_MUSIC_SETTINGS_PATH = "res/xml/settings_headers.xml"
|
||||
override fun execute(context: ResourceContext) {
|
||||
|
||||
SettingsPatch.addMusicPreference(
|
||||
@ -37,5 +38,14 @@ object NewPlayerLayoutPatch : ResourcePatch() {
|
||||
"true"
|
||||
)
|
||||
|
||||
val prefs = context[YOUTUBE_MUSIC_SETTINGS_PATH]
|
||||
|
||||
prefs.writeText(
|
||||
prefs.readText()
|
||||
.replace(
|
||||
"revanced_enable_new_player_background\"",
|
||||
"revanced_enable_new_player_background\" android:dependency=\"revanced_enable_new_player_layout\""
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
@ -34,6 +34,8 @@
|
||||
<string name="revanced_enable_force_minimized_player_title">Enable force minimized player</string>
|
||||
<string name="revanced_enable_landscape_mode_summary">Enables entry into landscape mode by screen rotation on the phone.</string>
|
||||
<string name="revanced_enable_landscape_mode_title">Enable landscape mode</string>
|
||||
<string name="revanced_enable_new_player_background_summary">Enables new player background.</string>
|
||||
<string name="revanced_enable_new_player_background_title">Enable new player background</string>
|
||||
<string name="revanced_enable_new_player_layout_summary">Enable new player layouts.</string>
|
||||
<string name="revanced_enable_new_player_layout_title">Enable new player layout</string>
|
||||
<string name="revanced_enable_old_style_library_shelf_summary">Return the library shelf to old style. (Experimental)</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user