From 701d73084d13e3fac62a3ede9c6298abed58f66a Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 6 Sep 2016 19:07:39 -0700 Subject: [PATCH] PopupWindow: Don't ignore top decorations in getMaxAvailableHeight. getMaxAvailableHeight is ignoring the top insets, while findDropDownPosition is not. This is causing getMaxAvailableHeight to return a fits above position that findDropDownPosition will think is too large. Bug: 31048766 Change-Id: Ifa57cb4ebe0944c701a6f38b58d4f144d8b9199c --- core/java/android/widget/PopupWindow.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index b12c03ca9c15..9b89491ce408 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -1758,11 +1758,22 @@ public class PopupWindow { */ public int getMaxAvailableHeight( @NonNull View anchor, int yOffset, boolean ignoreBottomDecorations) { - final Rect displayFrame = new Rect(); + Rect displayFrame = null; + final Rect visibleDisplayFrame = new Rect(); + + anchor.getWindowVisibleDisplayFrame(visibleDisplayFrame); if (ignoreBottomDecorations) { + // In the ignore bottom decorations case we want to + // still respect all other decorations so we use the inset visible + // frame on the top right and left and take the bottom + // value from the full frame. + displayFrame = new Rect(); anchor.getWindowDisplayFrame(displayFrame); + displayFrame.top = visibleDisplayFrame.top; + displayFrame.right = visibleDisplayFrame.right; + displayFrame.left = visibleDisplayFrame.left; } else { - anchor.getWindowVisibleDisplayFrame(displayFrame); + displayFrame = visibleDisplayFrame; } final int[] anchorPos = mTmpDrawingLocation; -- 2.11.0