alexandroid/decompiled/jadx/sources/com/th3rdwave/safeareacontext/SafeAreaUtilsKt.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

79 lines
4.5 KiB
Java

package com.th3rdwave.safeareacontext;
import android.graphics.Insets;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import androidx.annotation.RequiresApi;
import kotlin.Metadata;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Metadata(d1 = {"\u0000\u001a\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\u001a\u0012\u0010\u0000\u001a\u0004\u0018\u00010\u00012\u0006\u0010\u0002\u001a\u00020\u0003H\u0003\u001a\u0012\u0010\u0004\u001a\u0004\u0018\u00010\u00012\u0006\u0010\u0002\u001a\u00020\u0003H\u0003\u001a\u0012\u0010\u0005\u001a\u0004\u0018\u00010\u00012\u0006\u0010\u0002\u001a\u00020\u0003H\u0002\u001a\u0012\u0010\u0006\u001a\u0004\u0018\u00010\u00012\u0006\u0010\u0002\u001a\u00020\u0003H\u0002\u001a\u0010\u0010\u0007\u001a\u0004\u0018\u00010\u00012\u0006\u0010\b\u001a\u00020\u0003\u001a\u0018\u0010\t\u001a\u0004\u0018\u00010\n2\u0006\u0010\u0002\u001a\u00020\u000b2\u0006\u0010\b\u001a\u00020\u0003¨\u0006\f"}, d2 = {"getRootWindowInsetsCompatR", "Lcom/th3rdwave/safeareacontext/EdgeInsets;", "rootView", "Landroid/view/View;", "getRootWindowInsetsCompatM", "getRootWindowInsetsCompatBase", "getRootWindowInsetsCompat", "getSafeAreaInsets", "view", "getFrame", "Lcom/th3rdwave/safeareacontext/Rect;", "Landroid/view/ViewGroup;", "react-native-safe-area-context_release"}, k = 2, mv = {2, 1, 0}, xi = 48)
/* loaded from: classes9.dex */
public final class SafeAreaUtilsKt {
@Nullable
public static final Rect getFrame(@NotNull ViewGroup viewGroup, @NotNull View view) {
viewGroup.getClass();
view.getClass();
if (view.getParent() == null) {
return null;
}
android.graphics.Rect rect = new android.graphics.Rect();
view.getDrawingRect(rect);
try {
viewGroup.offsetDescendantRectToMyCoords(view, rect);
return new Rect(rect.left, rect.top, view.getWidth(), view.getHeight());
} catch (IllegalArgumentException e) {
e.printStackTrace();
return null;
}
}
private static final EdgeInsets getRootWindowInsetsCompat(View view) {
return Build.VERSION.SDK_INT >= 30 ? getRootWindowInsetsCompatR(view) : getRootWindowInsetsCompatM(view);
}
private static final EdgeInsets getRootWindowInsetsCompatBase(View view) {
view.getWindowVisibleDisplayFrame(new android.graphics.Rect());
return new EdgeInsets(r0.top, view.getWidth() - r0.right, view.getHeight() - r0.bottom, r0.left);
}
@RequiresApi(23)
private static final EdgeInsets getRootWindowInsetsCompatM(View view) {
if (view.getRootWindowInsets() == null) {
return null;
}
return new EdgeInsets(r5.getSystemWindowInsetTop(), r5.getSystemWindowInsetRight(), Math.min(r5.getSystemWindowInsetBottom(), r5.getStableInsetBottom()), r5.getSystemWindowInsetLeft());
}
@RequiresApi(30)
private static final EdgeInsets getRootWindowInsetsCompatR(View view) {
Insets insets;
WindowInsets rootWindowInsets = view.getRootWindowInsets();
if (rootWindowInsets == null || (insets = rootWindowInsets.getInsets(WindowInsets.Type.statusBars() | WindowInsets.Type.displayCutout() | WindowInsets.Type.navigationBars() | WindowInsets.Type.captionBar())) == null) {
return null;
}
return new EdgeInsets(insets.top, insets.right, insets.bottom, insets.left);
}
@Nullable
public static final EdgeInsets getSafeAreaInsets(@NotNull View view) {
view.getClass();
if (view.getHeight() == 0) {
return null;
}
View rootView = view.getRootView();
rootView.getClass();
EdgeInsets rootWindowInsetsCompat = getRootWindowInsetsCompat(rootView);
if (rootWindowInsetsCompat == null) {
return null;
}
float width = rootView.getWidth();
float height = rootView.getHeight();
view.getGlobalVisibleRect(new android.graphics.Rect());
return new EdgeInsets(Math.max(rootWindowInsetsCompat.getTop() - r3.top, 0.0f), Math.max(rootWindowInsetsCompat.getRight() + Math.min((view.getWidth() + r3.left) - width, 0.0f), 0.0f), Math.max(rootWindowInsetsCompat.getBottom() + Math.min((view.getHeight() + r3.top) - height, 0.0f), 0.0f), Math.max(rootWindowInsetsCompat.getLeft() - r3.left, 0.0f));
}
}