Fix bug 3210201 - Popup window wrong size/position when IME hidden
Fixes a case where ViewRoot does not recompute its size properly.
This caused various offsets to get out of sync and the window would
draw improperly.
Change-Id: Id0abb37bbf27b60de2dca4077c21040ec84ef163
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 9bda637..95949b9 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -865,6 +865,9 @@
childWidthMeasureSpec = getRootMeasureSpec(desiredWindowWidth, lp.width);
childHeightMeasureSpec = getRootMeasureSpec(desiredWindowHeight, lp.height);
host.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+ if (mWidth != host.getMeasuredWidth() || mHeight != host.getMeasuredHeight()) {
+ windowSizeMayChange = true;
+ }
}
if (DBG) {
diff --git a/core/java/com/android/internal/view/menu/MenuPopupHelper.java b/core/java/com/android/internal/view/menu/MenuPopupHelper.java
index 2cb78a5..a5fd38e 100644
--- a/core/java/com/android/internal/view/menu/MenuPopupHelper.java
+++ b/core/java/com/android/internal/view/menu/MenuPopupHelper.java
@@ -96,6 +96,7 @@
}
mPopup.setContentWidth(Math.min(measureContentWidth(adapter), mPopupMaxWidth));
+ mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
mPopup.show();
mPopup.getListView().setOnKeyListener(this);
}
@@ -163,6 +164,9 @@
final View anchor = mAnchorView != null ? mAnchorView.get() : null;
if (anchor != null && !anchor.isShown()) {
dismiss();
+ } else {
+ // Recompute window size and position
+ mPopup.show();
}
}
}