mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-04 16:44:29 +02:00
fix(YouTube/Hide player buttons): Hide collapse button
setting leaves a blank space in fullscreen
This commit is contained in:
parent
1a43c2b57e
commit
57c94dc39c
@ -5,21 +5,21 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
|||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
import app.revanced.patches.youtube.player.buttons.fingerprints.FullScreenButtonFingerprint
|
import app.revanced.patches.youtube.player.buttons.fingerprints.FullScreenButtonFingerprint
|
||||||
import app.revanced.patches.youtube.player.buttons.fingerprints.LithoSubtitleButtonConfigFingerprint
|
import app.revanced.patches.youtube.player.buttons.fingerprints.LithoSubtitleButtonConfigFingerprint
|
||||||
import app.revanced.patches.youtube.player.buttons.fingerprints.MusicAppDeeplinkButtonFingerprint
|
import app.revanced.patches.youtube.player.buttons.fingerprints.MusicAppDeeplinkButtonFingerprint
|
||||||
import app.revanced.patches.youtube.player.buttons.fingerprints.MusicAppDeeplinkButtonParentFingerprint
|
import app.revanced.patches.youtube.player.buttons.fingerprints.MusicAppDeeplinkButtonParentFingerprint
|
||||||
import app.revanced.patches.youtube.player.buttons.fingerprints.PlayerControlsVisibilityModelFingerprint
|
import app.revanced.patches.youtube.player.buttons.fingerprints.PlayerControlsVisibilityModelFingerprint
|
||||||
|
import app.revanced.patches.youtube.player.buttons.fingerprints.TitleAnchorFingerprint
|
||||||
import app.revanced.patches.youtube.player.buttons.fingerprints.YouTubeControlsOverlaySubtitleButtonFingerprint
|
import app.revanced.patches.youtube.player.buttons.fingerprints.YouTubeControlsOverlaySubtitleButtonFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.LayoutConstructorFingerprint
|
import app.revanced.patches.youtube.utils.fingerprints.LayoutConstructorFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.PlayerButtonsResourcesFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AutoNavToggle
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AutoNavToggle
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.PlayerCollapseButton
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TitleAnchor
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.getTargetIndex
|
import app.revanced.util.getTargetIndex
|
||||||
import app.revanced.util.getTargetIndexWithReference
|
import app.revanced.util.getTargetIndexWithReference
|
||||||
@ -27,7 +27,6 @@ import app.revanced.util.getWideLiteralInstructionIndex
|
|||||||
import app.revanced.util.patch.BaseBytecodePatch
|
import app.revanced.util.patch.BaseBytecodePatch
|
||||||
import app.revanced.util.resultOrThrow
|
import app.revanced.util.resultOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction3rc
|
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction3rc
|
||||||
@ -46,9 +45,9 @@ object PlayerButtonsPatch : BaseBytecodePatch(
|
|||||||
LayoutConstructorFingerprint,
|
LayoutConstructorFingerprint,
|
||||||
LithoSubtitleButtonConfigFingerprint,
|
LithoSubtitleButtonConfigFingerprint,
|
||||||
MusicAppDeeplinkButtonParentFingerprint,
|
MusicAppDeeplinkButtonParentFingerprint,
|
||||||
YouTubeControlsOverlaySubtitleButtonFingerprint,
|
|
||||||
PlayerButtonsResourcesFingerprint,
|
|
||||||
PlayerControlsVisibilityModelFingerprint,
|
PlayerControlsVisibilityModelFingerprint,
|
||||||
|
TitleAnchorFingerprint,
|
||||||
|
YouTubeControlsOverlaySubtitleButtonFingerprint,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
private const val HAS_NEXT = 5
|
private const val HAS_NEXT = 5
|
||||||
@ -114,28 +113,24 @@ object PlayerButtonsPatch : BaseBytecodePatch(
|
|||||||
|
|
||||||
// region patch for hide collapse button
|
// region patch for hide collapse button
|
||||||
|
|
||||||
PlayerButtonsResourcesFingerprint.resultOrThrow().mutableClass.methods.forEach { method ->
|
TitleAnchorFingerprint.resultOrThrow().mutableMethod.apply {
|
||||||
method.apply {
|
val titleAnchorConstIndex = getWideLiteralInstructionIndex(TitleAnchor)
|
||||||
var jumpInstruction = true
|
val titleAnchorIndex = getTargetIndex(titleAnchorConstIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||||
|
val titleAnchorRegister = getInstruction<OneRegisterInstruction>(titleAnchorIndex).registerA
|
||||||
|
|
||||||
implementation!!.instructions.forEachIndexed { index, instructions ->
|
addInstruction(
|
||||||
val definedInstruction = instructions as? BuilderInstruction35c
|
titleAnchorIndex + 1,
|
||||||
|
"invoke-static {v$titleAnchorRegister}, $PLAYER_CLASS_DESCRIPTOR->setTitleAnchorStartMargin(Landroid/view/View;)V"
|
||||||
if (instructions.opcode == Opcode.INVOKE_VIRTUAL
|
)
|
||||||
&& definedInstruction?.reference.toString().contains("setVisibility")) {
|
|
||||||
val viewRegister = definedInstruction?.registerC
|
val playerCollapseButtonConstIndex = getWideLiteralInstructionIndex(PlayerCollapseButton)
|
||||||
val visibilityRegister = definedInstruction?.registerD
|
val playerCollapseButtonIndex = getTargetIndex(playerCollapseButtonConstIndex, Opcode.CHECK_CAST)
|
||||||
|
val playerCollapseButtonRegister = getInstruction<OneRegisterInstruction>(playerCollapseButtonIndex).registerA
|
||||||
jumpInstruction = !jumpInstruction
|
|
||||||
if (jumpInstruction) return@forEachIndexed
|
addInstruction(
|
||||||
|
playerCollapseButtonIndex + 1,
|
||||||
replaceInstruction(
|
"invoke-static {v$playerCollapseButtonRegister}, $PLAYER_CLASS_DESCRIPTOR->hideCollapseButton(Landroid/widget/ImageView;)V"
|
||||||
index,
|
|
||||||
"invoke-static {v$viewRegister, v$visibilityRegister}, $PLAYER_CLASS_DESCRIPTOR->hideCollapseButton(Landroid/view/View;I)V"
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package app.revanced.patches.youtube.player.buttons.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.PlayerCollapseButton
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TitleAnchor
|
||||||
|
import app.revanced.util.containsWideLiteralInstructionIndex
|
||||||
|
|
||||||
|
internal object TitleAnchorFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.containsWideLiteralInstructionIndex(PlayerCollapseButton)
|
||||||
|
&& methodDef.containsWideLiteralInstructionIndex(TitleAnchor)
|
||||||
|
}
|
||||||
|
)
|
@ -60,6 +60,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
var MenuItemView = -1L
|
var MenuItemView = -1L
|
||||||
var MusicAppDeeplinkButtonView = -1L
|
var MusicAppDeeplinkButtonView = -1L
|
||||||
var PanelSubHeader = -1L
|
var PanelSubHeader = -1L
|
||||||
|
var PlayerCollapseButton = -1L
|
||||||
var PosterArtWidthDefault = -1L
|
var PosterArtWidthDefault = -1L
|
||||||
var QualityAuto = -1L
|
var QualityAuto = -1L
|
||||||
var QuickActionsElementContainer = -1L
|
var QuickActionsElementContainer = -1L
|
||||||
@ -80,6 +81,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
var SubtitleMenuSettingsFooterInfo = -1L
|
var SubtitleMenuSettingsFooterInfo = -1L
|
||||||
var SuggestedAction = -1L
|
var SuggestedAction = -1L
|
||||||
var TabsBarTextTabView = -1L
|
var TabsBarTextTabView = -1L
|
||||||
|
var TitleAnchor = -1L
|
||||||
var ToolTipContentView = -1L
|
var ToolTipContentView = -1L
|
||||||
var TotalTime = -1L
|
var TotalTime = -1L
|
||||||
var VideoQualityBottomSheet = -1L
|
var VideoQualityBottomSheet = -1L
|
||||||
@ -133,6 +135,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
MenuItemView = getId(ID, "menu_item_view")
|
MenuItemView = getId(ID, "menu_item_view")
|
||||||
MusicAppDeeplinkButtonView = getId(ID, "music_app_deeplink_button_view")
|
MusicAppDeeplinkButtonView = getId(ID, "music_app_deeplink_button_view")
|
||||||
PanelSubHeader = getId(ID, "panel_subheader")
|
PanelSubHeader = getId(ID, "panel_subheader")
|
||||||
|
PlayerCollapseButton = getId(ID, "player_collapse_button")
|
||||||
PosterArtWidthDefault = getId(DIMEN, "poster_art_width_default")
|
PosterArtWidthDefault = getId(DIMEN, "poster_art_width_default")
|
||||||
QualityAuto = getId(STRING, "quality_auto")
|
QualityAuto = getId(STRING, "quality_auto")
|
||||||
QuickActionsElementContainer = getId(ID, "quick_actions_element_container")
|
QuickActionsElementContainer = getId(ID, "quick_actions_element_container")
|
||||||
@ -153,6 +156,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
SubtitleMenuSettingsFooterInfo = getId(STRING, "subtitle_menu_settings_footer_info")
|
SubtitleMenuSettingsFooterInfo = getId(STRING, "subtitle_menu_settings_footer_info")
|
||||||
SuggestedAction = getId(LAYOUT, "suggested_action")
|
SuggestedAction = getId(LAYOUT, "suggested_action")
|
||||||
TabsBarTextTabView = getId(ID, "tabs_bar_text_tab_view")
|
TabsBarTextTabView = getId(ID, "tabs_bar_text_tab_view")
|
||||||
|
TitleAnchor = getId(ID, "title_anchor")
|
||||||
ToolTipContentView = getId(LAYOUT, "tooltip_content_view")
|
ToolTipContentView = getId(LAYOUT, "tooltip_content_view")
|
||||||
TotalTime = getId(STRING, "total_time")
|
TotalTime = getId(STRING, "total_time")
|
||||||
VideoQualityBottomSheet = getId(LAYOUT, "video_quality_bottom_sheet_list_fragment_title")
|
VideoQualityBottomSheet = getId(LAYOUT, "video_quality_bottom_sheet_list_fragment_title")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user