feat(YouTube Music): Add Forcibly enable miniplayer patch

Co-Authored-By: ILoveOpenSourceApplications <117499019+iloveopensourceapplications@users.noreply.github.com>
This commit is contained in:
oSumAtrIX 2026-03-11 11:02:56 +01:00
parent 7f52ec2cea
commit e7196e54b0
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
6 changed files with 97 additions and 3 deletions

View file

@ -0,0 +1,13 @@
package app.revanced.extension.music.patches;
import app.revanced.extension.music.settings.Settings;
@SuppressWarnings("unused")
public class ForciblyEnableMiniplayerPatch {
/**
* Injection point
*/
public static boolean enableForcedMiniplayerPatch(boolean original) {
return Settings.FORCIBLY_ENABLE_MINIPLAYER.get() || original;
}
}

View file

@ -35,6 +35,7 @@ public class Settings extends YouTubeAndMusicSettings {
// Player // Player
public static final BooleanSetting CHANGE_MINIPLAYER_COLOR = new BooleanSetting("revanced_music_change_miniplayer_color", FALSE, true); public static final BooleanSetting CHANGE_MINIPLAYER_COLOR = new BooleanSetting("revanced_music_change_miniplayer_color", FALSE, true);
public static final BooleanSetting FORCIBLY_ENABLE_MINIPLAYER = new BooleanSetting("revanced_music_forcibly_enable_miniplayer", FALSE, true);
public static final BooleanSetting PERMANENT_REPEAT = new BooleanSetting("revanced_music_play_permanent_repeat", FALSE, true); public static final BooleanSetting PERMANENT_REPEAT = new BooleanSetting("revanced_music_play_permanent_repeat", FALSE, true);
// Miscellaneous // Miscellaneous

View file

@ -1,6 +1,6 @@
@file:Suppress("SpellCheckingInspection") @file:Suppress("SpellCheckingInspection")
package app.revanced.patches.music.layout.miniplayercolor package app.revanced.patches.music.layout.miniplayer
import app.revanced.patcher.accessFlags import app.revanced.patcher.accessFlags
import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.getInstruction

View file

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.miniplayercolor package app.revanced.patches.music.layout.miniplayer
import app.revanced.patcher.* import app.revanced.patcher.*
import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.patch.BytecodePatchContext
@ -28,3 +28,10 @@ internal val ClassDef.switchToggleColorMethodMatch by ClassDefComposing.composin
Opcode.IGET, Opcode.IGET,
) )
} }
internal val BytecodePatchContext.minimizedPlayerMethod by gettingFirstMethodDeclaratively {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returnType("V")
parameterTypes("L", "L")
instructions("w_st"())
}

View file

@ -0,0 +1,68 @@
@file:Suppress("SpellCheckingInspection")
package app.revanced.patches.music.layout.miniplayer
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.music.misc.extension.sharedExtensionPatch
import app.revanced.patches.music.misc.settings.PreferenceScreen
import app.revanced.patches.music.misc.settings.settingsPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/music/patches/ForciblyEnableMiniplayerPatch;"
@Suppress("unused")
val forciblyEnableMiniplayerPatch = bytecodePatch(
name = "Forcibly enable miniplayer",
description = "Adds an option to forcibly enable the miniplayer when switching between music videos, podcasts, or songs."
) {
dependsOn(
sharedExtensionPatch,
settingsPatch,
addResourcesPatch,
)
compatibleWith(
"com.google.android.apps.youtube.music"(
"7.29.52",
"8.10.52",
"8.37.56",
"8.40.54",
"8.44.54"
),
)
apply {
addResources("music", "layout.miniplayer.forciblyEnableMiniplayer")
PreferenceScreen.PLAYER.addPreferences(
SwitchPreference("revanced_music_forcibly_enable_miniplayer")
)
minimizedPlayerMethod.apply {
val invokeIndex = indexOfFirstInstructionOrThrow {
opcode == Opcode.INVOKE_VIRTUAL && methodReference?.name == "booleanValue"
}
val moveResultIndex = invokeIndex + 1
val moveResultInstr = getInstruction<OneRegisterInstruction>(moveResultIndex)
val targetRegister = moveResultInstr.registerA
addInstructions(
moveResultIndex + 1,
"""
invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR->forciblyEnableMiniplayerPatch(Z)Z
move-result v$targetRegister
"""
)
}
}
}

View file

@ -1862,11 +1862,16 @@ Video playback with AV1 may stutter or drop frames."</string>
<string name="revanced_music_hide_category_bar_summary_on">Category bar is hidden</string> <string name="revanced_music_hide_category_bar_summary_on">Category bar is hidden</string>
<string name="revanced_music_hide_category_bar_summary_off">Category bar is shown</string> <string name="revanced_music_hide_category_bar_summary_off">Category bar is shown</string>
</patch> </patch>
<patch id="layout.miniplayercolor.changeMiniplayerColor"> <patch id="layout.miniplayer.changeMiniplayerColor">
<string name="revanced_music_change_miniplayer_color_title">Change miniplayer color</string> <string name="revanced_music_change_miniplayer_color_title">Change miniplayer color</string>
<string name="revanced_music_change_miniplayer_color_summary_on">Miniplayer color matches fullscreen player</string> <string name="revanced_music_change_miniplayer_color_summary_on">Miniplayer color matches fullscreen player</string>
<string name="revanced_music_change_miniplayer_color_summary_off">Miniplayer uses default color</string> <string name="revanced_music_change_miniplayer_color_summary_off">Miniplayer uses default color</string>
</patch> </patch>
<patch id="layout.miniplayer.forciblyEnableMiniplayer">
<string name="revanced_music_forcibly_enable_miniplayer_title">Forcibly enable miniplayer</string>
<string name="revanced_music_forcibly_enable_miniplayer_summary_on">Miniplayer stays minimized when playback changes</string>
<string name="revanced_music_forcibly_enable_miniplayer_summary_off">Miniplayer expands to fullscreen when playback changes</string>
</patch>
<patch id="layout.navigationbar.navigationBarPatch"> <patch id="layout.navigationbar.navigationBarPatch">
<string name="revanced_music_navigation_bar_screen_title">Navigation bar</string> <string name="revanced_music_navigation_bar_screen_title">Navigation bar</string>
<string name="revanced_music_navigation_bar_screen_summary">Hide or change navigation bar buttons</string> <string name="revanced_music_navigation_bar_screen_summary">Hide or change navigation bar buttons</string>