Don't apply corner cutout insets if we're already inset enough

Test: rotate with double cutout and corner cutout
Change-Id: Id0040d38d6ad82552943f78b4318122baef5b506
Fixes: 76149216
This commit is contained in:
Evan Laird
2018-04-17 17:42:36 -04:00
parent d7cea28bbc
commit 8bd70cb758

View File

@@ -332,6 +332,18 @@ public class PhoneStatusBarView extends PanelBar {
if (cornerCutoutMargins != null) {
lp.leftMargin = Math.max(lp.leftMargin, cornerCutoutMargins.first);
lp.rightMargin = Math.max(lp.rightMargin, cornerCutoutMargins.second);
// If we're already inset enough (e.g. on the status bar side), we can have 0 margin
WindowInsets insets = getRootWindowInsets();
int leftInset = insets.getSystemWindowInsetLeft();
int rightInset = insets.getSystemWindowInsetRight();
if (lp.leftMargin <= leftInset) {
lp.leftMargin = 0;
}
if (lp.rightMargin <= rightInset) {
lp.rightMargin = 0;
}
}
}