Bug 1269774 - Show browser menu over the menu button. r=sebastian, a=sledru
authorAndrzej Hunt <andrzej@ahunt.org>
Tue, 03 May 2016 14:02:28 -0700
changeset 333170 13f8321f46d0acec289bf7eb296f27eafcf76d7a
parent 333169 f940e3a54aca6b48f25604c2ef03fd4e68d79121
child 333171 ddf15775455b3e6b2b9bbd4cfa62ff7304f86dd8
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, sledru
bugs1269774
milestone48.0a2
Bug 1269774 - Show browser menu over the menu button. r=sebastian, a=sledru 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
@@ -120,17 +120,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>