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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/BoundedLinearLayout.java

Issue 1716683002: [Custom Tabs] Allow clients to display RemoteViews on the bottom bar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make findbug happy Created 4 years, 10 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/customtabs/CustomTabsConnection.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/widget/BoundedLinearLayout.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/BoundedLinearLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/BoundedLinearLayout.java
index 4c6b41c2bd807b93c3de1fc58f50c1e126e4fdb7..6fe79ff23cf7c7fd6a06e1d3b70ff5640f2efeaf 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/BoundedLinearLayout.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/BoundedLinearLayout.java
@@ -12,7 +12,7 @@ import android.widget.LinearLayout;
import org.chromium.chrome.R;
/**
- * A LinearLayout that can be constrained to a maximum width.
+ * A LinearLayout that can be constrained to a maximum size.
*
* Example:
* <org.chromium.chrome.browser.widget.BoundedLinearLayout
@@ -25,9 +25,10 @@ import org.chromium.chrome.R;
*/
public class BoundedLinearLayout extends LinearLayout {
- private static final int NO_MAX_WIDTH = -1;
+ private static final int NOT_SPECIFIED = -1;
private final int mMaxWidth;
+ private final int mMaxHeight;
/**
* Constructor for inflating from XML.
@@ -35,7 +36,8 @@ public class BoundedLinearLayout extends LinearLayout {
public BoundedLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BoundedView);
- mMaxWidth = a.getDimensionPixelSize(R.styleable.BoundedView_maxWidth, NO_MAX_WIDTH);
+ mMaxWidth = a.getDimensionPixelSize(R.styleable.BoundedView_maxWidth, NOT_SPECIFIED);
+ mMaxHeight = a.getDimensionPixelSize(R.styleable.BoundedView_maxHeight, NOT_SPECIFIED);
a.recycle();
}
@@ -43,11 +45,17 @@ public class BoundedLinearLayout extends LinearLayout {
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Limit width to mMaxWidth.
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
- if (mMaxWidth != NO_MAX_WIDTH && widthSize > mMaxWidth) {
+ if (mMaxWidth != NOT_SPECIFIED && widthSize > mMaxWidth) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
if (widthMode == MeasureSpec.UNSPECIFIED) widthMode = MeasureSpec.AT_MOST;
widthMeasureSpec = MeasureSpec.makeMeasureSpec(mMaxWidth, widthMode);
}
+ int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+ if (mMaxHeight != NOT_SPECIFIED && heightSize > mMaxHeight) {
+ int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+ if (heightMode == MeasureSpec.UNSPECIFIED) heightMode = MeasureSpec.AT_MOST;
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(mMaxHeight, heightMode);
+ }
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698