Bug 1151505 - Adjust for tablet anchoring being offscreen. r=margaret

This commit is contained in:
Chenxia Liu 2015-04-24 16:27:45 -07:00
parent f8aba2d7c9
commit f819cfe75e
3 changed files with 11 additions and 4 deletions

View File

@ -6,7 +6,7 @@
<resources>
<dimen name="arrow_popup_container_width">400dp</dimen>
<dimen name="doorhanger_offsetY">126dp</dimen>
<dimen name="doorhanger_offsetY">124dp</dimen>
<dimen name="browser_toolbar_height">56dp</dimen>
<dimen name="browser_toolbar_height_flipper">60dp</dimen>

View File

@ -103,7 +103,7 @@
<dimen name="doorhanger_input_width">250dp</dimen>
<dimen name="doorhanger_spinner_textsize">9sp</dimen>
<dimen name="doorhanger_padding">15dp</dimen>
<dimen name="doorhanger_offsetX">10dp</dimen>
<dimen name="doorhanger_offsetX">12dp</dimen>
<dimen name="doorhanger_offsetY">67dp</dimen>
<dimen name="doorhanger_GB_offsetY">7dp</dimen>
<dimen name="doorhanger_drawable_padding">5dp</dimen>

View File

@ -113,12 +113,19 @@ public abstract class AnchoredPopup extends PopupWindow {
return;
}
final boolean validAnchor = (mAnchor != null) && (anchorLocation[1] > 0);
if (HardwareUtils.isTablet()) {
showAsDropDown(mAnchor, 0, 0);
if (validAnchor) {
showAsDropDown(mAnchor, 0, 0);
} else {
// The anchor will be offscreen if the dynamic toolbar is hidden, so anticipate the re-shown position
// of the toolbar.
final int offsetX = mContext.getResources().getDimensionPixelOffset(R.dimen.doorhanger_offsetX);
showAtLocation(decorView, Gravity.TOP | Gravity.LEFT, offsetX, offsetY);
}
} else {
// If the anchor is null or out of the window bounds, just show the popup at the top of the
// root view.
final boolean validAnchor = (mAnchor != null) && (anchorLocation[1] > 0);
final View anchor = validAnchor ? mAnchor : decorView;
showAtLocation(anchor, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, offsetY);