Skip to content

Commit b918e3f

Browse files
committed
[minibrowser] Take into account IME insets
Check whether IME is visible (i.e. the on screen keyboard) and take it into account when applying insets to the main browser fragment. Previously only the system bars insets were taken into account, which resulted in the IME covering the toolbar and part of the web view. Fixes #192
1 parent d2d3073 commit b918e3f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/minibrowser/src/main/java/org/wpewebkit/tools/minibrowser/BrowserFragment.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ class BrowserFragment : Fragment(R.layout.fragment_browser) {
102102

103103
ViewCompat.setOnApplyWindowInsetsListener(binding.main) { v, insets ->
104104
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
105-
v.updatePadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
105+
val padding = if (insets.isVisible(WindowInsetsCompat.Type.ime())) {
106+
androidx.core.graphics.Insets.max(systemBars, insets.getInsets(WindowInsetsCompat.Type.ime()))
107+
} else {
108+
systemBars
109+
}
110+
v.updatePadding(padding.left, padding.top, padding.right, padding.bottom)
106111
WindowInsetsCompat.CONSUMED
107112
}
108113

0 commit comments

Comments
 (0)