From c0dc162ad0e67a7f8f4477fece5e4bdd6cd4ce90 Mon Sep 17 00:00:00 2001 From: pubiqq Date: Thu, 20 Mar 2025 05:07:06 +0300 Subject: [PATCH] [Catalog] Fix BottomWindowInsetView --- .../catalog/feature/BottomWindowInsetView.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/catalog/java/io/material/catalog/feature/BottomWindowInsetView.java b/catalog/java/io/material/catalog/feature/BottomWindowInsetView.java index 66e356eedb1..379151c40b5 100644 --- a/catalog/java/io/material/catalog/feature/BottomWindowInsetView.java +++ b/catalog/java/io/material/catalog/feature/BottomWindowInsetView.java @@ -20,9 +20,10 @@ import android.content.Context; import android.util.AttributeSet; import android.view.View; -import android.view.ViewGroup; import androidx.annotation.Nullable; +import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; /** * A View that measures itself to be as tall as the bottom window inset. @@ -48,19 +49,12 @@ public BottomWindowInsetView(Context context, @Nullable AttributeSet attrs, @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - ViewGroup parent = (ViewGroup) getParent(); - while (parent != null && !parent.getFitsSystemWindows()) { - parent = (ViewGroup) parent.getParent(); - } - - if (parent == null) { - return; - } - ViewCompat.setOnApplyWindowInsetsListener( - parent, + this, (v, insets) -> { - systemWindowInsetBottom = insets.getSystemWindowInsetBottom(); + Insets systemWindowInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()); + systemWindowInsetBottom = systemWindowInsets.bottom; + super.setVisibility(systemWindowInsetBottom == 0 ? GONE : VISIBLE); if (systemWindowInsetBottom > 0) { requestLayout();