Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.pm.PackageInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.util.TypedValue;
import android.view.View;
import android.view.Window;
Expand Down Expand Up @@ -196,10 +197,14 @@ private void initWindowInsetsListener() {
Insets systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime());
boolean keyboardVisible = insets.isVisible(WindowInsetsCompat.Type.ime());
// Below API 30 the window is already resized by the system for the IME (adjustResize) and
// WindowInsetsCompat can only approximate the IME inset, so padding for it as well would
// shrink the WebView twice. See https://github.com/ionic-team/capacitor/issues/8601
boolean padForIme = keyboardVisible && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;

if (shouldPassthroughInsets) {
// We need to correct for a possible shown IME
v.setPadding(0, 0, 0, keyboardVisible ? imeInsets.bottom : 0);
v.setPadding(0, 0, 0, padForIme ? imeInsets.bottom : 0);

WindowInsetsCompat newInsets = new WindowInsetsCompat.Builder(insets)
.setInsets(
Expand All @@ -223,7 +228,7 @@ private void initWindowInsetsListener() {
systemBarsInsets.left,
systemBarsInsets.top,
systemBarsInsets.right,
keyboardVisible ? imeInsets.bottom : systemBarsInsets.bottom
padForIme ? imeInsets.bottom : systemBarsInsets.bottom
);

// Returning `WindowInsetsCompat.CONSUMED` breaks recalculation of safe area insets
Expand Down