From b5038586a08006f2acc715e0e2a29ccc71aa3ebd Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Mon, 27 May 2024 20:43:42 +0900 Subject: [PATCH] feat(YouTube/Player components): add setting toggle for `Hide suggested video end screen` https://github.com/inotia00/ReVanced_Extended/issues/2066 --- .../player/overlaybuttons/OverlayButtonsPatch.kt | 2 -- .../SuggestedVideoEndScreenPatch.kt | 5 +++++ .../youtube/settings/host/values/strings.xml | 13 ++++++------- .../youtube/settings/xml/revanced_prefs.xml | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsPatch.kt index 63e1b452c..e34b545af 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsPatch.kt @@ -4,7 +4,6 @@ import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.fix.fullscreen.FullscreenButtonViewStubPatch -import app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.SuggestedVideoEndScreenPatch import app.revanced.patches.youtube.utils.integrations.Constants.OVERLAY_BUTTONS_PATH import app.revanced.patches.youtube.utils.playercontrols.PlayerControlsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch @@ -30,7 +29,6 @@ object OverlayButtonsPatch : BaseResourcePatch( FullscreenButtonViewStubPatch::class, PlayerControlsPatch::class, SettingsPatch::class, - SuggestedVideoEndScreenPatch::class, OverlayButtonsBytecodePatch::class, VideoInformationPatch::class ), diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/suggestedvideoendscreen/SuggestedVideoEndScreenPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/suggestedvideoendscreen/SuggestedVideoEndScreenPatch.kt index 467cc9fd0..fecf05bf8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/suggestedvideoendscreen/SuggestedVideoEndScreenPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/suggestedvideoendscreen/SuggestedVideoEndScreenPatch.kt @@ -7,6 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.utils.fix.suggestedvideoendscreen.fingerprints.RemoveOnLayoutChangeListenerFingerprint +import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndexReversed import app.revanced.util.getWalkerMethod @@ -43,6 +44,10 @@ object SuggestedVideoEndScreenPatch : BytecodePatch( addInstructionsWithLabels( 0, """ + invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->hideSuggestedVideoEndScreen()Z + move-result v0 + if-eqz v0, :show_suggested_video_end_screen + iget-object v0, p0, $iGetObjectReference # This reference checks whether autoplay is turned on. diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 94ec57c32..efb2e6ca2 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -508,16 +508,15 @@ Note: Hide suggested actions Suggested actions hidden. Suggested actions shown. - Hide suggested video end screen - "This setting has been deprecated. - -Instead, use the 'Settings → Autoplay → Autoplay next video' setting. - -Note: -• If you have any issues with 'Suggested video end screen', try restarting the app." Hide timed reactions Timed reactions are hidden. Timed reactions are shown. + Hide suggested video end screen + "Suggested video end screen is hidden when autoplay is turned off. + +Autoplay can be changed in YouTube settings: +'Settings → Autoplay → Autoplay next video'" + Suggested video end screen is shown. Skip autoplay countdown If autoplay is enabled, the next video will play immediately. If autoplay is enabled, the next video will play after the countdown ends. diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 6ad867eb5..2b35c30af 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -407,8 +407,8 @@ - + SETTINGS: PLAYER_COMPONENTS -->