From 875895524ef412d2e7c87983fb69397daf359997 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Thu, 3 Jun 2021 16:55:31 -0400 Subject: [PATCH] Fix media keyboard sizing issue by trying two ways to find window insets. --- .../components/KeyboardAwareLinearLayout.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java b/app/src/main/java/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java index 8813e8b17f..5ce4dd2a98 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java @@ -25,6 +25,7 @@ import android.preference.PreferenceManager; import android.util.AttributeSet; import android.view.Surface; import android.view.View; +import android.view.WindowInsets; import androidx.appcompat.widget.LinearLayoutCompat; @@ -120,6 +121,25 @@ public class KeyboardAwareLinearLayout extends LinearLayoutCompat { } } + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (Build.VERSION.SDK_INT >= 23 && getRootWindowInsets() != null) { + int bottomInset; + WindowInsets windowInsets = getRootWindowInsets(); + if (Build.VERSION.SDK_INT >= 30) { + bottomInset = windowInsets.getInsets(WindowInsets.Type.navigationBars()).bottom; + } else { + bottomInset = windowInsets.getStableInsetBottom(); + } + + if (bottomInset != 0 && (viewInset == 0 || viewInset == statusBarHeight)) { + Log.i(TAG, "Updating view inset based on WindowInsets. viewInset: " + viewInset + " windowInset: " + bottomInset); + viewInset = bottomInset; + } + } + } + @TargetApi(VERSION_CODES.LOLLIPOP) private int getViewInset() { try {