Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4261)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/appmenu/AppMenu.java

Issue 419673002: Update Android menu to overlap anchor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 94fe6e3489884beedfcff05708415df7a8e288a3..6f7f5733db21138c46f76bef09ca54a7f59ae42d 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
@@ -37,7 +37,7 @@ import java.util.List;
*/
public class AppMenu implements OnItemClickListener, OnKeyListener {
/** Whether or not to show the software menu button in the menu. */
- private static final boolean SHOW_SW_MENU_BUTTON = false;
+ private static final boolean SHOW_SW_MENU_BUTTON = true;
private static final float LAST_ITEM_SHOW_FRACTION = 0.5f;
@@ -45,7 +45,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
private final int mItemRowHeight;
private final int mItemDividerHeight;
private final int mVerticalFadeDistance;
- private final int mAdditionalVerticalOffset;
private ListPopupWindow mPopup;
private AppMenuAdapter mAdapter;
private AppMenuHandler mHandler;
@@ -72,7 +71,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
mItemDividerHeight = itemDividerHeight;
assert mItemDividerHeight >= 0;
- mAdditionalVerticalOffset = res.getDimensionPixelSize(R.dimen.menu_vertical_offset);
mVerticalFadeDistance = res.getDimensionPixelSize(R.dimen.menu_vertical_fade_distance);
}
@@ -105,7 +103,13 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
// Need to explicitly set the background here. Relying on it being set in the style caused
// an incorrectly drawn background.
- mPopup.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.menu_bg));
+ if (isByHardwareButton) {
+ mPopup.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.menu_bg));
+ } else {
+ mPopup.setBackgroundDrawable(
+ context.getResources().getDrawable(R.drawable.edge_menu_bg));
+ mPopup.setAnimationStyle(R.style.OverflowMenuAnim);
+ }
Rect bgPadding = new Rect();
mPopup.getBackground().getPadding(bgPadding);
@@ -165,6 +169,7 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
popup.getBackground().getPadding(paddingRect);
int[] anchorLocation = new int[2];
popup.getAnchorView().getLocationInWindow(anchorLocation);
+ int anchorHeight = popup.getAnchorView().getHeight();
// If we have a hardware menu button, locate the app menu closer to the estimated
// hardware menu button location.
@@ -187,11 +192,11 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
popup.setHorizontalOffset(horizontalOffset);
// The menu is displayed above the anchored view, so shift the menu up by the top
// padding of the background.
- popup.setVerticalOffset(mAdditionalVerticalOffset - paddingRect.bottom);
+ popup.setVerticalOffset(-paddingRect.bottom);
} else {
- // The menu is displayed below the anchored view, so shift the menu up by the top
- // padding of the background.
- popup.setVerticalOffset(mAdditionalVerticalOffset - paddingRect.top);
+ // The menu is displayed over and below the anchored view, so shift the menu up by the
+ // height of the anchor view.
+ popup.setVerticalOffset(-anchorHeight);
}
}
@@ -264,9 +269,10 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
int[] anchorViewLocation = new int[2];
anchorView.getLocationOnScreen(anchorViewLocation);
anchorViewLocation[1] -= appDimensions.top;
+ int anchorViewImpactHeight = mIsByHardwareButton ? anchorView.getHeight() : 0;
int availableScreenSpace = Math.max(anchorViewLocation[1],
- appDimensions.height() - anchorViewLocation[1] - anchorView.getHeight());
+ appDimensions.height() - anchorViewLocation[1] - anchorViewImpactHeight);
Rect padding = new Rect();
mPopup.getBackground().getPadding(padding);

Powered by Google App Engine
This is Rietveld 408576698