Fix media keyboard sizing issue by trying two ways to find window insets.

This commit is contained in:
Cody Henthorne 2021-06-03 16:55:31 -04:00
parent 3a21a2a49e
commit 875895524e

View file

@ -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 {