Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/ten-bees-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@capawesome/capacitor-android-edge-to-edge-support': patch
---

fix: resize webview when keyboard is shown
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,24 @@ private void applyInsets() {
parent.setBackgroundColor(this.config.getBackgroundColor());
// Apply insets to disable the edge-to-edge feature
ViewCompat.setOnApplyWindowInsetsListener(view, (v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
Boolean keyboardVisible = windowInsets.isVisible(WindowInsetsCompat.Type.ime());
// Retrieve system bars insets (for status/navigation bars)
Insets systemBarsInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
// Retrieve keyboard (IME) insets
Insets imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime());
boolean keyboardVisible = windowInsets.isVisible(WindowInsetsCompat.Type.ime());

ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
if (keyboardVisible) {
mlp.bottomMargin = 0;
} else {
mlp.bottomMargin = insets.bottom;
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
mlp.bottomMargin = insets.bottom;
}
// Apply the appropriate bottom inset: use keyboard inset if visible, else system bars inset
mlp.bottomMargin = keyboardVisible ? imeInsets.bottom : systemBarsInsets.bottom;

// Set the other margins using system bars insets
mlp.topMargin = systemBarsInsets.top;
mlp.leftMargin = systemBarsInsets.left;
mlp.rightMargin = systemBarsInsets.right;

mlp.leftMargin = insets.left;
mlp.rightMargin = insets.right;
mlp.topMargin = insets.top;
v.setLayoutParams(mlp);

return WindowInsetsCompat.CONSUMED;
});
}
Expand Down