diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 152dc8346f..0b4976b98e 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -1670,6 +1670,12 @@ public final class app/revanced/patches/youtube/layout/buttons/navigation/Naviga public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } +public final class app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + public final class app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt index f5ea004743..3d82a1e412 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/AutoCaptionsPatch.kt @@ -9,10 +9,10 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.all.misc.resources.AddResourcesPatch import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.layout.autocaptions.fingerprints.StartVideoInformerFingerprint -import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleButtonControllerFingerprint import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleTrackFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.patches.youtube.shared.fingerprints.SubtitleButtonControllerFingerprint import app.revanced.util.exception diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt index 161a3a2b3c..a322b755d1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/HideAutoplayButtonPatch.kt @@ -1,84 +1,14 @@ package app.revanced.patches.youtube.layout.buttons.autoplay import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotation.CompatiblePackage -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch -import app.revanced.patches.shared.misc.settings.preference.SwitchPreference -import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch -import app.revanced.patches.youtube.misc.settings.SettingsPatch -import app.revanced.patches.youtube.shared.fingerprints.LayoutConstructorFingerprint -import app.revanced.util.getReference -import app.revanced.util.indexOfFirstInstructionOrThrow -import app.revanced.util.indexOfIdResourceOrThrow -import app.revanced.util.resultOrThrow -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference +import app.revanced.patches.youtube.layout.buttons.overlay.HidePlayerOverlayButtonsPatch -@Patch( - name = "Hide autoplay button", - description = "Adds an option to hide the autoplay button in the video player.", - dependencies = [ - IntegrationsPatch::class, - SettingsPatch::class, - ResourceMappingPatch::class, - AddResourcesPatch::class, - ], - compatiblePackages = [ - CompatiblePackage( - "com.google.android.youtube", - [ - "18.38.44", - "18.49.37", - "19.16.39", - "19.25.37", - "19.34.42", - ], - ), - ], -) @Suppress("unused") +@Deprecated("This patch has been merged into HidePlayerOverlayButtonsPatch.") object HideAutoplayButtonPatch : BytecodePatch( - setOf(LayoutConstructorFingerprint), + dependencies = setOf(HidePlayerOverlayButtonsPatch::class), ) { - - private const val INTEGRATIONS_CLASS_DESCRIPTOR = - "Lapp/revanced/integrations/youtube/patches/HideAutoplayButtonPatch;" - override fun execute(context: BytecodeContext) { - AddResourcesPatch(this::class) - - SettingsPatch.PreferenceScreen.PLAYER.addPreferences( - SwitchPreference("revanced_hide_autoplay_button"), - ) - - LayoutConstructorFingerprint.resultOrThrow().mutableMethod.apply { - val constIndex = indexOfIdResourceOrThrow("autonav_toggle") - val constRegister = getInstruction(constIndex).registerA - - // Add a conditional branch around the code that inflates and adds the auto repeat button. - val gotoIndex = indexOfFirstInstructionOrThrow(constIndex) { - val parameterTypes = getReference()?.parameterTypes - opcode == Opcode.INVOKE_VIRTUAL && - parameterTypes?.size == 2 && - parameterTypes.first() == "Landroid/view/ViewStub;" - } + 1 - - addInstructionsWithLabels( - constIndex, - """ - invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->hideAutoPlayButton()Z - move-result v$constRegister - if-nez v$constRegister, :hidden - """, - ExternalLabel("hidden", getInstruction(gotoIndex)), - ) - } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt index bf41baa3be..200f8e5ffa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/captions/HideCaptionsButtonPatch.kt @@ -1,61 +1,14 @@ package app.revanced.patches.youtube.layout.buttons.captions import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotation.CompatiblePackage -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.misc.settings.preference.SwitchPreference -import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleButtonControllerFingerprint -import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch -import app.revanced.patches.youtube.misc.settings.SettingsPatch -import com.android.tools.smali.dexlib2.Opcode +import app.revanced.patches.youtube.layout.buttons.overlay.HidePlayerOverlayButtonsPatch -@Patch( - name = "Hide captions button", - description = "Adds an option to hide the captions button in the video player.", - dependencies = [ - IntegrationsPatch::class, - SettingsPatch::class, - AddResourcesPatch::class - ], - compatiblePackages = [ - CompatiblePackage( - "com.google.android.youtube", - [ - "18.38.44", - "18.49.37", - "19.16.39", - "19.25.37", - "19.34.42", - ] - ) - ] -) @Suppress("unused") +@Deprecated("This patch has been merged into HidePlayerOverlayButtonsPatch.") object HideCaptionsButtonPatch : BytecodePatch( - setOf(SubtitleButtonControllerFingerprint) + dependencies = setOf(HidePlayerOverlayButtonsPatch::class), ) { override fun execute(context: BytecodeContext) { - AddResourcesPatch(this::class) - - SettingsPatch.PreferenceScreen.PLAYER.addPreferences( - SwitchPreference("revanced_hide_captions_button") - ) - - val subtitleButtonControllerMethod = SubtitleButtonControllerFingerprint.result!!.mutableMethod - - // Due to previously applied patches, scanResult index cannot be used in this context - val insertIndex = subtitleButtonControllerMethod.implementation!!.instructions.indexOfFirst { - it.opcode == Opcode.IGET_BOOLEAN - } + 1 - - subtitleButtonControllerMethod.addInstruction( - insertIndex, - """ - invoke-static {v0}, Lapp/revanced/integrations/youtube/patches/HideCaptionsButtonPatch;->hideCaptionsButton(Landroid/widget/ImageView;)V - """ - ) } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt index aaec98701c..7a8aec8d14 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/cast/HideCastButtonPatch.kt @@ -1,47 +1,14 @@ package app.revanced.patches.youtube.layout.buttons.cast import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchException -import app.revanced.patcher.patch.annotation.CompatiblePackage -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.misc.settings.preference.SwitchPreference -import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch -import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.patches.youtube.layout.buttons.overlay.HidePlayerOverlayButtonsPatch -@Patch( - name = "Hide cast button", - description = "Adds an option to hide the cast button in the video player.", - dependencies = [ - IntegrationsPatch::class, - SettingsPatch::class, - AddResourcesPatch::class, - ], - compatiblePackages = [ - CompatiblePackage("com.google.android.youtube"), - ], -) -object HideCastButtonPatch : BytecodePatch(emptySet()) { +@Suppress("unused") +@Deprecated("This patch has been merged into HidePlayerOverlayButtonsPatch.") +object HideCastButtonPatch : BytecodePatch( + dependencies = setOf(HidePlayerOverlayButtonsPatch::class), +) { override fun execute(context: BytecodeContext) { - AddResourcesPatch(this::class) - - SettingsPatch.PreferenceScreen.PLAYER.addPreferences( - SwitchPreference("revanced_hide_cast_button") - ) - - val buttonClass = context.findClass("MediaRouteButton") - ?: throw PatchException("MediaRouteButton class not found.") - - buttonClass.mutableClass.methods.find { it.name == "setVisibility" }?.apply { - addInstructions( - 0, - """ - invoke-static {p1}, Lapp/revanced/integrations/youtube/patches/HideCastButtonPatch;->getCastButtonOverrideV2(I)I - move-result p1 - """, - ) - } ?: throw PatchException("setVisibility method not found.") } -} +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt new file mode 100644 index 0000000000..1cc48c63f1 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsPatch.kt @@ -0,0 +1,151 @@ +package app.revanced.patches.youtube.layout.buttons.overlay + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.all.misc.resources.AddResourcesPatch +import app.revanced.patches.shared.misc.settings.preference.SwitchPreference +import app.revanced.patches.youtube.layout.buttons.overlay.fingerprints.MediaRouteButtonFingerprint +import app.revanced.patches.youtube.layout.buttons.overlay.fingerprints.PlayerControlsPreviousNextOverlayTouchFingerprint +import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch +import app.revanced.patches.youtube.misc.settings.SettingsPatch +import app.revanced.patches.youtube.shared.fingerprints.LayoutConstructorFingerprint +import app.revanced.patches.youtube.shared.fingerprints.SubtitleButtonControllerFingerprint +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstructionOrThrow +import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow +import app.revanced.util.indexOfIdResourceOrThrow +import app.revanced.util.resultOrThrow +import com.android.tools.smali.dexlib2.Opcode +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.reference.MethodReference + +@Patch( + name = "Hide player overlay buttons", + description = "Adds options to hide the player cast, autoplay, caption button and next/ previous buttons.", + dependencies = [ + IntegrationsPatch::class, + SettingsPatch::class, + AddResourcesPatch::class, + HidePlayerOverlayButtonsResourcePatch::class, + ], + compatiblePackages = [ + CompatiblePackage( + "com.google.android.youtube", + [ + "18.38.44", + "18.49.37", + "19.16.39", + "19.25.37", + "19.34.42", + ] + ) + ] +) +@Suppress("unused") +object HidePlayerOverlayButtonsPatch : BytecodePatch( + setOf( + PlayerControlsPreviousNextOverlayTouchFingerprint, + MediaRouteButtonFingerprint, + SubtitleButtonControllerFingerprint, + LayoutConstructorFingerprint + ) +) { + + private const val INTEGRATIONS_CLASS_DESCRIPTOR = + "Lapp/revanced/integrations/youtube/patches/HidePlayerOverlayButtonsPatch;" + + override fun execute(context: BytecodeContext) { + AddResourcesPatch(this::class) + + SettingsPatch.PreferenceScreen.PLAYER.addPreferences( + SwitchPreference("revanced_hide_player_previous_next_buttons"), + SwitchPreference("revanced_hide_cast_button"), + SwitchPreference("revanced_hide_captions_button"), + SwitchPreference("revanced_hide_autoplay_button"), + ) + + // region hide player next/previous button + + PlayerControlsPreviousNextOverlayTouchFingerprint.resultOrThrow().mutableMethod.apply { + val resourceIndex = indexOfFirstWideLiteralInstructionValueOrThrow( + HidePlayerOverlayButtonsResourcePatch.playerControlPreviousButtonTouchArea + ) + + val insertIndex = indexOfFirstInstructionOrThrow(resourceIndex) { + opcode == Opcode.INVOKE_STATIC + && getReference()?.parameterTypes?.firstOrNull() == "Landroid/view/View;" + } + + val viewRegister = getInstruction(insertIndex).registerC + + addInstruction( + insertIndex, + "invoke-static { v$viewRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR" + + "->hidePreviousNextButtons(Landroid/view/View;)V" + ) + } + + // endregion + + // region hide cast button + + MediaRouteButtonFingerprint.resultOrThrow().mutableMethod.addInstructions( + 0, + """ + invoke-static { p1 }, $INTEGRATIONS_CLASS_DESCRIPTOR->getCastButtonOverrideV2(I)I + move-result p1 + """ + ) + + // endregion + + // region hide captions button + + SubtitleButtonControllerFingerprint.resultOrThrow().mutableMethod.apply { + // Due to previously applied patches, scanResult index cannot be used in this context + val insertIndex = indexOfFirstInstructionOrThrow(Opcode.IGET_BOOLEAN) + 1 + + addInstruction( + insertIndex, + "invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->hideCaptionsButton(Landroid/widget/ImageView;)V" + ) + } + + // endregion + + // region hide auto play button + + LayoutConstructorFingerprint.resultOrThrow().mutableMethod.apply { + val constIndex = indexOfIdResourceOrThrow("autonav_toggle") + val constRegister = getInstruction(constIndex).registerA + + // Add a conditional branch around the code that inflates and adds the auto repeat button. + val gotoIndex = indexOfFirstInstructionOrThrow(constIndex) { + val parameterTypes = getReference()?.parameterTypes + opcode == Opcode.INVOKE_VIRTUAL && + parameterTypes?.size == 2 && + parameterTypes.first() == "Landroid/view/ViewStub;" + } + 1 + + addInstructionsWithLabels( + constIndex, + """ + invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->hideAutoPlayButton()Z + move-result v$constRegister + if-nez v$constRegister, :hidden + """, + ExternalLabel("hidden", getInstruction(gotoIndex)), + ) + } + + // endregion + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsResourcePatch.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsResourcePatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsResourcePatch.kt index 7bd23b17a1..4b997d7891 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/HidePlayerOverlayButtonsResourcePatch.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.buttons.player.hide +package app.revanced.patches.youtube.layout.buttons.overlay import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.ResourcePatch @@ -6,7 +6,7 @@ import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch @Patch(dependencies = [ResourceMappingPatch::class]) -internal object HidePlayerButtonsResourcePatch : ResourcePatch() { +internal object HidePlayerOverlayButtonsResourcePatch : ResourcePatch() { var playerControlPreviousButtonTouchArea = -1L var playerControlNextButtonTouchArea = -1L diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/fingerprints/MediaRouteButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/fingerprints/MediaRouteButtonFingerprint.kt new file mode 100644 index 0000000000..69e2815452 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/fingerprints/MediaRouteButtonFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.youtube.layout.buttons.overlay.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object MediaRouteButtonFingerprint : MethodFingerprint ( + parameters = listOf("I"), + customFingerprint = { methodDef, _ -> + methodDef.definingClass.endsWith("/MediaRouteButton;") && methodDef.name == "setVisibility" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/fingerprints/PlayerControlsPreviousNextOverlayTouchFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/fingerprints/PlayerControlsPreviousNextOverlayTouchFingerprint.kt similarity index 63% rename from src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/fingerprints/PlayerControlsPreviousNextOverlayTouchFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/fingerprints/PlayerControlsPreviousNextOverlayTouchFingerprint.kt index 131bf47130..46270b516e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/fingerprints/PlayerControlsPreviousNextOverlayTouchFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/overlay/fingerprints/PlayerControlsPreviousNextOverlayTouchFingerprint.kt @@ -1,8 +1,8 @@ -package app.revanced.patches.youtube.layout.buttons.player.hide.fingerprints +package app.revanced.patches.youtube.layout.buttons.overlay.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint -import app.revanced.patches.youtube.layout.buttons.player.hide.HidePlayerButtonsResourcePatch +import app.revanced.patches.youtube.layout.buttons.overlay.HidePlayerOverlayButtonsResourcePatch import app.revanced.util.containsWideLiteralInstructionValue import com.android.tools.smali.dexlib2.AccessFlags @@ -12,9 +12,9 @@ internal object PlayerControlsPreviousNextOverlayTouchFingerprint : MethodFinger strings = listOf("1.0x"), customFingerprint = { methodDef, _ -> methodDef.containsWideLiteralInstructionValue( - HidePlayerButtonsResourcePatch.playerControlPreviousButtonTouchArea + HidePlayerOverlayButtonsResourcePatch.playerControlPreviousButtonTouchArea ) && methodDef.containsWideLiteralInstructionValue( - HidePlayerButtonsResourcePatch.playerControlNextButtonTouchArea + HidePlayerOverlayButtonsResourcePatch.playerControlNextButtonTouchArea ) } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt index 9581f8f8ac..e8707a39b9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch.kt @@ -1,74 +1,13 @@ package app.revanced.patches.youtube.layout.buttons.player.hide import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotation.CompatiblePackage -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.all.misc.resources.AddResourcesPatch -import app.revanced.patches.shared.misc.settings.preference.SwitchPreference -import app.revanced.patches.youtube.layout.buttons.player.hide.fingerprints.PlayerControlsPreviousNextOverlayTouchFingerprint -import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch -import app.revanced.patches.youtube.misc.settings.SettingsPatch -import app.revanced.util.getReference -import app.revanced.util.indexOfFirstInstructionOrThrow -import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow -import app.revanced.util.resultOrThrow -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -import com.android.tools.smali.dexlib2.iface.reference.MethodReference +import app.revanced.patches.youtube.layout.buttons.overlay.HidePlayerOverlayButtonsPatch -@Patch( - name = "Hide player buttons", - description = "Adds an option to hide the previous and next buttons in the video player.", - dependencies = [ - IntegrationsPatch::class, - SettingsPatch::class, - AddResourcesPatch::class, - HidePlayerButtonsResourcePatch::class, - ], - compatiblePackages = [ - CompatiblePackage( - "com.google.android.youtube", - [ - "18.38.44", - "18.49.37", - "19.16.39", - "19.25.37", - "19.34.42", - ] - ) - ] -) -@Suppress("unused") +@Deprecated("This patch has been merged into HidePlayerOverlayButtonsPatch.") object HidePlayerButtonsPatch : BytecodePatch( - setOf(PlayerControlsPreviousNextOverlayTouchFingerprint) + dependencies = setOf(HidePlayerOverlayButtonsPatch::class), ) { override fun execute(context: BytecodeContext) { - AddResourcesPatch(this::class) - - SettingsPatch.PreferenceScreen.PLAYER.addPreferences( - SwitchPreference("revanced_hide_player_buttons") - ) - - PlayerControlsPreviousNextOverlayTouchFingerprint.resultOrThrow().mutableMethod.apply { - val resourceIndex = indexOfFirstWideLiteralInstructionValueOrThrow( - HidePlayerButtonsResourcePatch.playerControlPreviousButtonTouchArea - ) - - val insertIndex = indexOfFirstInstructionOrThrow(resourceIndex) { - opcode == Opcode.INVOKE_STATIC - && getReference()?.parameterTypes?.firstOrNull() == "Landroid/view/View;" - } - - val viewRegister = getInstruction(insertIndex).registerC - - addInstruction( - insertIndex, - "invoke-static { v$viewRegister }, Lapp/revanced/integrations/youtube/patches/HidePlayerButtonsPatch;" + - "->hidePreviousNextButtons(Landroid/view/View;)V" - ) - } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt index 5ecd694f8d..e8f72052cf 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.youtube.misc.gms import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch -import app.revanced.patches.youtube.layout.buttons.cast.HideCastButtonPatch +import app.revanced.patches.youtube.layout.buttons.overlay.HidePlayerOverlayButtonsPatch import app.revanced.patches.youtube.misc.fix.playback.SpoofVideoStreamsPatch import app.revanced.patches.youtube.misc.gms.Constants.REVANCED_YOUTUBE_PACKAGE_NAME import app.revanced.patches.youtube.misc.gms.Constants.YOUTUBE_PACKAGE_NAME @@ -22,7 +22,7 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( mainActivityOnCreateFingerprint = MainActivityOnCreateFingerprint, integrationsPatchDependency = IntegrationsPatch::class, dependencies = setOf( - HideCastButtonPatch::class, + HidePlayerOverlayButtonsPatch::class, // Hide non functional cast button. SpoofVideoStreamsPatch::class, ), gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/SubtitleButtonControllerFingerprint.kt similarity index 91% rename from src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/SubtitleButtonControllerFingerprint.kt index 6379cb6707..e840e446b3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/autocaptions/fingerprints/SubtitleButtonControllerFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/shared/fingerprints/SubtitleButtonControllerFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.layout.autocaptions.fingerprints +package app.revanced.patches.youtube.shared.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/resources/addresources/values/strings.xml b/src/main/resources/addresources/values/strings.xml index d08ae90ea1..fab3feb621 100644 --- a/src/main/resources/addresources/values/strings.xml +++ b/src/main/resources/addresources/values/strings.xml @@ -430,22 +430,6 @@ This is because Crowdin requires temporarily flattening this file and removing t Save to playlist button is hidden Save to playlist button is shown - - Hide autoplay button - Autoplay button is hidden - Autoplay button is shown - - - - Hide captions button - Captions button is hidden - Captions button is shown - - - Hide cast button - Cast button is hidden - Cast button is shown - Navigation buttons Hide or change buttons in the navigation bar @@ -518,10 +502,20 @@ This is because Crowdin requires temporarily flattening this file and removing t Watch in VR menu is hidden Watch in VR menu is shown - - Hide previous & next video buttons - Buttons are hidden - Buttons are shown + + Hide previous & next video buttons + Buttons are hidden + Buttons are shown + Hide cast button + Cast button is hidden + Cast button is shown + + Hide captions button + Captions button is hidden + Captions button is shown + Hide autoplay button + Autoplay button is hidden + Autoplay button is shown Hide album cards