mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-18 11:57:18 +01:00
76 lines
3 KiB
Java
76 lines
3 KiB
Java
package com.google.android.material.internal;
|
|
|
|
import android.R;
|
|
import android.content.Context;
|
|
import android.view.Window;
|
|
import androidx.annotation.ColorInt;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.core.view.WindowCompat;
|
|
import com.google.android.material.color.MaterialColors;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
/* loaded from: classes7.dex */
|
|
public class EdgeToEdgeUtils {
|
|
private static final int EDGE_TO_EDGE_BAR_ALPHA = 128;
|
|
|
|
private EdgeToEdgeUtils() {
|
|
}
|
|
|
|
public static void applyEdgeToEdge(@NonNull Window window, boolean z, @Nullable @ColorInt Integer num, @Nullable @ColorInt Integer num2) {
|
|
boolean z2 = num == null || num.intValue() == 0;
|
|
boolean z3 = num2 == null || num2.intValue() == 0;
|
|
if (z2 || z3) {
|
|
int color = MaterialColors.getColor(window.getContext(), R.attr.colorBackground, ViewCompat.MEASURED_STATE_MASK);
|
|
if (z2) {
|
|
num = Integer.valueOf(color);
|
|
}
|
|
if (z3) {
|
|
num2 = Integer.valueOf(color);
|
|
}
|
|
}
|
|
WindowCompat.setDecorFitsSystemWindows(window, !z);
|
|
int statusBarColor = getStatusBarColor(window.getContext(), z);
|
|
int navigationBarColor = getNavigationBarColor(window.getContext(), z);
|
|
window.setStatusBarColor(statusBarColor);
|
|
window.setNavigationBarColor(navigationBarColor);
|
|
setLightStatusBar(window, isUsingLightSystemBar(statusBarColor, MaterialColors.isColorLight(num.intValue())));
|
|
setLightNavigationBar(window, isUsingLightSystemBar(navigationBarColor, MaterialColors.isColorLight(num2.intValue())));
|
|
}
|
|
|
|
private static int getNavigationBarColor(Context context, boolean z) {
|
|
if (z) {
|
|
return 0;
|
|
}
|
|
return MaterialColors.getColor(context, R.attr.navigationBarColor, ViewCompat.MEASURED_STATE_MASK);
|
|
}
|
|
|
|
private static int getStatusBarColor(Context context, boolean z) {
|
|
if (z) {
|
|
return 0;
|
|
}
|
|
return MaterialColors.getColor(context, R.attr.statusBarColor, ViewCompat.MEASURED_STATE_MASK);
|
|
}
|
|
|
|
private static boolean isUsingLightSystemBar(int i, boolean z) {
|
|
if (MaterialColors.isColorLight(i)) {
|
|
return true;
|
|
}
|
|
return i == 0 && z;
|
|
}
|
|
|
|
public static void setLightNavigationBar(@NonNull Window window, boolean z) {
|
|
WindowCompat.getInsetsController(window, window.getDecorView()).setAppearanceLightNavigationBars(z);
|
|
}
|
|
|
|
public static void setLightStatusBar(@NonNull Window window, boolean z) {
|
|
WindowCompat.getInsetsController(window, window.getDecorView()).setAppearanceLightStatusBars(z);
|
|
}
|
|
|
|
public static void applyEdgeToEdge(@NonNull Window window, boolean z) {
|
|
applyEdgeToEdge(window, z, null, null);
|
|
}
|
|
}
|