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
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@ import androidx.appcompat.app.AppCompatActivity

@JvmOverloads
@Suppress("MagicNumber")
fun AppCompatActivity.adjustUIForAPILevel35(
fun AppCompatActivity.applyEdgeToEdgeWithSystemBarPadding(
statusBarStyle: SystemBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT),
navigationBarStyle: SystemBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT)
) {
val isApiLevel35OrHigher = (Build.VERSION.SDK_INT >= 35)
if (!isApiLevel35OrHigher) {
return
}

enableEdgeToEdge(statusBarStyle, navigationBarStyle)

window.addSystemBarPaddings()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ fun Window?.addSystemBarPaddings() {
}

ViewCompat.setOnApplyWindowInsetsListener(decorView) { v: View, insets: WindowInsetsCompat ->
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
val ime = insets.getInsets(WindowInsetsCompat.Type.ime())
val bottomInset = maxOf(systemBars.bottom, ime.bottom)

v.updatePadding(
left = bars.left,
top = bars.top,
right = bars.right,
bottom = bars.bottom
left = systemBars.left,
top = systemBars.top,
right = systemBars.right,
bottom = bottomInset
)

WindowInsetsCompat.CONSUMED
Expand Down
Loading