Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarWrapper.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarWrapper.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarWrapper.java |
| index f0c5e8cdf860e31f5b2ffafd12281e6788e843ae..9d4f5b0549b8ae28df21513e890691bbf8e50035 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarWrapper.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarWrapper.java |
| @@ -19,6 +19,15 @@ class InfoBarWrapper extends FrameLayout { |
| 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 mHeightForAnimation; |
|
Ted C
2017/05/19 17:21:41
I would throw a Px suffix on this to make it super
mdjones
2017/05/19 17:30:14
Done.
|
| + |
| /** |
| * Constructor for inflating from Java. |
| */ |
| @@ -35,11 +44,36 @@ class InfoBarWrapper extends FrameLayout { |
| setPadding(0, shadowHeight, 0, 0); |
| } |
| + /** |
| + * @param restrict Whether or not the height of this view should be restricted for animations. |
| + */ |
| + public void setRestrictHeightForAnimation(boolean restrict) { |
| + mRestrictHeightForAnimation = restrict; |
| + } |
| + |
| + /** |
| + * @param height The restricted height in px that will be used if |
| + * {@link #mRestrictHeightForAnimation} is set. |
| + */ |
| + public void setHeightForAnimation(int height) { |
| + mHeightForAnimation = height; |
| + } |
| + |
| InfoBarContainerLayout.Item getItem() { |
| return mItem; |
| } |
| @Override |
| + public void onMeasure(int widthSpec, int heightSpec) { |
| + if (mRestrictHeightForAnimation) { |
| + int height = Math.min(mHeightForAnimation, MeasureSpec.getSize(heightSpec)); |
| + heightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.getMode(heightSpec)); |
| + } |
| + |
| + super.onMeasure(widthSpec, heightSpec); |
| + } |
| + |
| + @Override |
| public void onViewAdded(View child) { |
| child.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, |
| Gravity.TOP)); |