File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Simplenote/src/main/java/com/automattic/simplenote/utils Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import androidx.appcompat.widget.Toolbar
1010import androidx.core.view.ViewCompat
1111import androidx.core.view.WindowCompat
1212import androidx.core.view.WindowInsetsCompat
13+ import kotlin.math.max
1314
1415/* *
1516 * Utility class to handle system bar appearance changes in a way that's compatible
@@ -116,19 +117,24 @@ object SystemBarUtils {
116117 }
117118
118119 // Handle content view insets - avoid overlap with navigation bar
119- if ( contentView != null ) {
120+ contentView?. let {
120121 ViewCompat .setOnApplyWindowInsetsListener(
121- contentView ,
122+ it ,
122123 { v: View , windowInsets: WindowInsetsCompat ->
123124 val systemBars = windowInsets.getInsets(WindowInsetsCompat .Type .systemBars())
124- // Apply bottom padding to avoid navigation bar overlap
125+ val ime = windowInsets.getInsets(WindowInsetsCompat .Type .ime())
126+ // Apply bottom padding to avoid navigation bar overlap, but let's consider IME too
127+ // this will prevent the keyboard from pushing the content down
128+ val bottomPadding = max(systemBars.bottom, ime.bottom)
125129 v.setPadding(
126130 v.getPaddingLeft(),
127131 v.getPaddingTop(),
128132 v.getPaddingRight(),
129- systemBars.bottom
133+ bottomPadding
130134 )
131- WindowInsetsCompat .CONSUMED
135+ // WARNING: Don't consume IME insets - let them pass through to child views (scroll views)
136+ // this will allow proper scrolling when keyboard appears
137+ windowInsets.inset(0 , 0 , 0 , systemBars.bottom)
132138 })
133139 }
134140 }
You can’t perform that action at this time.
0 commit comments