From 3b105d92a5913777a8a89bdce8647da5e27267b7 Mon Sep 17 00:00:00 2001 From: Vladislav Kaznacheev Date: Thu, 11 May 2017 23:49:52 +0000 Subject: [PATCH] Revert "Respect PopupWindow.setOverlapAnchor when above anchor" This reverts commit 07084924be4ce0dc67f150d77b886f21fcb01aa7. Bug: 37951656 Test: android.widget.cts.PopupWindowTest Change-Id: I6c950d19bbf5c778f799a652595550a2733aae08 --- core/java/android/widget/PopupWindow.java | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index 59fb02d353bb..8464c6e47d47 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -1667,32 +1667,17 @@ public class PopupWindow { int anchorHeight, int drawingLocationY, int screenLocationY, int displayFrameTop, int displayFrameBottom, boolean allowResize) { final int winOffsetY = screenLocationY - drawingLocationY; - final int popupScreenTop = outParams.y + winOffsetY; - final int spaceBelow = displayFrameBottom - popupScreenTop; - if (popupScreenTop >= 0 && height <= spaceBelow) { + final int anchorTopInScreen = outParams.y + winOffsetY; + final int spaceBelow = displayFrameBottom - anchorTopInScreen; + if (anchorTopInScreen >= 0 && height <= spaceBelow) { return true; } - final int popupScreenBottom; - if (mOverlapAnchor) { - // popupScreenTop equals the anchor's top at this point. - // When shown above the anchor, an overlapping popup's bottom should be aligned with - // the anchor's bottom. - popupScreenBottom = popupScreenTop + anchorHeight; - } else { - // popupScreenTop equals the anchor's bottom at this point. - // When shown above the anchor, a non-overlapping popup's bottom is aligned with - // the anchor's top. - popupScreenBottom = popupScreenTop - anchorHeight; - } - final int spaceAbove = popupScreenBottom - displayFrameTop; + final int spaceAbove = anchorTopInScreen - anchorHeight - displayFrameTop; if (height <= spaceAbove) { // Move everything up. if (mOverlapAnchor) { - // Add one anchorHeight to compensate for the correction made at the start of - // findDropDownPosition, and another to account for being aligned to the anchor's - // bottom, not top. - yOffset += anchorHeight * 2; + yOffset += anchorHeight; } outParams.y = drawingLocationY - height + yOffset; -- 2.11.0