Skip to content

Commit

Permalink
feat(YouTube - Hide player flyout menu): Add Hide quality menu header
Browse files Browse the repository at this point in the history
Co-Authored-By: inotia00 <[email protected]>
  • Loading branch information
inotia00 authored and anddea committed Jun 11, 2024
1 parent 412d248 commit 99af80b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(
Expand All @@ -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)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ object VisualPreferencesIconsPatch : BaseResourcePatch(
"revanced_hide_player_flyout_menu_loop_video",
"revanced_hide_player_flyout_menu_more_info",
"revanced_hide_player_flyout_menu_playback_speed",
"revanced_hide_player_flyout_menu_quality_footer",
"revanced_hide_player_flyout_menu_quality_header",
"revanced_hide_player_flyout_menu_report",
"revanced_hide_player_flyout_menu_stable_volume",
"revanced_hide_player_flyout_menu_stats_for_nerds",
Expand Down Expand Up @@ -211,6 +211,7 @@ object VisualPreferencesIconsPatch : BaseResourcePatch(
"revanced_gms_show_dialog",
"revanced_hide_shorts_comments_disabled_button",
"revanced_hide_player_flyout_menu_captions_footer",
"revanced_hide_player_flyout_menu_quality_footer",
"revanced_remember_playback_speed_last_selected",
"revanced_remember_video_quality_last_selected",
"revanced_restore_old_video_quality_menu",
Expand Down Expand Up @@ -253,7 +254,7 @@ object VisualPreferencesIconsPatch : BaseResourcePatch(
"revanced_hide_player_flyout_menu_captions" -> "captions_key_icon"
"revanced_hide_player_flyout_menu_loop_video" -> "revanced_overlay_button_always_repeat_icon"
"revanced_hide_player_flyout_menu_more_info" -> "about_key_icon"
"revanced_hide_player_flyout_menu_quality_footer" -> "revanced_default_video_quality_wifi_icon"
"revanced_hide_player_flyout_menu_quality_header" -> "revanced_default_video_quality_wifi_icon"
"revanced_hide_player_flyout_menu_report" -> "revanced_hide_report_button_icon"
"revanced_hide_player_fullscreen_button" -> "revanced_preference_screen_fullscreen_icon"
"revanced_hide_quick_actions_dislike_button" -> "revanced_preference_screen_ryd_icon"
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/youtube/settings/xml/revanced_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
<SwitchPreference android:title="@string/revanced_change_player_flyout_menu_toggle_title" android:key="revanced_change_player_flyout_menu_toggle" android:defaultValue="false" android:summaryOn="@string/revanced_change_player_flyout_menu_toggle_summary_on" android:summaryOff="@string/revanced_change_player_flyout_menu_toggle_summary_off" />SETTINGS: CHANGE_PLAYER_FLYOUT_MENU_TOGGLE -->

<!-- SETTINGS: HIDE_PLAYER_FLYOUT_MENU
<SwitchPreference android:title="@string/revanced_hide_player_flyout_menu_quality_header_title" android:key="revanced_hide_player_flyout_menu_quality_header" android:summaryOn="@string/revanced_hide_player_flyout_menu_quality_header_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_menu_quality_header_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_player_flyout_menu_quality_footer_title" android:key="revanced_hide_player_flyout_menu_quality_footer" android:defaultValue="true" android:summaryOn="@string/revanced_hide_player_flyout_menu_quality_footer_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_menu_quality_footer_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_player_flyout_menu_playback_speed_title" android:key="revanced_hide_player_flyout_menu_playback_speed" android:defaultValue="false" android:summaryOn="@string/revanced_hide_player_flyout_menu_playback_speed_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_menu_playback_speed_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_player_flyout_menu_captions_title" android:key="revanced_hide_player_flyout_menu_captions" android:defaultValue="false" android:summaryOn="@string/revanced_hide_player_flyout_menu_captions_summary_on" android:summaryOff="@string/revanced_hide_player_flyout_menu_captions_summary_off" />
Expand Down

0 comments on commit 99af80b

Please sign in to comment.