Skip to content

Commit 9ff8d9e

Browse files
committed
fix: Handle display cutouts in landscape mode
EdgeToEdgeHelper now considers both systemBars() and displayCutout() insets when applying padding. This prevents camera cutouts from obscuring UI content when the device is in landscape orientation.
1 parent 10d5a82 commit 9ff8d9e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app/src/main/java/eu/darken/capod/common/EdgeToEdgeHelper.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package eu.darken.capod.common
22

33
import android.app.Activity
44
import android.view.View
5-
import androidx.core.graphics.Insets
65
import androidx.core.view.ViewCompat
76
import androidx.core.view.WindowInsetsCompat
87
import eu.darken.capod.common.debug.logging.logTag
@@ -20,12 +19,14 @@ class EdgeToEdgeHelper(activity: Activity) {
2019
bottom: Boolean = false,
2120
) {
2221
ViewCompat.setOnApplyWindowInsetsListener(view) { v: View, insets: WindowInsetsCompat ->
23-
val systemBars: Insets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
22+
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
23+
val displayCutout = insets.getInsets(WindowInsetsCompat.Type.displayCutout())
24+
2425
v.setPadding(
25-
if (left) systemBars.left else v.paddingLeft,
26-
if (top) systemBars.top else v.paddingTop,
27-
if (right) systemBars.right else v.paddingRight,
28-
if (bottom) systemBars.bottom else v.paddingBottom,
26+
if (left) maxOf(systemBars.left, displayCutout.left) else v.paddingLeft,
27+
if (top) maxOf(systemBars.top, displayCutout.top) else v.paddingTop,
28+
if (right) maxOf(systemBars.right, displayCutout.right) else v.paddingRight,
29+
if (bottom) maxOf(systemBars.bottom, displayCutout.bottom) else v.paddingBottom,
2930
)
3031
insets
3132
}

0 commit comments

Comments
 (0)