From c081f744e315a2654afd14e086ba68b0d69bff0d Mon Sep 17 00:00:00 2001 From: Sriram Ramasubramanian Date: Mon, 9 Jul 2012 13:23:16 -0700 Subject: [PATCH] Bug 769237: Menu popup arrow position doesn't need to be calculated. [r=mfinkle] --HG-- extra : rebase_source : ae4e17c08a73223d49adfe55bb989261abb00f67 --- mobile/android/base/BrowserToolbar.java | 31 +------------------ .../base/resources/layout/menu_popup.xml | 4 ++- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index 2ec77bc6ed9..2a55c384a20 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -548,7 +548,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, return false; if (mMenuPopup != null && !mMenuPopup.isShowing()) - mMenuPopup.show(mMenu); + mMenuPopup.showAsDropDown(mMenu); return true; } @@ -565,7 +565,6 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, // MenuPopup holds the MenuPanel in Honeycomb/ICS devices with no hardware key public class MenuPopup extends PopupWindow { - private ImageView mArrow; private RelativeLayout mPanel; public MenuPopup(Context context) { @@ -581,7 +580,6 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.menu_popup, null); setContentView(layout); - mArrow = (ImageView) layout.findViewById(R.id.menu_arrow); mPanel = (RelativeLayout) layout.findViewById(R.id.menu_panel); } @@ -589,32 +587,5 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, mPanel.removeAllViews(); mPanel.addView(view); } - - public void show(View anchor) { - showAsDropDown(anchor); - - int location[] = new int[2]; - anchor.getLocationOnScreen(location); - - int menuButtonWidth = anchor.getWidth(); - int arrowWidth = mArrow.getWidth(); - - int rightMostEdge = location[0] + menuButtonWidth; - - DisplayMetrics metrics = new DisplayMetrics(); - GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); - - int leftMargin = (int)(240 * metrics.density) - (metrics.widthPixels - location[0] - menuButtonWidth/2); - - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mArrow.getLayoutParams(); - RelativeLayout.LayoutParams newParams = new RelativeLayout.LayoutParams(params); - newParams.setMargins(leftMargin, - params.topMargin, - 0, - params.bottomMargin); - - // From the left of popup, the arrow should move half of (menuButtonWidth - arrowWidth) - mArrow.setLayoutParams(newParams); - } } } diff --git a/mobile/android/base/resources/layout/menu_popup.xml b/mobile/android/base/resources/layout/menu_popup.xml index 72eb5e3aee8..71880c0fe21 100644 --- a/mobile/android/base/resources/layout/menu_popup.xml +++ b/mobile/android/base/resources/layout/menu_popup.xml @@ -10,6 +10,7 @@ @@ -20,7 +21,8 @@ android:layout_width="28dip" android:layout_height="10dip" android:layout_marginTop="2dip" - android:layout_alignParentRight="true" + android:layout_marginRight="8dip" + android:layout_alignRight="@id/menu_panel" android:src="@drawable/menu_popup_arrow" android:scaleType="fitXY"/>