Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix(YouTube - Restore old video quality menu): Show advanced quality …
Browse files Browse the repository at this point in the history
…menu in Shorts quality flyout (#632)
  • Loading branch information
LisoUseInAIKyrios authored May 11, 2024
1 parent 44dea1a commit 77c9825
Showing 1 changed file with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import android.view.ViewGroup;
import android.widget.ListView;

import app.revanced.integrations.shared.Logger;
import app.revanced.integrations.youtube.patches.components.VideoQualityMenuFilterPatch;
import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.shared.Logger;

/**
* This patch contains the logic to show the old video quality menu.
Expand Down Expand Up @@ -44,25 +44,39 @@ public static void onFlyoutMenuCreate(RecyclerView recyclerView) {
}

/**
* Injection point. Only used if spoofing to an old app version.
* Injection point.
*
* Used to force the creation of the advanced menu item for the Shorts quality flyout.
*/
public static boolean forceAdvancedVideoQualityMenuCreation() {
return Settings.RESTORE_OLD_VIDEO_QUALITY_MENU.get();
}

/**
* Injection point.
*
* Used if spoofing to an old app version, and also used for the Shorts video quality flyout.
*/
public static void showOldVideoQualityMenu(final ListView listView) {
if (!Settings.RESTORE_OLD_VIDEO_QUALITY_MENU.get()) return;

listView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
@Override
public void onChildViewAdded(View parent, View child) {
Logger.printDebug(() -> "Added listener to old type of quality menu");
try {
parent.setVisibility(View.GONE);

parent.setVisibility(View.GONE);
final var indexOfAdvancedQualityMenuItem = 4;
if (listView.indexOfChild(child) != indexOfAdvancedQualityMenuItem) return;

final var indexOfAdvancedQualityMenuItem = 4;
if (listView.indexOfChild(child) != indexOfAdvancedQualityMenuItem) return;
Logger.printDebug(() -> "Found advanced menu item in old type of quality menu");

Logger.printDebug(() -> "Found advanced menu item in old type of quality menu");
final var qualityItemMenuPosition = 4;
listView.performItemClick(null, qualityItemMenuPosition, 0);

final var qualityItemMenuPosition = 4;
listView.performItemClick(null, qualityItemMenuPosition, 0);
} catch (Exception ex) {
Logger.printException(() -> "showOldVideoQualityMenu failure", ex);
}
}

@Override
Expand Down

0 comments on commit 77c9825

Please sign in to comment.