Commit e88d5af6 authored by Theresa's avatar Theresa Committed by Commit Bot

Remove support for bottom anchored app menu

This support is no longer needed, and removing it side-steps an Android
framework issue. Specifically, re-enabling popupwindow clipping prevents
Android from drawing it overtop of the bottom navigation bar.

BUG=815226

Change-Id: I5860a7f58efb3920cb636557502879dd9e3136ab
Reviewed-on: https://chromium-review.googlesource.com/934978
Commit-Queue: Theresa <twellington@chromium.org>
Reviewed-by: default avatarBecky Zhou <huayinz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#538861}
parent 72d721e5
...@@ -57,7 +57,6 @@ ...@@ -57,7 +57,6 @@
via scrolling. --> via scrolling. -->
<dimen name="menu_vertical_fade_distance">15dp</dimen> <dimen name="menu_vertical_fade_distance">15dp</dimen>
<dimen name="menu_badge_translation_y_distance">6dp</dimen> <dimen name="menu_badge_translation_y_distance">6dp</dimen>
<dimen name="menu_negative_vertical_offset_not_top_anchored">4dp</dimen>
<!-- Menu button dragging related dimensions --> <!-- Menu button dragging related dimensions -->
<dimen name="auto_scroll_full_velocity">500dp</dimen> <dimen name="auto_scroll_full_velocity">500dp</dimen>
......
...@@ -59,7 +59,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -59,7 +59,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
private final int mItemDividerHeight; private final int mItemDividerHeight;
private final int mVerticalFadeDistance; private final int mVerticalFadeDistance;
private final int mNegativeSoftwareVerticalOffset; private final int mNegativeSoftwareVerticalOffset;
private final int mNegativeVerticalOffsetNotTopAnchored;
private final int[] mTempLocation; private final int[] mTempLocation;
private final boolean mTranslateMenuItemsOnShow; private final boolean mTranslateMenuItemsOnShow;
...@@ -99,8 +98,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -99,8 +98,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
mNegativeSoftwareVerticalOffset = mNegativeSoftwareVerticalOffset =
res.getDimensionPixelSize(R.dimen.menu_negative_software_vertical_offset); res.getDimensionPixelSize(R.dimen.menu_negative_software_vertical_offset);
mVerticalFadeDistance = res.getDimensionPixelSize(R.dimen.menu_vertical_fade_distance); mVerticalFadeDistance = res.getDimensionPixelSize(R.dimen.menu_vertical_fade_distance);
mNegativeVerticalOffsetNotTopAnchored =
res.getDimensionPixelSize(R.dimen.menu_negative_vertical_offset_not_top_anchored);
mTempLocation = new int[2]; mTempLocation = new int[2];
mTranslateMenuItemsOnShow = translateMenuItemsOnShow; mTranslateMenuItemsOnShow = translateMenuItemsOnShow;
...@@ -171,7 +168,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -171,7 +168,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
@IdRes int footerResourceId, View headerView, Integer highlightedItemId) { @IdRes int footerResourceId, View headerView, Integer highlightedItemId) {
mPopup = new PopupWindow(context); mPopup = new PopupWindow(context);
mPopup.setFocusable(true); mPopup.setFocusable(true);
if (!isByPermanentButton) mPopup.setClippingEnabled(false);
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
...@@ -179,7 +175,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -179,7 +175,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
mPopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL); mPopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL);
} }
boolean anchorAtBottom = isAnchorAtBottom(anchorView, visibleDisplayFrame);
mPopup.setOnDismissListener(() -> { mPopup.setOnDismissListener(() -> {
if (anchorView instanceof ImageButton) { if (anchorView instanceof ImageButton) {
((ImageButton) anchorView).setSelected(false); ((ImageButton) anchorView).setSelected(false);
...@@ -208,12 +203,9 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -208,12 +203,9 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
mPopup.setBackgroundDrawable( mPopup.setBackgroundDrawable(
ApiCompatibilityUtils.getDrawable(context.getResources(), R.drawable.menu_bg)); ApiCompatibilityUtils.getDrawable(context.getResources(), R.drawable.menu_bg));
} else { } else {
mPopup.setBackgroundDrawable(ApiCompatibilityUtils.getDrawable(context.getResources(), mPopup.setBackgroundDrawable(ApiCompatibilityUtils.getDrawable(
isAnchorAtTop(anchorView, visibleDisplayFrame) context.getResources(), R.drawable.edge_menu_bg));
? R.drawable.edge_menu_bg mPopup.setAnimationStyle(R.style.OverflowMenuAnim);
: R.drawable.bottom_anchor_edge_menu_bg));
mPopup.setAnimationStyle(
anchorAtBottom ? R.style.OverflowMenuAnimBottom : R.style.OverflowMenuAnim);
} }
// Turn off window animations for low end devices. // Turn off window animations for low end devices.
...@@ -268,7 +260,7 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -268,7 +260,7 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
int popupHeight = setMenuHeight(menuItems.size(), visibleDisplayFrame, screenHeight, int popupHeight = setMenuHeight(menuItems.size(), visibleDisplayFrame, screenHeight,
sizingPadding, footerHeight, headerHeight, anchorView); sizingPadding, footerHeight, headerHeight, anchorView);
int[] popupPosition = getPopupPosition(mCurrentScreenRotation, visibleDisplayFrame, int[] popupPosition = getPopupPosition(mCurrentScreenRotation, visibleDisplayFrame,
sizingPadding, anchorView, anchorAtBottom, popupWidth, popupHeight); sizingPadding, anchorView, popupWidth, popupHeight);
mPopup.setContentView(contentView); mPopup.setContentView(contentView);
mPopup.showAtLocation( mPopup.showAtLocation(
...@@ -306,18 +298,8 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -306,18 +298,8 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
return mFooterView; return mFooterView;
} }
private boolean isAnchorAtBottom(View anchorView, Rect visibleDisplayFrame) {
anchorView.getLocationOnScreen(mTempLocation);
return (mTempLocation[1] + anchorView.getHeight()) >= visibleDisplayFrame.bottom;
}
private boolean isAnchorAtTop(View anchorView, Rect visibleDisplayFrame) {
anchorView.getLocationOnScreen(mTempLocation);
return mTempLocation[1] == visibleDisplayFrame.top;
}
private int[] getPopupPosition(int screenRotation, Rect appRect, Rect padding, View anchorView, private int[] getPopupPosition(int screenRotation, Rect appRect, Rect padding, View anchorView,
boolean anchorAtBottom, int popupWidth, int popupHeight) { int popupWidth, int popupHeight) {
anchorView.getLocationInWindow(mTempLocation); anchorView.getLocationInWindow(mTempLocation);
int anchorViewX = mTempLocation[0]; int anchorViewX = mTempLocation[0];
int anchorViewY = mTempLocation[1]; int anchorViewY = mTempLocation[1];
...@@ -348,21 +330,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -348,21 +330,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
} else { } else {
offsets[1] = -mNegativeSoftwareVerticalOffset; offsets[1] = -mNegativeSoftwareVerticalOffset;
// If the anchor is at the bottom of the screen, align the popup with the bottom of the
// anchor. The anchor may not be fully visible, so
// (appRect.bottom - anchorViewLocationOnScreenY) is used to determine the visible
// bottom edge of the anchor view.
if (anchorAtBottom) {
anchorView.getLocationOnScreen(mTempLocation);
int anchorViewLocationOnScreenY = mTempLocation[1];
offsets[1] += appRect.bottom - anchorViewLocationOnScreenY - popupHeight;
if (!mIsByPermanentButton) offsets[1] += padding.bottom;
}
if (!isAnchorAtTop(anchorView, appRect)) {
offsets[1] -= mNegativeVerticalOffsetNotTopAnchored;
}
if (!ApiCompatibilityUtils.isLayoutRtl(anchorView.getRootView())) { if (!ApiCompatibilityUtils.isLayoutRtl(anchorView.getRootView())) {
offsets[0] = anchorView.getWidth() - popupWidth; offsets[0] = anchorView.getWidth() - popupWidth;
} }
...@@ -489,8 +456,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -489,8 +456,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
anchorView.getLocationOnScreen(mTempLocation); anchorView.getLocationOnScreen(mTempLocation);
int anchorViewY = mTempLocation[1] - appDimensions.top; int anchorViewY = mTempLocation[1] - appDimensions.top;
if (isAnchorAtBottom(anchorView, appDimensions)) anchorViewY += anchorView.getHeight();
int anchorViewImpactHeight = mIsByPermanentButton ? anchorView.getHeight() : 0; int anchorViewImpactHeight = mIsByPermanentButton ? anchorView.getHeight() : 0;
// Set appDimensions.height() for abnormal anchorViewLocation. // Set appDimensions.height() for abnormal anchorViewLocation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment