Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1473)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java

Issue 2846663002: Peek new infobars behind existing ones (Closed)
Patch Set: undo tab changes Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/banners/SwipableOverlayView.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dac8fbd155857d5f27d1e05f6671668acba72857..150cbb314dfb424cd5194db09d50df80f89b20ca 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
@@ -15,6 +15,7 @@ import android.content.res.Resources;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.FrameLayout;
import org.chromium.base.ObserverList;
@@ -22,6 +23,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
@@ -112,6 +114,16 @@ public 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);
+ }
+
+ @Override
+ public void onAttachedToWindow() {
+ super.onAttachedToWindow();
+
+ mBottomContainer = (ViewGroup) getRootView().findViewById(R.id.bottom_container);
}
/**
@@ -175,10 +187,17 @@ public 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;
+
+ /** The bottom container that the infobar container sits inside of. */
+ private ViewGroup mBottomContainer;
+
/**
* Base class for animations inside the InfoBarContainerLayout.
*
@@ -215,11 +234,10 @@ public 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();
}
});
@@ -398,6 +416,7 @@ public class InfoBarContainerLayout extends FrameLayout {
BackInfoBarAppearingAnimation(Item appearingItem) {
mAppearingWrapper = new InfoBarWrapper(getContext(), appearingItem);
+ mAppearingWrapper.addView(appearingItem.getView());
}
@Override
@@ -407,9 +426,41 @@ public 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);
+ animators.add(animator);
+
+ animators.add(createTranslationYAnimator(mAppearingWrapper, 0));
+
+ set.addListener(new AnimatorListenerAdapter() {
Ted C 2017/05/18 00:09:29 merge with the one below?
mdjones 2017/05/18 17:40:13 Whoops. Done.
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mAppearingWrapper.removeView(mAppearingWrapper.getItem().getView());
+ }
+ });
+
+ set.playSequentially(animators);
+ set.setDuration(DURATION_PEEK_MS);
+
+ // 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) {
+ mBottomContainer.setClipChildren(false);
Ted C 2017/05/18 00:09:29 should we also set setClipChildren on the InfobarC
mdjones 2017/05/18 17:40:13 Added utility method that sets this value in all t
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mBottomContainer.setClipChildren(true);
+ }
+ });
+
+ return set;
}
@Override
@@ -837,7 +888,10 @@ public 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/banners/SwipableOverlayView.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698