Bug 1269774 - Show browser menu over the menu button r=sebastian
Note: this commit alone results in the menu looking slightly odd
due to different top and right paddings. These are fixed in the
next commit.
MozReview-Commit-ID: AWzYU067K0W
--- a/mobile/android/base/java/org/mozilla/gecko/menu/MenuPopup.java
+++ b/mobile/android/base/java/org/mozilla/gecko/menu/MenuPopup.java
@@ -17,28 +17,24 @@ import android.widget.FrameLayout;
import android.widget.PopupWindow;
/**
* A popup to show the inflated MenuPanel.
*/
public class MenuPopup extends PopupWindow {
private final FrameLayout mPanel;
- private final int mYOffset;
private final int mPopupWidth;
- private final int mPopupMinHeight;
public MenuPopup(Context context) {
super(context);
setFocusable(true);
- mYOffset = context.getResources().getDimensionPixelSize(R.dimen.menu_popup_offset);
mPopupWidth = context.getResources().getDimensionPixelSize(R.dimen.menu_popup_width);
- mPopupMinHeight = context.getResources().getDimensionPixelSize(R.dimen.menu_item_row_height);
// Setting a null background makes the popup to not close on touching outside.
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
LayoutInflater inflater = LayoutInflater.from(context);
mPanel = (FrameLayout) inflater.inflate(R.layout.menu_popup, null);
@@ -68,11 +64,11 @@ public class MenuPopup extends PopupWind
// Set a height, so that the popup will not be displayed below the bottom of the screen.
// We use the exact height of the internal content, which is the technique described in
// http://stackoverflow.com/a/7698709
setHeight(mPanel.getHeight());
// Attempt to align the center of the popup with the center of the anchor. If the anchor is
// near the edge of the screen, the popup will just align with the edge of the screen.
final int xOffset = anchor.getWidth() / 2 - mPopupWidth / 2;
- showAsDropDown(anchor, xOffset, -mYOffset);
+ showAsDropDown(anchor, xOffset, -anchor.getHeight());
}
}
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -121,17 +121,16 @@
<dimen name="menu_item_icon">21dp</dimen>
<dimen name="menu_item_textsize">16sp</dimen>
<dimen name="menu_item_state_icon">18dp</dimen>
<!-- This is chosen to match Android's listPreferredItemHeight.
TODO: We should inherit these from the system.
http://androidxref.com/4.2.2_r1/xref/frameworks/base/core/res/res/values/themes.xml#123 -->
<dimen name="menu_item_row_height">64dip</dimen>
<dimen name="menu_item_row_width">240dp</dimen>
- <dimen name="menu_popup_offset">12dp</dimen>
<dimen name="menu_popup_width">256dp</dimen>
<dimen name="nav_button_border_width">1dp</dimen>
<dimen name="prompt_service_group_padding_size">32dp</dimen>
<dimen name="prompt_service_icon_size">36dp</dimen>
<dimen name="prompt_service_icon_text_padding">10dp</dimen>
<dimen name="prompt_service_inputs_padding">16dp</dimen>
<dimen name="prompt_service_left_right_text_with_icon_padding">10dp</dimen>
<dimen name="prompt_service_top_bottom_text_with_icon_padding">8dp</dimen>