Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java b/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java |
| index cd053376aa7b04180022795783a9e6661c2ec460..eedc62f2828c7cf9f3e547481ca721c18c4771d5 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java |
| @@ -133,13 +133,24 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { |
| * @param screenRotation Current device screen rotation. |
| * @param visibleDisplayFrame The display area rect in which AppMenu is supposed to fit in. |
| * @param screenHeight Current device screen height. |
| + * @param footerResourceId The resource id for a view to add to the end of the menu list. |
| + * Can be 0 if no such view is required. |
|
newt (away)
2015/07/10 18:55:46
nit: indentation
Yusuf
2015/07/10 19:12:19
Done.
|
| */ |
| void show(Context context, View anchorView, boolean isByHardwareButton, int screenRotation, |
| - Rect visibleDisplayFrame, int screenHeight) { |
| + Rect visibleDisplayFrame, int screenHeight, int footerResourceId) { |
| mPopup = new ListPopupWindow(context, null, android.R.attr.popupMenuStyle); |
| mPopup.setModal(true); |
| mPopup.setAnchorView(anchorView); |
| mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); |
| + |
| + int footerHeight = 0; |
| + if (footerResourceId != 0) { |
| + mPopup.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW); |
| + mPopup.setPromptView( |
|
newt (away)
2015/07/10 18:55:46
fits on one line?
Yusuf
2015/07/10 19:12:19
Done.
|
| + LayoutInflater.from(context).inflate(footerResourceId, null)); |
| + footerHeight = context.getResources().getDimensionPixelSize( |
| + R.dimen.powered_by_chrome_footer_height); |
|
newt (away)
2015/07/10 18:55:46
maybe should call this menu_footer_height, since A
Yusuf
2015/07/10 19:12:19
Done.
|
| + } |
| mPopup.setOnDismissListener(new OnDismissListener() { |
| @Override |
| public void onDismiss() { |
| @@ -207,7 +218,8 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { |
| mAdapter = new AppMenuAdapter(this, menuItems, LayoutInflater.from(context)); |
| mPopup.setAdapter(mAdapter); |
| - setMenuHeight(menuItems.size(), visibleDisplayFrame, screenHeight, sizingPadding); |
| + setMenuHeight( |
| + menuItems.size(), visibleDisplayFrame, screenHeight, sizingPadding, footerHeight); |
| setPopupOffset(mPopup, mCurrentScreenRotation, visibleDisplayFrame, sizingPadding); |
| mPopup.setOnItemClickListener(this); |
| mPopup.show(); |
| @@ -339,8 +351,8 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { |
| return mMenu; |
| } |
| - private void setMenuHeight( |
| - int numMenuItems, Rect appDimensions, int screenHeight, Rect padding) { |
| + private void setMenuHeight(int numMenuItems, Rect appDimensions, |
| + int screenHeight, Rect padding, int footerHeight) { |
| assert mPopup.getAnchorView() != null; |
| View anchorView = mPopup.getAnchorView(); |
| int[] anchorViewLocation = new int[2]; |
| @@ -355,7 +367,7 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { |
| int availableScreenSpace = Math.max(anchorViewLocation[1], |
| appDimensions.height() - anchorViewLocation[1] - anchorViewImpactHeight); |
| - availableScreenSpace -= padding.bottom; |
| + availableScreenSpace -= padding.bottom + footerHeight; |
| if (mIsByHardwareButton) availableScreenSpace -= padding.top; |
| int numCanFit = availableScreenSpace / (mItemRowHeight + mItemDividerHeight); |