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

[EoC] Enable app menu item translation

For Chrome Home, we disabled the app menu item translation animation
when showing the menu. Since we conditioned this behavior on
ChromeActivity#getBottomSheet() != null, the app menu item translation
animation was incorrectly disabled for EoC.

BUG=833610,814528

Change-Id: I6225f7d490cc41d57b5efc6a8ffe26b706cccbbb
Reviewed-on: https://chromium-review.googlesource.com/1015160Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552091}
parent 42791f42
...@@ -60,7 +60,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -60,7 +60,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
private final int mVerticalFadeDistance; private final int mVerticalFadeDistance;
private final int mNegativeSoftwareVerticalOffset; private final int mNegativeSoftwareVerticalOffset;
private final int[] mTempLocation; private final int[] mTempLocation;
private final boolean mTranslateMenuItemsOnShow;
private PopupWindow mPopup; private PopupWindow mPopup;
private ListView mListView; private ListView mListView;
...@@ -80,11 +79,9 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -80,11 +79,9 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
* @param itemDividerHeight Desired height for the divider between app menu items. * @param itemDividerHeight Desired height for the divider between app menu items.
* @param handler AppMenuHandler receives callbacks from AppMenu. * @param handler AppMenuHandler receives callbacks from AppMenu.
* @param res Resources object used to get dimensions and style attributes. * @param res Resources object used to get dimensions and style attributes.
* @param translateMenuItemsOnShow Whether menu items should be translated during the animation
* that is run when the menu is shown.
*/ */
AppMenu(Menu menu, int itemRowHeight, int itemDividerHeight, AppMenuHandler handler, AppMenu(Menu menu, int itemRowHeight, int itemDividerHeight, AppMenuHandler handler,
Resources res, boolean translateMenuItemsOnShow) { Resources res) {
mMenu = menu; mMenu = menu;
mItemRowHeight = itemRowHeight; mItemRowHeight = itemRowHeight;
...@@ -100,7 +97,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -100,7 +97,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
mVerticalFadeDistance = res.getDimensionPixelSize(R.dimen.menu_vertical_fade_distance); mVerticalFadeDistance = res.getDimensionPixelSize(R.dimen.menu_vertical_fade_distance);
mTempLocation = new int[2]; mTempLocation = new int[2];
mTranslateMenuItemsOnShow = translateMenuItemsOnShow;
} }
/** /**
...@@ -242,8 +238,8 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -242,8 +238,8 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
// A List adapter for visible items in the Menu. The first row is added as a header to the // A List adapter for visible items in the Menu. The first row is added as a header to the
// list view. // list view.
mAdapter = new AppMenuAdapter(this, menuItems, LayoutInflater.from(context), mAdapter = new AppMenuAdapter(
highlightedItemId, mTranslateMenuItemsOnShow); this, menuItems, LayoutInflater.from(context), highlightedItemId);
ViewGroup contentView = ViewGroup contentView =
(ViewGroup) LayoutInflater.from(context).inflate(R.layout.app_menu_layout, null); (ViewGroup) LayoutInflater.from(context).inflate(R.layout.app_menu_layout, null);
......
...@@ -99,16 +99,14 @@ class AppMenuAdapter extends BaseAdapter { ...@@ -99,16 +99,14 @@ class AppMenuAdapter extends BaseAdapter {
private final int mNumMenuItems; private final int mNumMenuItems;
private final Integer mHighlightedItemId; private final Integer mHighlightedItemId;
private final float mDpToPx; private final float mDpToPx;
private final boolean mTranslateMenuItemsOnShow;
public AppMenuAdapter(AppMenu appMenu, List<MenuItem> menuItems, LayoutInflater inflater, public AppMenuAdapter(AppMenu appMenu, List<MenuItem> menuItems, LayoutInflater inflater,
Integer highlightedItemId, boolean translateMenuItemsOnShow) { Integer highlightedItemId) {
mAppMenu = appMenu; mAppMenu = appMenu;
mMenuItems = menuItems; mMenuItems = menuItems;
mInflater = inflater; mInflater = inflater;
mHighlightedItemId = highlightedItemId; mHighlightedItemId = highlightedItemId;
mNumMenuItems = menuItems.size(); mNumMenuItems = menuItems.size();
mTranslateMenuItemsOnShow = translateMenuItemsOnShow;
mDpToPx = inflater.getContext().getResources().getDisplayMetrics().density; mDpToPx = inflater.getContext().getResources().getDisplayMetrics().density;
} }
...@@ -364,17 +362,10 @@ class AppMenuAdapter extends BaseAdapter { ...@@ -364,17 +362,10 @@ class AppMenuAdapter extends BaseAdapter {
final int startDelay = ENTER_ITEM_BASE_DELAY_MS + ENTER_ITEM_ADDL_DELAY_MS * position; final int startDelay = ENTER_ITEM_BASE_DELAY_MS + ENTER_ITEM_ADDL_DELAY_MS * position;
AnimatorSet animation = new AnimatorSet(); AnimatorSet animation = new AnimatorSet();
if (mTranslateMenuItemsOnShow) { final float offsetYPx = ENTER_STANDARD_ITEM_OFFSET_Y_DP * mDpToPx;
final float offsetYPx = ENTER_STANDARD_ITEM_OFFSET_Y_DP * mDpToPx; animation.playTogether(ObjectAnimator.ofFloat(view, View.ALPHA, 0.f, 1.f),
animation.playTogether(ObjectAnimator.ofFloat(view, View.ALPHA, 0.f, 1.f), ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, offsetYPx, 0.f));
ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, offsetYPx, 0.f)); animation.setStartDelay(startDelay);
animation.setStartDelay(startDelay);
} else {
animation.playTogether(ObjectAnimator.ofFloat(view, View.ALPHA, 0.f, 1.f));
// Start delay is set to make sure disabling the animation in battery saver mode does
// not cause the view to stay at alpha 0 on Android O.
animation.setStartDelay(ENTER_ITEM_BASE_DELAY_MS);
}
animation.setDuration(ENTER_ITEM_DURATION_MS); animation.setDuration(ENTER_ITEM_DURATION_MS);
animation.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE); animation.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE);
......
...@@ -18,7 +18,6 @@ import android.widget.PopupMenu; ...@@ -18,7 +18,6 @@ import android.widget.PopupMenu;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -140,10 +139,8 @@ public class AppMenuHandler { ...@@ -140,10 +139,8 @@ public class AppMenuHandler {
Drawable itemDivider = a.getDrawable(1); Drawable itemDivider = a.getDrawable(1);
int itemDividerHeight = itemDivider != null ? itemDivider.getIntrinsicHeight() : 0; int itemDividerHeight = itemDivider != null ? itemDivider.getIntrinsicHeight() : 0;
a.recycle(); a.recycle();
boolean translateMenuItemsOnShow = !(mActivity instanceof ChromeActivity) mAppMenu = new AppMenu(
|| ((ChromeActivity) mActivity).getBottomSheet() == null; mMenu, itemRowHeight, itemDividerHeight, this, mActivity.getResources());
mAppMenu = new AppMenu(mMenu, itemRowHeight, itemDividerHeight, this,
mActivity.getResources(), translateMenuItemsOnShow);
mAppMenuDragHelper = new AppMenuDragHelper(mActivity, mAppMenu, itemRowHeight); mAppMenuDragHelper = new AppMenuDragHelper(mActivity, mAppMenu, itemRowHeight);
} }
......
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