From 7382a020b8322a7abc016a4569bc15f9caf05546 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:43:29 +0400 Subject: [PATCH] fix(YouTube - Settings): Do not clip settings menus when using an Android 15 device (#3999) --- .../preference/AbstractPreferenceFragment.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/extensions/shared/src/main/java/app/revanced/extension/shared/settings/preference/AbstractPreferenceFragment.java b/extensions/shared/src/main/java/app/revanced/extension/shared/settings/preference/AbstractPreferenceFragment.java index 038dfefaf..b7dd65063 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/shared/settings/preference/AbstractPreferenceFragment.java +++ b/extensions/shared/src/main/java/app/revanced/extension/shared/settings/preference/AbstractPreferenceFragment.java @@ -8,12 +8,14 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.SharedPreferences; +import android.graphics.Insets; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; import android.preference.*; import android.util.TypedValue; import android.view.ViewGroup; +import android.view.WindowInsets; import android.widget.TextView; import android.widget.Toolbar; @@ -310,6 +312,18 @@ public abstract class AbstractPreferenceFragment extends PreferenceFragment { .findViewById(android.R.id.content) .getParent(); + // Fix required for Android 15 and YT 19.45+ + // FIXME: + // On Android 15 the text layout is not aligned the same as the parent + // screen and it looks a little off. Otherwise this works. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + rootView.setOnApplyWindowInsetsListener((v, insets) -> { + Insets statusInsets = insets.getInsets(WindowInsets.Type.statusBars()); + v.setPadding(0, statusInsets.top, 0, 0); + return insets; + }); + } + Toolbar toolbar = new Toolbar(childScreen.getContext()); toolbar.setTitle(childScreen.getTitle()); toolbar.setNavigationIcon(getBackButtonDrawable());