Commit 7f332e80 authored by Becky Zhou's avatar Becky Zhou Committed by Commit Bot

Remove bottom AppMenu list items translation animation

+ Set list item translation value to 0 when app menu is anchored
  at bottom

Before: Bottom AppMenu list items translate y position while fade in
Now: List items don't translate y position while fade in when
     app menu is at bottom, but still translate when at top.

BUG=735272

Change-Id: I0f20647807916059c7c81613772f5881c85600da
Reviewed-on: https://chromium-review.googlesource.com/566588Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486803}
parent 92aaf60d
...@@ -63,6 +63,7 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -63,6 +63,7 @@ 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;
...@@ -82,9 +83,11 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -82,9 +83,11 @@ 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) { Resources res, boolean translateMenuItemsOnShow) {
mMenu = menu; mMenu = menu;
mItemRowHeight = itemRowHeight; mItemRowHeight = itemRowHeight;
...@@ -100,6 +103,7 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -100,6 +103,7 @@ 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;
} }
/** /**
...@@ -237,8 +241,8 @@ public class AppMenu implements OnItemClickListener, OnKeyListener { ...@@ -237,8 +241,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( mAdapter = new AppMenuAdapter(this, menuItems, LayoutInflater.from(context),
this, menuItems, LayoutInflater.from(context), highlightedItemId); highlightedItemId, mTranslateMenuItemsOnShow);
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);
......
...@@ -103,6 +103,7 @@ class AppMenuAdapter extends BaseAdapter { ...@@ -103,6 +103,7 @@ 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;
// Use a single PulseDrawable to spawn the other drawables so that the ConstantState gets // Use a single PulseDrawable to spawn the other drawables so that the ConstantState gets
// shared. This allows the animation to stay in step even as the views are recycled and the // shared. This allows the animation to stay in step even as the views are recycled and the
...@@ -111,12 +112,13 @@ class AppMenuAdapter extends BaseAdapter { ...@@ -111,12 +112,13 @@ class AppMenuAdapter extends BaseAdapter {
private PulseDrawable mHighlightDrawableSource; private PulseDrawable mHighlightDrawableSource;
public AppMenuAdapter(AppMenu appMenu, List<MenuItem> menuItems, LayoutInflater inflater, public AppMenuAdapter(AppMenu appMenu, List<MenuItem> menuItems, LayoutInflater inflater,
Integer highlightedItemId) { Integer highlightedItemId, boolean translateMenuItemsOnShow) {
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;
} }
...@@ -376,15 +378,18 @@ class AppMenuAdapter extends BaseAdapter { ...@@ -376,15 +378,18 @@ class AppMenuAdapter extends BaseAdapter {
* @return The {@link Animator}. * @return The {@link Animator}.
*/ */
private Animator buildStandardItemEnterAnimator(final View view, int position) { private Animator buildStandardItemEnterAnimator(final View view, int position) {
final float offsetYPx = ENTER_STANDARD_ITEM_OFFSET_Y_DP * mDpToPx;
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();
animation.playTogether( if (mTranslateMenuItemsOnShow) {
ObjectAnimator.ofFloat(view, View.ALPHA, 0.f, 1.f), final float offsetYPx = ENTER_STANDARD_ITEM_OFFSET_Y_DP * mDpToPx;
ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, offsetYPx, 0.f)); animation.playTogether(ObjectAnimator.ofFloat(view, View.ALPHA, 0.f, 1.f),
ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, offsetYPx, 0.f));
animation.setStartDelay(startDelay);
} else {
animation.playTogether(ObjectAnimator.ofFloat(view, View.ALPHA, 0.f, 1.f));
}
animation.setDuration(ENTER_ITEM_DURATION_MS); animation.setDuration(ENTER_ITEM_DURATION_MS);
animation.setStartDelay(startDelay);
animation.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE); animation.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE);
animation.addListener(new AnimatorListenerAdapter() { animation.addListener(new AnimatorListenerAdapter() {
......
...@@ -18,6 +18,7 @@ import android.widget.PopupMenu; ...@@ -18,6 +18,7 @@ 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;
...@@ -139,8 +140,10 @@ public class AppMenuHandler { ...@@ -139,8 +140,10 @@ 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)
|| ((ChromeActivity) mActivity).getBottomSheet() == null;
mAppMenu = new AppMenu(mMenu, itemRowHeight, itemDividerHeight, this, mAppMenu = new AppMenu(mMenu, itemRowHeight, itemDividerHeight, this,
mActivity.getResources()); 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