Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java |
| index f80439e8f7a28d8b1490f9dd96599eed6d6c8846..937b4865a284ec5646d49166cfc4841120907e9f 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java |
| @@ -21,6 +21,7 @@ import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.infobar.InfoBarContainer.InfoBarAnimationListener; |
| import java.util.ArrayList; |
| +import java.util.List; |
| /** |
| * Layout that displays infobars in a stack. Handles all the animations when adding or removing |
| @@ -105,6 +106,9 @@ class InfoBarContainerLayout extends FrameLayout { |
| Resources res = context.getResources(); |
| mBackInfobarHeight = res.getDimensionPixelSize(R.dimen.infobar_peeking_height); |
| mFloatingBehavior = new FloatingBehavior(this); |
| + mBackgroundPeekSize = getResources().getDimensionPixelSize(R.dimen.min_touch_target_size); |
| + |
| + setClipChildren(false); |
| } |
| /** |
| @@ -161,10 +165,14 @@ class InfoBarContainerLayout extends FrameLayout { |
| // Animation durations. |
| private static final int DURATION_SLIDE_UP_MS = 250; |
| + private static final int DURATION_PEEK_MS = 500; |
| private static final int DURATION_SLIDE_DOWN_MS = 250; |
| private static final int DURATION_FADE_MS = 100; |
| private static final int DURATION_FADE_OUT_MS = 200; |
| + // The height that an infobar will peek when being added behind another one. |
| + private final int mBackgroundPeekSize; |
| + |
| /** |
| * Base class for animations inside the InfoBarContainerLayout. |
| * |
| @@ -201,11 +209,10 @@ class InfoBarContainerLayout extends FrameLayout { |
| * value to endValue and updates the side shadow positions on each frame. |
| */ |
| ValueAnimator createTranslationYAnimator(final InfoBarWrapper wrapper, float endValue) { |
| - ValueAnimator animator = ValueAnimator.ofFloat(wrapper.getTranslationY(), endValue); |
| + ValueAnimator animator = ObjectAnimator.ofFloat(wrapper, View.TRANSLATION_Y, endValue); |
| animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { |
| @Override |
| public void onAnimationUpdate(ValueAnimator animation) { |
| - wrapper.setTranslationY((float) animation.getAnimatedValue()); |
| mFloatingBehavior.updateShadowPosition(); |
| } |
| }); |
| @@ -384,6 +391,7 @@ class InfoBarContainerLayout extends FrameLayout { |
| BackInfoBarAppearingAnimation(Item appearingItem) { |
| mAppearingWrapper = new InfoBarWrapper(getContext(), appearingItem); |
| + mAppearingWrapper.addView(appearingItem.getView()); |
| } |
| @Override |
| @@ -393,9 +401,28 @@ class InfoBarContainerLayout extends FrameLayout { |
| @Override |
| Animator createAnimator() { |
| + AnimatorSet set = new AnimatorSet(); |
| + List<Animator> animators = new ArrayList<>(); |
| + |
| mAppearingWrapper.setTranslationY(mAppearingWrapper.getHeight()); |
| - return createTranslationYAnimator(mAppearingWrapper, 0f) |
| - .setDuration(DURATION_SLIDE_UP_MS); |
| + ValueAnimator animator = |
| + createTranslationYAnimator(mAppearingWrapper, -mBackgroundPeekSize); |
| + animator.setDuration(DURATION_PEEK_MS); |
|
Ted C
2017/05/17 17:55:54
We should be able to set the duration on the set s
mdjones
2017/05/17 21:05:19
Setting duration on the set ends up working just f
|
| + animators.add(animator); |
| + |
| + animators.add( |
| + createTranslationYAnimator(mAppearingWrapper, 0).setDuration(DURATION_PEEK_MS)); |
| + |
| + set.addListener(new AnimatorListenerAdapter() { |
|
Ted C
2017/05/17 17:55:54
Do you want the view to be removed even if the set
mdjones
2017/05/17 21:05:19
When cancel is called on the animator set, cancel
|
| + @Override |
| + public void onAnimationEnd(Animator animation) { |
| + mAppearingWrapper.removeView(mAppearingWrapper.getItem().getView()); |
| + } |
| + }); |
| + |
| + set.playSequentially(animators); |
| + |
| + return set; |
| } |
| @Override |
| @@ -815,7 +842,10 @@ class InfoBarContainerLayout extends FrameLayout { |
| protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| widthMeasureSpec = mFloatingBehavior.beforeOnMeasure(widthMeasureSpec); |
| super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| - mFloatingBehavior.afterOnMeasure(getMeasuredHeight()); |
| + |
| + // Make sure the shadow is tall enough to compensate for the peek animation of other |
| + // infboars. |
| + mFloatingBehavior.afterOnMeasure(getMeasuredHeight() + mBackgroundPeekSize); |
| } |
| @Override |