1
mirror of https://github.com/revanced/revanced-integrations synced 2024-11-14 07:47:33 +01:00

fix: quick quality list flyout view visibility in old-quality-layout patch (#86)

This commit is contained in:
OxrxL 2022-07-19 01:58:49 +02:00 committed by GitHub
parent 5549b95825
commit 996434c574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,11 @@
package app.revanced.integrations.patches;
import android.os.Handler;
import android.os.Looper;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ListView;
import android.widget.RelativeLayout;
@ -14,16 +15,27 @@ 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 Window window;
private static boolean hideWindow = true;
public static void showOldQualityMenu(ListView listView)
{
if (!SettingsEnum.OLD_STYLE_QUALITY_SETTINGS.getBoolean()) return;
hideWindow = true;
listView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
@Override
public void onChildViewAdded(View parent, View child) {
LogHelper.debug(OldQualityLayoutPatch.class, "Added: " + child);
parent.setVisibility(View.GONE);
if (window != null && hideWindow) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
hideWindow = false;
}
final var indexOfAdvancedQualityMenuItem = 4;
if (listView.indexOfChild(child) != indexOfAdvancedQualityMenuItem) return;