74 lines
2.5 KiB
Java
74 lines
2.5 KiB
Java
package androidx.core.view;
|
|
|
|
import android.os.Build;
|
|
import android.view.View;
|
|
import android.view.Window;
|
|
import android.view.WindowInsetsController;
|
|
import androidx.annotation.IdRes;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
public final class WindowCompat {
|
|
public static final int FEATURE_ACTION_BAR = 8;
|
|
public static final int FEATURE_ACTION_BAR_OVERLAY = 9;
|
|
public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
|
|
|
|
@RequiresApi(16)
|
|
public static class Impl16 {
|
|
private Impl16() {
|
|
}
|
|
|
|
public static void setDecorFitsSystemWindows(@NonNull Window window, boolean z2) {
|
|
View decorView = window.getDecorView();
|
|
int systemUiVisibility = decorView.getSystemUiVisibility();
|
|
decorView.setSystemUiVisibility(z2 ? systemUiVisibility & -1793 : systemUiVisibility | 1792);
|
|
}
|
|
}
|
|
|
|
@RequiresApi(30)
|
|
public static class Impl30 {
|
|
private Impl30() {
|
|
}
|
|
|
|
public static WindowInsetsControllerCompat getInsetsController(@NonNull Window window) {
|
|
WindowInsetsController insetsController = window.getInsetsController();
|
|
if (insetsController != null) {
|
|
return WindowInsetsControllerCompat.toWindowInsetsControllerCompat(insetsController);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static void setDecorFitsSystemWindows(@NonNull Window window, boolean z2) {
|
|
window.setDecorFitsSystemWindows(z2);
|
|
}
|
|
}
|
|
|
|
private WindowCompat() {
|
|
}
|
|
|
|
@Nullable
|
|
public static WindowInsetsControllerCompat getInsetsController(@NonNull Window window, @NonNull View view) {
|
|
return Build.VERSION.SDK_INT >= 30 ? Impl30.getInsetsController(window) : new WindowInsetsControllerCompat(window, view);
|
|
}
|
|
|
|
@NonNull
|
|
public static <T extends View> T requireViewById(@NonNull Window window, @IdRes int i) {
|
|
if (Build.VERSION.SDK_INT >= 28) {
|
|
return (T) window.requireViewById(i);
|
|
}
|
|
T t = (T) window.findViewById(i);
|
|
if (t != null) {
|
|
return t;
|
|
}
|
|
throw new IllegalArgumentException("ID does not reference a View inside this Window");
|
|
}
|
|
|
|
public static void setDecorFitsSystemWindows(@NonNull Window window, boolean z2) {
|
|
if (Build.VERSION.SDK_INT >= 30) {
|
|
Impl30.setDecorFitsSystemWindows(window, z2);
|
|
} else {
|
|
Impl16.setDecorFitsSystemWindows(window, z2);
|
|
}
|
|
}
|
|
}
|