mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-29 22:24:31 +02:00
fix(YouTube - Settings): Add a listener only if edge-to-edge display is supported
This commit is contained in:
parent
84b122f628
commit
872db64da1
@ -30,9 +30,9 @@ public class PackageUtils extends Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPackageEnabled(@NonNull String packageName) {
|
public static boolean isPackageEnabled(@NonNull String packageName) {
|
||||||
try {
|
ApplicationInfo applicationInfo = getApplicationInfo(packageName);
|
||||||
return getContext().getPackageManager().getApplicationInfo(packageName, 0).enabled;
|
if (applicationInfo != null) {
|
||||||
} catch (PackageManager.NameNotFoundException ignored) {
|
return applicationInfo.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -47,6 +47,26 @@ public class PackageUtils extends Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// utils
|
// utils
|
||||||
|
@Nullable
|
||||||
|
public static Integer getTargetSDKVersion(@NonNull String packageName) {
|
||||||
|
ApplicationInfo applicationInfo = getApplicationInfo(packageName);
|
||||||
|
if (applicationInfo != null) {
|
||||||
|
return applicationInfo.targetSdkVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static ApplicationInfo getApplicationInfo(@NonNull String packageName) {
|
||||||
|
try {
|
||||||
|
return getContext().getPackageManager().getApplicationInfo(packageName, 0);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
Logger.printException(() -> "Failed to get application Info!" + e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static PackageInfo getPackageInfo() {
|
private static PackageInfo getPackageInfo() {
|
||||||
try {
|
try {
|
||||||
|
@ -197,6 +197,9 @@ public class ReVancedPreferenceFragment extends PreferenceFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer targetSDKVersion = ExtendedUtils.getTargetSDKVersion(getContext().getPackageName());
|
||||||
|
boolean isEdgeToEdgeSupported = isSDKAbove(35) && targetSDKVersion != null && targetSDKVersion >= 35;
|
||||||
|
|
||||||
for (PreferenceScreen mPreferenceScreen : preferenceScreenMap.values()) {
|
for (PreferenceScreen mPreferenceScreen : preferenceScreenMap.values()) {
|
||||||
mPreferenceScreen.setOnPreferenceClickListener(
|
mPreferenceScreen.setOnPreferenceClickListener(
|
||||||
preferenceScreen -> {
|
preferenceScreen -> {
|
||||||
@ -218,7 +221,7 @@ public class ReVancedPreferenceFragment extends PreferenceFragment {
|
|||||||
//
|
//
|
||||||
// Since ReVanced Settings Activity do not use AndroidX libraries,
|
// Since ReVanced Settings Activity do not use AndroidX libraries,
|
||||||
// You will need to manually fix the layout breakage caused by edge-to-edge.
|
// You will need to manually fix the layout breakage caused by edge-to-edge.
|
||||||
if (isSDKAbove(35)) {
|
if (isEdgeToEdgeSupported) {
|
||||||
rootView.setOnApplyWindowInsetsListener((v, insets) -> {
|
rootView.setOnApplyWindowInsetsListener((v, insets) -> {
|
||||||
Insets statusInsets = insets.getInsets(WindowInsets.Type.statusBars());
|
Insets statusInsets = insets.getInsets(WindowInsets.Type.statusBars());
|
||||||
Insets navInsets = insets.getInsets(WindowInsets.Type.navigationBars());
|
Insets navInsets = insets.getInsets(WindowInsets.Type.navigationBars());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user