Commit 7c8e44dd authored by dtrainor@chromium.org's avatar dtrainor@chromium.org

Add per-item animations to the menu

- Animate the normal menu items down into the menu while fading in.
- Animate the icon row to the left while fading in.

BUG=394898
NOTRY=true

Review URL: https://codereview.chromium.org/388803006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284781 0039d316-1c4b-4281-b951-d872f2087c98
parent 3c893eca
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<resources>
<item name="menu_item_enter_anim_id" type="id" />
</resources>
......@@ -4,6 +4,8 @@
package org.chromium.chrome.browser.appmenu;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
......@@ -147,6 +149,15 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
mPopup.getListView().setVerticalFadingEdgeEnabled(true);
mPopup.getListView().setFadingEdgeLength(mVerticalFadeDistance);
}
mPopup.getListView().addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
mPopup.getListView().removeOnLayoutChangeListener(this);
runMenuItemEnterAnimations();
}
});
}
private void setPopupOffset(ListPopupWindow popup, int screenRotation, Rect appRect) {
......@@ -225,7 +236,9 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
*/
void dismiss() {
mHandler.appMenuDismissed();
if (isShowing()) mPopup.dismiss();
if (isShowing()) {
mPopup.dismiss();
}
}
/**
......@@ -277,4 +290,24 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
mPopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
}
}
private void runMenuItemEnterAnimations() {
AnimatorSet animation = new AnimatorSet();
AnimatorSet.Builder builder = null;
ViewGroup list = mPopup.getListView();
for (int i = 0; i < list.getChildCount(); i++) {
View view = list.getChildAt(i);
Object animatorObject = view.getTag(R.id.menu_item_enter_anim_id);
if (animatorObject != null) {
if (builder == null) {
builder = animation.play((Animator) animatorObject);
} else {
builder.with((Animator) animatorObject);
}
}
}
animation.start();
}
}
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