From e30d1201c992f4896a0b7106230377d78506cd6f Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 13 May 2023 21:44:08 +0400 Subject: [PATCH] fix(youtube/remember-video-quality): do not show 'auto' in video resolution picker if a default quality is set (#400) --- .../quality/RememberVideoQualityPatch.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java b/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java index 8da4a4af..4406e5a2 100644 --- a/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch.java @@ -110,15 +110,25 @@ public class RememberVideoQualityPatch { } i++; } + + // If the desired quality index is equal to the original index, + // then the video is already set to the desired default quality. + // + // The method could return here, but the UI video quality flyout will still + // show 'Auto' (ie: Auto (480p)) + // It appears that "Auto" picks the resolution on video load, + // and it does not appear to change the resolution during playback. + // + // To prevent confusion, set the video index anyways (even if it matches the existing index) + // As that will force the UI picker to not display "Auto" which may confuse the user. if (qualityIndexToUse == originalQualityIndex) { LogHelper.printDebug(() -> "Video is already preferred quality: " + preferredQuality); - return originalQualityIndex; + } else { + final int qualityToUseLog = qualityToUse; + LogHelper.printDebug(() -> "Quality changed from: " + + videoQualities.get(originalQualityIndex) + " to: " + qualityToUseLog); } - final int qualityToUseLog = qualityToUse; - LogHelper.printDebug(() -> "Quality changed from: " - + videoQualities.get(originalQualityIndex) + " to: " + qualityToUseLog); - Method m = qInterface.getClass().getMethod(qIndexMethod, Integer.TYPE); m.invoke(qInterface, qualityToUse); return qualityIndexToUse;