diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java index 1c66cb930d..71f403931b 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java @@ -235,7 +235,7 @@ private static CharSequence onLithoTextLoaded(@NonNull Object conversionContext, true, isRollingNumber); } else if (!isRollingNumber && conversionContextString.contains("|shorts_dislike_button.eml|")) { // Litho Shorts player. - if (!Settings.RYD_SHORTS.get()) { + if (!Settings.RYD_SHORTS.get() || Settings.HIDE_SHORTS_DISLIKE_BUTTON.get()) { // Must clear the current video here, otherwise if the user opens a regular video // then opens a litho short (while keeping the regular video on screen), then closes the short, // the original video may show the incorrect dislike value. @@ -451,7 +451,7 @@ public static boolean setShortsDislikes(@NonNull View likeDislikeView) { if (!Settings.RYD_ENABLED.get()) { return false; } - if (!Settings.RYD_SHORTS.get()) { + if (!Settings.RYD_SHORTS.get() || Settings.HIDE_SHORTS_DISLIKE_BUTTON.get()) { // Must clear the data here, in case a new video was loaded while PlayerType // suggested the video was not a short (can happen when spoofing to an old app version). clearData(); diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/ShortsFilter.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/ShortsFilter.java index 371fde562a..afb5b76892 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/ShortsFilter.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/ShortsFilter.java @@ -4,12 +4,16 @@ import static app.revanced.integrations.youtube.shared.NavigationBar.NavigationButton; import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; import androidx.annotation.Nullable; import com.google.android.libraries.youtube.rendering.ui.pivotbar.PivotBar; +import app.revanced.integrations.shared.Logger; import app.revanced.integrations.shared.Utils; +import app.revanced.integrations.shared.settings.BooleanSetting; import app.revanced.integrations.youtube.settings.Settings; import app.revanced.integrations.youtube.shared.NavigationBar; import app.revanced.integrations.youtube.shared.PlayerType; @@ -310,6 +314,31 @@ public static void hideShortsShelf(final View shortsShelfView) { // region Hide the buttons in older versions of YouTube. New versions use Litho. + private static void hideTextViewUnderCondition(BooleanSetting setting, View view) { + try { + if (setting.get()) { + TextView textView = (TextView) view; + ViewGroup.LayoutParams params = textView.getLayoutParams(); + params.width = 0; + params.height = 0; + textView.setLayoutParams(params); + } + } catch (Exception ex) { + Logger.printException(() -> "hideTextViewUnderCondition failure", ex); + } + } + + public static void hideLikeButton(final View likeButtonView) { + // Cannot simply set the visibility to gone for like/dislike, + // as some other unknown YT code also sets the visibility after this hook. + // Instead set the layout to a zero size. + hideTextViewUnderCondition(Settings.HIDE_SHORTS_LIKE_BUTTON, likeButtonView); + } + + public static void hideDislikeButton(final View dislikeButtonView) { + hideTextViewUnderCondition(Settings.HIDE_SHORTS_DISLIKE_BUTTON, dislikeButtonView); + } + public static void hideShortsCommentsButton(final View commentsButtonView) { hideViewUnderCondition(Settings.HIDE_SHORTS_COMMENTS_BUTTON, commentsButtonView); }