Bug 1269774 - Show browser menu over the menu button r=sebastian draft
authorAndrzej Hunt <andrzej@ahunt.org>
Tue, 03 May 2016 14:02:28 -0700
changeset 365065 6c6420c40d76b4275e16b374cfc9548b220e4491
parent 365064 0c027526b324d4de9c748a616ca3d760d1d78e77
child 365066 d2dc78e28681a810e02bf4fe1e5b2b973c45016b
push id17622
push userbmo:ahunt@mozilla.com
push dateMon, 09 May 2016 23:51:40 +0000
reviewerssebastian
bugs1269774
milestone49.0a1
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
mobile/android/base/java/org/mozilla/gecko/menu/MenuPopup.java
mobile/android/base/resources/values/dimens.xml
--- 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>