fix: old-quality-layout patch

This commit is contained in:
oSumAtrIX 2022-07-17 15:58:13 +02:00
parent 887bcff415
commit 5a5e8824c5
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 40 additions and 11 deletions

View File

@ -0,0 +1,40 @@
package app.revanced.integrations.patches;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.RelativeLayout;
import java.util.Arrays;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
public class OldQualityLayoutPatch {
// TODO: hide listView, OnHierarchyChange will not be triggered though
public static void showOldQualityMenu(ListView listView)
{
if (!SettingsEnum.OLD_STYLE_QUALITY_SETTINGS.getBoolean()) return;
listView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
@Override
public void onChildViewAdded(View parent, View child) {
LogHelper.debug(OldQualityLayoutPatch.class, "Added: " + child);
final var indexOfAdvancedQualityMenuItem = 4;
if (listView.indexOfChild(child) != indexOfAdvancedQualityMenuItem) return;
LogHelper.debug(OldQualityLayoutPatch.class, "Found advanced menu: " + child);
final var qualityItemMenuPosition = 4;
listView.performItemClick(null, qualityItemMenuPosition, 0);
}
@Override
public void onChildViewRemoved(View parent, View child) {}
});
}
}

View File

@ -1,11 +0,0 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class OldStyleQualityPatch {
//Used by app.revanced.patches.youtube.layout.oldqualitylayout.patch.OldQualityLayoutPatch
public static boolean useOldStyleQualitySettings() {
return SettingsEnum.OLD_STYLE_QUALITY_SETTINGS.getBoolean();
}
}