Commit 4b357070 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Revert "Peek new infobars behind existing ones"

This reverts commit 58394da4 as it
causes a crash and undesirable behavior in the existing
infractructure.

BUG=729575, 729611, 721389

Change-Id: I029fcc2c6d63b849bf511e57bd2737acb0b6325f
Reviewed-on: https://chromium-review.googlesource.com/564081Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485112}
parent 3206fa07
...@@ -15,8 +15,6 @@ import android.content.res.Resources; ...@@ -15,8 +15,6 @@ import android.content.res.Resources;
import android.view.Gravity; import android.view.Gravity;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.chromium.base.ObserverList; import org.chromium.base.ObserverList;
...@@ -24,7 +22,6 @@ import org.chromium.chrome.R; ...@@ -24,7 +22,6 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.infobar.InfoBarContainer.InfoBarAnimationListener; import org.chromium.chrome.browser.infobar.InfoBarContainer.InfoBarAnimationListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
/** /**
* Layout that displays infobars in a stack. Handles all the animations when adding or removing * Layout that displays infobars in a stack. Handles all the animations when adding or removing
...@@ -115,15 +112,6 @@ public class InfoBarContainerLayout extends FrameLayout { ...@@ -115,15 +112,6 @@ public class InfoBarContainerLayout extends FrameLayout {
Resources res = context.getResources(); Resources res = context.getResources();
mBackInfobarHeight = res.getDimensionPixelSize(R.dimen.infobar_peeking_height); mBackInfobarHeight = res.getDimensionPixelSize(R.dimen.infobar_peeking_height);
mFloatingBehavior = new FloatingBehavior(this); mFloatingBehavior = new FloatingBehavior(this);
mBackgroundPeekSize = getResources().getDimensionPixelSize(R.dimen.infobar_compact_size);
mInfoBarShadowHeight = getResources().getDimensionPixelSize(R.dimen.infobar_shadow_height);
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
mBottomContainer = (ViewGroup) getRootView().findViewById(R.id.bottom_container);
} }
/** /**
...@@ -187,20 +175,10 @@ public class InfoBarContainerLayout extends FrameLayout { ...@@ -187,20 +175,10 @@ public class InfoBarContainerLayout extends FrameLayout {
// Animation durations. // Animation durations.
private static final int DURATION_SLIDE_UP_MS = 250; 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_SLIDE_DOWN_MS = 250;
private static final int DURATION_FADE_MS = 100; private static final int DURATION_FADE_MS = 100;
private static final int DURATION_FADE_OUT_MS = 200; 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;
/** The height of the shadow that sits above the infobar. */
private final int mInfoBarShadowHeight;
/** The bottom container that the infobar container sits inside of. */
private ViewGroup mBottomContainer;
/** /**
* Base class for animations inside the InfoBarContainerLayout. * Base class for animations inside the InfoBarContainerLayout.
* *
...@@ -237,10 +215,11 @@ public class InfoBarContainerLayout extends FrameLayout { ...@@ -237,10 +215,11 @@ public class InfoBarContainerLayout extends FrameLayout {
* value to endValue and updates the side shadow positions on each frame. * value to endValue and updates the side shadow positions on each frame.
*/ */
ValueAnimator createTranslationYAnimator(final InfoBarWrapper wrapper, float endValue) { ValueAnimator createTranslationYAnimator(final InfoBarWrapper wrapper, float endValue) {
ValueAnimator animator = ObjectAnimator.ofFloat(wrapper, View.TRANSLATION_Y, endValue); ValueAnimator animator = ValueAnimator.ofFloat(wrapper.getTranslationY(), endValue);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override @Override
public void onAnimationUpdate(ValueAnimator animation) { public void onAnimationUpdate(ValueAnimator animation) {
wrapper.setTranslationY((float) animation.getAnimatedValue());
mFloatingBehavior.updateShadowPosition(); mFloatingBehavior.updateShadowPosition();
} }
}); });
...@@ -428,39 +407,14 @@ public class InfoBarContainerLayout extends FrameLayout { ...@@ -428,39 +407,14 @@ public class InfoBarContainerLayout extends FrameLayout {
@Override @Override
Animator createAnimator() { Animator createAnimator() {
AnimatorSet set = new AnimatorSet();
List<Animator> animators = new ArrayList<>();
mAppearingWrapper.setTranslationY(mAppearingWrapper.getHeight()); mAppearingWrapper.setTranslationY(mAppearingWrapper.getHeight());
mAppearingWrapper.setRestrictHeightForAnimation(true); return createTranslationYAnimator(mAppearingWrapper, 0f)
mAppearingWrapper.setHeightForAnimation(mInfoBarShadowHeight + mBackgroundPeekSize); .setDuration(DURATION_SLIDE_UP_MS);
mAppearingWrapper.addView(mAppearingWrapper.getItem().getView());
ValueAnimator animator = createTranslationYAnimator(
mAppearingWrapper, mBackInfobarHeight - mBackgroundPeekSize);
animators.add(animator);
animators.add(createTranslationYAnimator(mAppearingWrapper, 0));
// When the infobar container is running this specific animation, do not clip the
// children so the infobars can animate outside their container.
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
setHierarchyClipsChildren(false);
}
});
set.playSequentially(animators);
set.setDuration(DURATION_PEEK_MS);
return set;
} }
@Override @Override
public void onAnimationEnd() { public void onAnimationEnd() {
mAppearingWrapper.setRestrictHeightForAnimation(false);
mAppearingWrapper.removeView(mAppearingWrapper.getItem().getView()); mAppearingWrapper.removeView(mAppearingWrapper.getItem().getView());
setHierarchyClipsChildren(true);
} }
@Override @Override
...@@ -469,17 +423,6 @@ public class InfoBarContainerLayout extends FrameLayout { ...@@ -469,17 +423,6 @@ public class InfoBarContainerLayout extends FrameLayout {
} }
} }
/**
* Used to set the relevant view hierarchy to not clip its children. This is used during
* animation so views can draw outside the normal bounds.
* @param clip Whether or not to clip child views.
*/
private void setHierarchyClipsChildren(boolean clip) {
setClipChildren(clip);
((ViewGroup) getParent()).setClipChildren(clip);
mBottomContainer.setClipChildren(clip);
}
/** /**
* The animation to hide the front infobar and reveal the second-to-front infobar. The front * The animation to hide the front infobar and reveal the second-to-front infobar. The front
* infobar slides down and off the screen. The back infobar(s) will adjust to the size of the * infobar slides down and off the screen. The back infobar(s) will adjust to the size of the
...@@ -899,10 +842,7 @@ public class InfoBarContainerLayout extends FrameLayout { ...@@ -899,10 +842,7 @@ public class InfoBarContainerLayout extends FrameLayout {
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
widthMeasureSpec = mFloatingBehavior.beforeOnMeasure(widthMeasureSpec); widthMeasureSpec = mFloatingBehavior.beforeOnMeasure(widthMeasureSpec);
super.onMeasure(widthMeasureSpec, heightMeasureSpec); 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 @Override
......
...@@ -19,15 +19,6 @@ class InfoBarWrapper extends FrameLayout { ...@@ -19,15 +19,6 @@ class InfoBarWrapper extends FrameLayout {
private final InfoBarContainerLayout.Item mItem; private final InfoBarContainerLayout.Item mItem;
/** Whether or not the height of the layout should be restricted for animations. */
private boolean mRestrictHeightForAnimation;
/**
* The height in px that this view will be restricted to if
* {@link #mRestrictHeightForAnimation} is set.
*/
private int mHeightForAnimationPx;
/** /**
* Constructor for inflating from Java. * Constructor for inflating from Java.
*/ */
...@@ -42,38 +33,12 @@ class InfoBarWrapper extends FrameLayout { ...@@ -42,38 +33,12 @@ class InfoBarWrapper extends FrameLayout {
// setBackgroundResource() changes the padding, so call setPadding() second. // setBackgroundResource() changes the padding, so call setPadding() second.
setBackgroundResource(R.drawable.infobar_wrapper_bg); setBackgroundResource(R.drawable.infobar_wrapper_bg);
setPadding(0, shadowHeight, 0, 0); setPadding(0, shadowHeight, 0, 0);
setClipChildren(true);
}
/**
* @param restrict Whether or not the height of this view should be restricted for animations.
*/
public void setRestrictHeightForAnimation(boolean restrict) {
mRestrictHeightForAnimation = restrict;
}
/**
* @param heightPx The restricted height in px that will be used if
* {@link #mRestrictHeightForAnimation} is set.
*/
public void setHeightForAnimation(int heightPx) {
mHeightForAnimationPx = heightPx;
} }
InfoBarContainerLayout.Item getItem() { InfoBarContainerLayout.Item getItem() {
return mItem; return mItem;
} }
@Override
public void onMeasure(int widthSpec, int heightSpec) {
if (mRestrictHeightForAnimation) {
int heightPx = Math.min(mHeightForAnimationPx, MeasureSpec.getSize(heightSpec));
heightSpec = MeasureSpec.makeMeasureSpec(heightPx, MeasureSpec.getMode(heightSpec));
}
super.onMeasure(widthSpec, heightSpec);
}
@Override @Override
public void onViewAdded(View child) { public void onViewAdded(View child) {
child.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, child.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
......
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