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

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

Issue 1539643002: Make InfoBarControlLayouts more aesthetically pleasing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Logs Created 5 years 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 | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarControlLayoutTest.java » ('j') | 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/InfoBarControlLayout.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarControlLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarControlLayout.java
index 6b5e1a9cdb95a629e05dca6000a87ad46c6c4498..7bb2d2dec166408d794b1769090e5bc8a1cae03c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarControlLayout.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarControlLayout.java
@@ -92,25 +92,49 @@ public final class InfoBarControlLayout extends ViewGroup {
int exactlyColumnWidthSpec = MeasureSpec.makeMeasureSpec(columnWidth, MeasureSpec.EXACTLY);
int unspecifiedSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- // Measure all children, assuming they all have to fit within the width of the layout.
- // Height is unconstrained.
+ // Figure out how many columns each child requires.
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
measureChild(child, atMostFullWidthSpec, unspecifiedSpec);
if (child.getMeasuredWidth() <= columnWidth
&& !getControlLayoutParams(child).mMustBeFullWidth) {
- // Stretch out the control to take up a column width.
getControlLayoutParams(child).columnsRequired = 1;
- measureChild(child, exactlyColumnWidthSpec, unspecifiedSpec);
} else {
- // Stretch out the control to take up the full width.
getControlLayoutParams(child).columnsRequired = 2;
- measureChild(child, exactlyFullWidthSpec, unspecifiedSpec);
}
}
// Pack all the children as tightly into rows as possible without changing their ordering.
+ // Stretch out column-width controls if either it is the last control or the next one is
+ // a full-width control.
+ for (int i = 0; i < getChildCount(); i++) {
+ ControlLayoutParams lp = getControlLayoutParams(getChildAt(i));
+
+ if (i == getChildCount() - 1) {
+ lp.columnsRequired = 2;
+ } else {
+ ControlLayoutParams nextLp = getControlLayoutParams(getChildAt(i + 1));
+ if (lp.columnsRequired + nextLp.columnsRequired > 2) {
+ // This control is too big to place with the next child.
+ lp.columnsRequired = 2;
+ } else {
+ // This and the next control fit on the same line. Skip placing the next child.
+ i++;
+ }
+ }
+ }
+
+ // Measure all children, assuming they all have to fit within the width of the layout.
+ // Height is unconstrained.
+ for (int i = 0; i < getChildCount(); i++) {
+ View child = getChildAt(i);
+ ControlLayoutParams lp = getControlLayoutParams(child);
+ int spec = lp.columnsRequired == 1 ? exactlyColumnWidthSpec : exactlyFullWidthSpec;
+ measureChild(child, spec, unspecifiedSpec);
+ }
+
+ // Pack all the children as tightly into rows as possible without changing their ordering.
int layoutHeight = 0;
int nextChildStart = 0;
int nextChildTop = 0;
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarControlLayoutTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698