mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat(YouTube/Hide player flyout menu) add Hide quality menu header
https://github.com/inotia00/ReVanced_Extended/issues/2126
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package app.revanced.patches.youtube.player.flyoutmenu.hide
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.player.flyoutmenu.hide.fingerprints.AdvancedQualityBottomSheetFingerprint
|
||||
import app.revanced.patches.youtube.player.flyoutmenu.hide.fingerprints.CaptionsBottomSheetFingerprint
|
||||
@ -14,9 +16,12 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.BottomSheetFooterText
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
import app.revanced.util.literalInstructionBooleanHook
|
||||
import app.revanced.util.literalInstructionViewHook
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
|
||||
@Suppress("unused")
|
||||
object PlayerFlyoutMenuPatch : BaseBytecodePatch(
|
||||
@ -41,17 +46,39 @@ object PlayerFlyoutMenuPatch : BaseBytecodePatch(
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
arrayOf(
|
||||
AdvancedQualityBottomSheetFingerprint to "hideFooterQuality",
|
||||
CaptionsBottomSheetFingerprint to "hideFooterCaptions",
|
||||
QualityMenuViewInflateFingerprint to "hideFooterQuality"
|
||||
).map { (fingerprint, name) ->
|
||||
// region hide player flyout menu header, footer (non-litho)
|
||||
|
||||
mapOf(
|
||||
AdvancedQualityBottomSheetFingerprint to "hidePlayerFlyoutMenuQualityFooter",
|
||||
CaptionsBottomSheetFingerprint to "hidePlayerFlyoutMenuCaptionsFooter",
|
||||
QualityMenuViewInflateFingerprint to "hidePlayerFlyoutMenuQualityFooter"
|
||||
).forEach { (fingerprint, name) ->
|
||||
val smaliInstruction = """
|
||||
invoke-static {v$REGISTER_TEMPLATE_REPLACEMENT}, $PLAYER_CLASS_DESCRIPTOR->$name(Landroid/view/View;)V
|
||||
"""
|
||||
fingerprint.literalInstructionViewHook(BottomSheetFooterText, smaliInstruction)
|
||||
}
|
||||
|
||||
arrayOf(
|
||||
AdvancedQualityBottomSheetFingerprint,
|
||||
QualityMenuViewInflateFingerprint
|
||||
).forEach { fingerprint ->
|
||||
fingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val insertIndex = getTargetIndexWithMethodReferenceName("addHeaderView")
|
||||
val insertRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
|
||||
addInstructions(
|
||||
insertIndex,
|
||||
"""
|
||||
invoke-static {v$insertRegister}, $PLAYER_CLASS_DESCRIPTOR->hidePlayerFlyoutMenuQualityHeader(Landroid/view/View;)Landroid/view/View;
|
||||
move-result-object v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
LithoFilterPatch.addFilter(PANELS_FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user