Skip to content

[NavigationRailView] Use display cutout and system bar insets for start padding #3991

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from
Closed
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 @@ -419,17 +419,21 @@ public WindowInsetsCompat onApplyWindowInsets(
@NonNull WindowInsetsCompat insets,
@NonNull RelativePadding initialPadding) {
// Apply the top, bottom, and start padding for a start edge aligned
// NavigationRailView to dodge the system status and navigation bars
// NavigationRailView to dodge the system status/navigation bars and display cutouts
Insets systemBarInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars());
Insets displayCutoutInsets = insets.getInsets(WindowInsetsCompat.Type.displayCutout());
if (shouldApplyWindowInsetPadding(paddingTopSystemWindowInsets)) {
initialPadding.top += systemBarInsets.top;
}
if (shouldApplyWindowInsetPadding(paddingBottomSystemWindowInsets)) {
initialPadding.bottom += systemBarInsets.bottom;
}
if (shouldApplyWindowInsetPadding(paddingStartSystemWindowInsets)) {
initialPadding.start +=
ViewUtils.isLayoutRtl(view) ? systemBarInsets.right : systemBarInsets.left;
if (ViewUtils.isLayoutRtl(view)) {
initialPadding.start += Math.max(systemBarInsets.right, displayCutoutInsets.right);
} else {
initialPadding.start += Math.max(systemBarInsets.left, displayCutoutInsets.left);
}
}
initialPadding.applyToView(view);
return insets;
Expand Down