|
| 1 | +package app.revanced.integrations.patches; |
| 2 | + |
| 3 | +import android.os.Handler; |
| 4 | +import android.os.Looper; |
| 5 | +import android.util.Log; |
| 6 | +import android.view.View; |
| 7 | +import android.view.ViewGroup; |
| 8 | +import android.widget.ListView; |
| 9 | +import android.widget.RelativeLayout; |
| 10 | + |
| 11 | +import java.util.Arrays; |
| 12 | + |
| 13 | +import app.revanced.integrations.settings.SettingsEnum; |
| 14 | +import app.revanced.integrations.utils.LogHelper; |
| 15 | + |
| 16 | +public class OldQualityLayoutPatch { |
| 17 | + // TODO: hide listView, OnHierarchyChange will not be triggered though |
| 18 | + public static void showOldQualityMenu(ListView listView) |
| 19 | + { |
| 20 | + if (!SettingsEnum.OLD_STYLE_QUALITY_SETTINGS.getBoolean()) return; |
| 21 | + |
| 22 | + listView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() { |
| 23 | + @Override |
| 24 | + public void onChildViewAdded(View parent, View child) { |
| 25 | + LogHelper.debug(OldQualityLayoutPatch.class, "Added: " + child); |
| 26 | + |
| 27 | + final var indexOfAdvancedQualityMenuItem = 4; |
| 28 | + if (listView.indexOfChild(child) != indexOfAdvancedQualityMenuItem) return; |
| 29 | + |
| 30 | + LogHelper.debug(OldQualityLayoutPatch.class, "Found advanced menu: " + child); |
| 31 | + |
| 32 | + final var qualityItemMenuPosition = 4; |
| 33 | + listView.performItemClick(null, qualityItemMenuPosition, 0); |
| 34 | + } |
| 35 | + |
| 36 | + @Override |
| 37 | + public void onChildViewRemoved(View parent, View child) {} |
| 38 | + }); |
| 39 | + } |
| 40 | +} |
0 commit comments