feat(YouTube Music/Player components): add Hide audio video switch toggle setting

This commit is contained in:
inotia00 2024-05-15 22:06:59 +09:00
parent 8f3f20036b
commit 55811b48aa
4 changed files with 40 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMut
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.player.components.fingerprints.AudioVideoSwitchToggleFingerprint
import app.revanced.patches.music.player.components.fingerprints.HandleSearchRenderedFingerprint
import app.revanced.patches.music.player.components.fingerprints.HandleSignInEventFingerprint
import app.revanced.patches.music.player.components.fingerprints.InteractionLoggingEnumFingerprint
@ -39,6 +40,7 @@ import app.revanced.patches.music.utils.fingerprints.PendingIntentReceiverFinger
import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.music.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.AudioVideoSwitchToggle
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.ColorGrey
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MiniPlayerPlayPauseReplayButton
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.TopEnd
@ -88,6 +90,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
),
compatiblePackages = COMPATIBLE_PACKAGE,
fingerprints = setOf(
AudioVideoSwitchToggleFingerprint,
HandleSearchRenderedFingerprint,
InteractionLoggingEnumFingerprint,
MinimizedPlayerFingerprint,
@ -492,6 +495,27 @@ object PlayerComponentsPatch : BaseBytecodePatch(
// endregion
// region patch for hide audio video switch toggle
AudioVideoSwitchToggleFingerprint.resultOrThrow().mutableMethod.apply {
val constIndex = getWideLiteralInstructionIndex(AudioVideoSwitchToggle)
val viewIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
val viewRegister = getInstruction<OneRegisterInstruction>(viewIndex).registerA
addInstruction(
viewIndex + 1,
"invoke-static {v$viewRegister}, $PLAYER_CLASS_DESCRIPTOR->hideAudioVideoSwitchToggle(Landroid/view/View;)V"
)
}
SettingsPatch.addSwitchPreference(
CategoryType.PLAYER,
"revanced_hide_audio_video_switch_toggle",
"false"
)
// endregion
// region patch for hide channel guideline, timestamps & emoji picker buttons
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)

View File

@ -0,0 +1,12 @@
package app.revanced.patches.music.player.components.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.AudioVideoSwitchToggle
import app.revanced.util.fingerprint.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
internal object AudioVideoSwitchToggleFingerprint : LiteralValueFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
literalSupplier = { AudioVideoSwitchToggle }
)

View File

@ -16,6 +16,7 @@ import app.revanced.patches.shared.mapping.ResourceType.STYLE
@Patch(dependencies = [ResourceMappingPatch::class])
object SharedResourceIdPatch : ResourcePatch() {
var AccountSwitcherAccessibility = -1L
var AudioVideoSwitchToggle = -1L
var ButtonContainer = -1L
var ButtonIconPaddingMedium = -1L
var ChipCloud = -1L
@ -56,6 +57,7 @@ object SharedResourceIdPatch : ResourcePatch() {
override fun execute(context: ResourceContext) {
AccountSwitcherAccessibility = getId(STRING, "account_switcher_accessibility_label")
AudioVideoSwitchToggle = getId(ID, "audio_video_switch_toggle")
ButtonContainer = getId(ID, "button_container")
ButtonIconPaddingMedium = getId(DIMEN, "button_icon_padding_medium")
ChipCloud = getId(LAYOUT, "chip_cloud")

View File

@ -225,6 +225,8 @@ This does not bypass the age restriction. It just accepts it automatically."</st
<string name="revanced_enable_zen_mode_summary">Changes the player background to light grey to reduce eye strain.</string>
<string name="revanced_enable_zen_mode_podcast_title">Enable zen mode in podcasts</string>
<string name="revanced_enable_zen_mode_podcast_summary">Zen mode is also applied to podcasts.</string>
<string name="revanced_hide_audio_video_switch_toggle_title">Hide audio video switch toggle</string>
<string name="revanced_hide_audio_video_switch_toggle_summary">Hides the audio video switch toggle in player.</string>
<string name="revanced_hide_comment_channel_guidelines_title">Hide channel guidelines</string>
<string name="revanced_hide_comment_channel_guidelines_summary">Hides channel guidelines at the top of the comments section.</string>
<string name="revanced_hide_comment_timestamp_and_emoji_buttons_title">Hide timestamp and emoji buttons</string>