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 71f40393..7499aa29 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 @@ -91,99 +91,6 @@ public class ReturnYouTubeDislikePatch { // while a regular video is on screen. } - // - // 17.x non litho regular video player. - // - - /** - * Resource identifier of old UI dislike button. - */ - private static final int OLD_UI_DISLIKE_BUTTON_RESOURCE_ID - = Utils.getResourceIdentifier("dislike_button", "id"); - - /** - * Dislikes text label used by old UI. - */ - @NonNull - private static WeakReference oldUITextViewRef = new WeakReference<>(null); - - /** - * Original old UI 'Dislikes' text before patch modifications. - * Required to reset the dislikes when changing videos and RYD is not available. - * Set only once during the first load. - */ - private static Spanned oldUIOriginalSpan; - - /** - * Replacement span that contains dislike value. Used by {@link #oldUiTextWatcher}. - */ - @Nullable - private static Spanned oldUIReplacementSpan; - - /** - * Old UI dislikes can be set multiple times by YouTube. - * To prevent reverting changes made here, this listener overrides any future changes YouTube makes. - */ - private static final TextWatcher oldUiTextWatcher = new TextWatcher() { - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - public void afterTextChanged(Editable s) { - if (oldUIReplacementSpan == null || oldUIReplacementSpan.toString().equals(s.toString())) { - return; - } - s.replace(0, s.length(), oldUIReplacementSpan); // Causes a recursive call back into this listener - } - }; - - private static void updateOldUIDislikesTextView() { - ReturnYouTubeDislike videoData = currentVideoData; - if (videoData == null) { - return; - } - TextView oldUITextView = oldUITextViewRef.get(); - if (oldUITextView == null) { - return; - } - oldUIReplacementSpan = videoData.getDislikesSpanForRegularVideo(oldUIOriginalSpan, false, false); - if (!oldUIReplacementSpan.equals(oldUITextView.getText())) { - oldUITextView.setText(oldUIReplacementSpan); - } - } - - /** - * Injection point. Called on main thread. - * - * Used when spoofing to 16.x and 17.x versions. - */ - public static void setOldUILayoutDislikes(int buttonViewResourceId, @Nullable TextView textView) { - try { - if (!Settings.RYD_ENABLED.get() - || buttonViewResourceId != OLD_UI_DISLIKE_BUTTON_RESOURCE_ID - || textView == null) { - return; - } - Logger.printDebug(() -> "setOldUILayoutDislikes"); - - if (oldUIOriginalSpan == null) { - // Use value of the first instance, as it appears TextViews can be recycled - // and might contain dislikes previously added by the patch. - oldUIOriginalSpan = (Spanned) textView.getText(); - } - oldUITextViewRef = new WeakReference<>(textView); - // No way to check if a listener is already attached, so remove and add again. - textView.removeTextChangedListener(oldUiTextWatcher); - textView.addTextChangedListener(oldUiTextWatcher); - - updateOldUIDislikesTextView(); - - } catch (Exception ex) { - Logger.printException(() -> "setOldUILayoutDislikes failure", ex); - } - } - - // // Litho player for both regular videos and Shorts. // @@ -690,11 +597,8 @@ public class ReturnYouTubeDislikePatch { if (v.value == vote) { videoData.sendVote(v); - if (isNoneHiddenOrMinimized) { - if (lastLithoShortsVideoData != null) { - lithoShortsShouldUseCurrentData = true; - } - updateOldUIDislikesTextView(); + if (isNoneHiddenOrMinimized && lastLithoShortsVideoData != null) { + lithoShortsShouldUseCurrentData = true; } return; diff --git a/app/src/main/java/app/revanced/integrations/youtube/shared/PlayerType.kt b/app/src/main/java/app/revanced/integrations/youtube/shared/PlayerType.kt index 7db4a3fd..9a5275b6 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/shared/PlayerType.kt +++ b/app/src/main/java/app/revanced/integrations/youtube/shared/PlayerType.kt @@ -21,9 +21,6 @@ enum class PlayerType { /** * A regular video is minimized. - * - * When spoofing to 16.x YouTube and watching a short with a regular video in the background, - * the type can be this (and not [HIDDEN]). */ WATCH_WHILE_MINIMIZED, WATCH_WHILE_MAXIMIZED, @@ -87,9 +84,8 @@ enum class PlayerType { * Check if the current player type is [NONE] or [HIDDEN]. * Useful to check if a short is currently playing. * - * Does not include the first moment after a short is opened when a regular video is minimized on screen, - * or while watching a short with a regular video present on a spoofed 16.x version of YouTube. - * To include those situations instead use [isNoneHiddenOrMinimized]. + * Does not include the first moment after a short is opened when a regular video is minimized on screen. + * To include that, instead use [isNoneHiddenOrMinimized]. * * @see VideoInformation */ @@ -103,9 +99,7 @@ enum class PlayerType { * * Useful to check if a Short is being played or opened. * - * Usually covers all use cases with no false positives, except if called from some hooks - * when spoofing to an old version this will return false even - * though a Short is being opened or is on screen (see [isNoneHiddenOrMinimized]). + * Usually covers all use cases with no false positives. * * @return If nothing, a Short, or a regular video is sliding off screen to a dismissed or hidden state. * @see VideoInformation