From 830f2d20e4452f412299e94f8752beb239bc3cb9 Mon Sep 17 00:00:00 2001 From: Annie Lin Date: Wed, 12 Jun 2024 20:16:18 +0000 Subject: [Divider] Update veil visibility depending on if container bounds are empty. If this is not done, the veil surface could be sized incorrectly, and we want to ensure it is not shown. e.g. If a zero window crop is applied, the veil may expand to beyond the full screen bounds (though the view on top may or may not cover it): https://screenshot.googleplex.com/5xiAsixgZSGiBJv.png Bug: 343509560 Test: atest DividerPresenterTest Change-Id: I41436d0388b3692293121f7822df5512f988bc56 --- .../window/extensions/embedding/DividerPresenter.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java index 94c281fa9fac..290fefa5abfa 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java @@ -1394,10 +1394,16 @@ class DividerPresenter implements View.OnTouchListener { primaryBounds = mProperties.mIsReversedLayout ? boundsBottom : boundsTop; secondaryBounds = mProperties.mIsReversedLayout ? boundsTop : boundsBottom; } - t.setWindowCrop(mPrimaryVeil, primaryBounds.width(), primaryBounds.height()); - t.setWindowCrop(mSecondaryVeil, secondaryBounds.width(), secondaryBounds.height()); - t.setPosition(mPrimaryVeil, primaryBounds.left, primaryBounds.top); - t.setPosition(mSecondaryVeil, secondaryBounds.left, secondaryBounds.top); + if (mPrimaryVeil != null) { + t.setWindowCrop(mPrimaryVeil, primaryBounds.width(), primaryBounds.height()); + t.setPosition(mPrimaryVeil, primaryBounds.left, primaryBounds.top); + t.setVisibility(mPrimaryVeil, !primaryBounds.isEmpty()); + } + if (mSecondaryVeil != null) { + t.setWindowCrop(mSecondaryVeil, secondaryBounds.width(), secondaryBounds.height()); + t.setPosition(mSecondaryVeil, secondaryBounds.left, secondaryBounds.top); + t.setVisibility(mSecondaryVeil, !secondaryBounds.isEmpty()); + } } private static float[] colorToFloatArray(@NonNull Color color) { -- cgit v1.2.3-59-g8ed1b