Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf2a2faf authored by Robert Carr's avatar Robert Carr Committed by android-build-merger
Browse files

Merge "Respect WRAP_CONTENT when resolving drop down position." into nyc-dev

am: 5a2554a8

* commit '5a2554a8':
  Respect WRAP_CONTENT when resolving drop down position.

Change-Id: Ie466c526c84d26caddc5577f231e58738733d983
parents b752ef77 5a2554a8
Loading
Loading
Loading
Loading
+16 −10
Original line number Original line Diff line number Diff line
@@ -54,6 +54,8 @@ import java.lang.ref.WeakReference;


import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;


/**
/**
 * <p>
 * <p>
@@ -1305,15 +1307,15 @@ public class PopupWindow {
    private PopupBackgroundView createBackgroundView(View contentView) {
    private PopupBackgroundView createBackgroundView(View contentView) {
        final ViewGroup.LayoutParams layoutParams = mContentView.getLayoutParams();
        final ViewGroup.LayoutParams layoutParams = mContentView.getLayoutParams();
        final int height;
        final int height;
        if (layoutParams != null && layoutParams.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
        if (layoutParams != null && layoutParams.height == WRAP_CONTENT) {
            height = ViewGroup.LayoutParams.WRAP_CONTENT;
            height = WRAP_CONTENT;
        } else {
        } else {
            height = ViewGroup.LayoutParams.MATCH_PARENT;
            height = MATCH_PARENT;
        }
        }


        final PopupBackgroundView backgroundView = new PopupBackgroundView(mContext);
        final PopupBackgroundView backgroundView = new PopupBackgroundView(mContext);
        final PopupBackgroundView.LayoutParams listParams = new PopupBackgroundView.LayoutParams(
        final PopupBackgroundView.LayoutParams listParams = new PopupBackgroundView.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, height);
                MATCH_PARENT, height);
        backgroundView.addView(contentView, listParams);
        backgroundView.addView(contentView, listParams);


        return backgroundView;
        return backgroundView;
@@ -1328,14 +1330,14 @@ public class PopupWindow {
    private PopupDecorView createDecorView(View contentView) {
    private PopupDecorView createDecorView(View contentView) {
        final ViewGroup.LayoutParams layoutParams = mContentView.getLayoutParams();
        final ViewGroup.LayoutParams layoutParams = mContentView.getLayoutParams();
        final int height;
        final int height;
        if (layoutParams != null && layoutParams.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
        if (layoutParams != null && layoutParams.height == WRAP_CONTENT) {
            height = ViewGroup.LayoutParams.WRAP_CONTENT;
            height = WRAP_CONTENT;
        } else {
        } else {
            height = ViewGroup.LayoutParams.MATCH_PARENT;
            height = MATCH_PARENT;
        }
        }


        final PopupDecorView decorView = new PopupDecorView(mContext);
        final PopupDecorView decorView = new PopupDecorView(mContext);
        decorView.addView(contentView, ViewGroup.LayoutParams.MATCH_PARENT, height);
        decorView.addView(contentView, MATCH_PARENT, height);
        decorView.setClipChildren(false);
        decorView.setClipChildren(false);
        decorView.setClipToPadding(false);
        decorView.setClipToPadding(false);


@@ -1522,11 +1524,15 @@ public class PopupWindow {
        // to fill in real width and height values.
        // to fill in real width and height values.
        final Rect displayFrame = new Rect();
        final Rect displayFrame = new Rect();
        anchor.getWindowVisibleDisplayFrame(displayFrame);
        anchor.getWindowVisibleDisplayFrame(displayFrame);
        if (width < 0) {
        if (width == MATCH_PARENT) {
            width = displayFrame.right - displayFrame.left;
            width = displayFrame.right - displayFrame.left;
        } else if (width == WRAP_CONTENT) {
            width = mContentView.getMeasuredWidth();
        }
        }
        if (height < 0) {
        if (height == MATCH_PARENT) {
            height = displayFrame.bottom - displayFrame.top;
            height = displayFrame.bottom - displayFrame.top;
        } else if (height == WRAP_CONTENT) {
            height = mContentView.getMeasuredHeight();
        }
        }


        // If we need to adjust for gravity RIGHT, align to the bottom-right
        // If we need to adjust for gravity RIGHT, align to the bottom-right