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) {
|
||||
try {
|
||||
return getContext().getPackageManager().getApplicationInfo(packageName, 0).enabled;
|
||||
} catch (PackageManager.NameNotFoundException ignored) {
|
||||
ApplicationInfo applicationInfo = getApplicationInfo(packageName);
|
||||
if (applicationInfo != null) {
|
||||
return applicationInfo.enabled;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -47,6 +47,26 @@ public class PackageUtils extends 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
|
||||
private static PackageInfo getPackageInfo() {
|
||||
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()) {
|
||||
mPreferenceScreen.setOnPreferenceClickListener(
|
||||
preferenceScreen -> {
|
||||
@ -218,7 +221,7 @@ public class ReVancedPreferenceFragment extends PreferenceFragment {
|
||||
//
|
||||
// Since ReVanced Settings Activity do not use AndroidX libraries,
|
||||
// You will need to manually fix the layout breakage caused by edge-to-edge.
|
||||
if (isSDKAbove(35)) {
|
||||
if (isEdgeToEdgeSupported) {
|
||||
rootView.setOnApplyWindowInsetsListener((v, insets) -> {
|
||||
Insets statusInsets = insets.getInsets(WindowInsets.Type.statusBars());
|
||||
Insets navInsets = insets.getInsets(WindowInsets.Type.navigationBars());
|
||||
|
Loading…
x
Reference in New Issue
Block a user