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

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

Issue 2846663002: Peek new infobars behind existing ones (Closed)
Patch Set: measure happens while adding view 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/infobar/InfoBarContainerLayout.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/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..c64ded9e6b308b84d461e9a86cb7d215e0c802ab 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 mHeightForAnimationPx;
+
/**
* Constructor for inflating from Java.
*/
@@ -33,6 +42,22 @@ class InfoBarWrapper extends FrameLayout {
// setBackgroundResource() changes the padding, so call setPadding() second.
setBackgroundResource(R.drawable.infobar_wrapper_bg);
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() {
@@ -40,6 +65,16 @@ class InfoBarWrapper extends FrameLayout {
}
@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
public void onViewAdded(View child) {
child.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
Gravity.TOP));
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainerLayout.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698