Commit 31ea1563 authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Android UI: remove maxWidth in BoundedLinearLayout.

We have introduced maxWidthLandscape and maxWidthPortrait, so maxWidth
can be removed, because:

1. Functionality overlap, and unnecessary complexity when using this
widget.

2. maxWidthLandscape/maxWidthPortrait can force people to notice
the difference between landscape and portrait views.

TBR=twellington@chromium.org

Bug: 852545
Change-Id: I3532701b3886969d8232a348ae36738ea3dc4259
Reviewed-on: https://chromium-review.googlesource.com/1099774
Commit-Queue: Xing Liu <xingliu@chromium.org>
Reviewed-by: default avatarBecky Zhou <huayinz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568080}
parent 16eaec90
......@@ -12,7 +12,8 @@
android:id="@+id/payment_request"
android:orientation="vertical"
android:gravity="center"
app:maxWidth="@dimen/payments_ui_max_dialog_width"
app:maxWidthLandscape="@dimen/payments_ui_max_dialog_width"
app:maxWidthPortrait="@dimen/payments_ui_max_dialog_width"
android:background="@android:color/white" >
<include layout="@layout/payment_request_header" />
......
......@@ -14,7 +14,8 @@
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/menu_bg"
app:maxWidth="@dimen/payments_ui_max_dialog_width" >
app:maxWidthLandscape="@dimen/payments_ui_max_dialog_width"
app:maxWidthPortrait="@dimen/payments_ui_max_dialog_width" >
<include layout="@layout/payment_request_header" />
......
......@@ -19,7 +19,8 @@
android:layout_gravity="center"
android:orientation="vertical"
android:background="@drawable/menu_bg"
app:maxWidth="@dimen/dialog_max_width" >
app:maxWidthLandscape="@dimen/dialog_max_width"
app:maxWidthPortrait="@dimen/dialog_max_width" >
<org.chromium.chrome.browser.widget.FadingEdgeScrollView
android:id="@+id/promo_container"
......@@ -53,7 +54,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:maxWidth="@dimen/promo_dialog_max_content_width" >
app:maxWidthLandscape="@dimen/promo_dialog_max_content_width"
app:maxWidthPortrait="@dimen/promo_dialog_max_content_width" >
<TextView
android:id="@+id/header"
......
......@@ -8,7 +8,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:gravity="center"
android:padding="24dp"
app:maxWidth="312dp"
app:maxWidthLandscape="312dp"
app:maxWidthPortrait="312dp"
style="@style/AlertDialogContent" >
<ProgressBar
......
......@@ -30,8 +30,6 @@ public class BoundedLinearLayout extends LinearLayout {
private static final int NOT_SPECIFIED = -1;
// TODO(xingliu): Get rid of mMaxWidth.
private final int mMaxWidth;
private TypedValue mMaxWidthLandscape = new TypedValue();
private TypedValue mMaxWidthPortrait = new TypedValue();
......@@ -44,19 +42,13 @@ public class BoundedLinearLayout extends LinearLayout {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BoundedView);
int maxWidth = a.getDimensionPixelSize(R.styleable.BoundedView_maxWidth, NOT_SPECIFIED);
int maxHeight = a.getDimensionPixelSize(R.styleable.BoundedView_maxHeight, NOT_SPECIFIED);
assert(maxWidth == NOT_SPECIFIED
|| (mMaxWidthLandscape.type == TypedValue.TYPE_NULL
&& mMaxWidthPortrait.type == TypedValue.TYPE_NULL));
a.getValue(R.styleable.BoundedView_maxWidthLandscape, mMaxWidthLandscape);
a.getValue(R.styleable.BoundedView_maxWidthPortrait, mMaxWidthPortrait);
a.recycle();
mMaxWidth = maxWidth <= 0 ? NOT_SPECIFIED : maxWidth;
mMaxHeight = maxHeight <= 0 ? NOT_SPECIFIED : maxHeight;
}
......@@ -65,26 +57,19 @@ public class BoundedLinearLayout extends LinearLayout {
final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;
// Limit the width with fixed value.
// Limit the width.
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
if (mMaxWidth != NOT_SPECIFIED && widthSize > mMaxWidth) {
widthMeasureSpec = makeMeasureSpec(widthMeasureSpec, mMaxWidth);
}
final TypedValue tv = isPortrait ? mMaxWidthPortrait : mMaxWidthLandscape;
if (tv.type != TypedValue.TYPE_NULL) {
int maxWidthPixel = NOT_SPECIFIED;
if (tv.type == TypedValue.TYPE_DIMENSION) {
maxWidthPixel = (int) tv.getDimension(metrics);
} else if (tv.type == TypedValue.TYPE_FRACTION) {
maxWidthPixel = (int) tv.getFraction(metrics.widthPixels, metrics.widthPixels);
}
// Limit the width with fraction of the screen if fixed width value is not specified.
if (mMaxWidth == NOT_SPECIFIED) {
final TypedValue tv = isPortrait ? mMaxWidthPortrait : mMaxWidthLandscape;
if (tv.type != TypedValue.TYPE_NULL) {
int maxWidthPixel = NOT_SPECIFIED;
if (tv.type == TypedValue.TYPE_DIMENSION) {
maxWidthPixel = (int) tv.getDimension(metrics);
} else if (tv.type == TypedValue.TYPE_FRACTION) {
maxWidthPixel = (int) tv.getFraction(metrics.widthPixels, metrics.widthPixels);
}
if (widthSize > maxWidthPixel && maxWidthPixel != NOT_SPECIFIED) {
widthMeasureSpec = makeMeasureSpec(widthMeasureSpec, maxWidthPixel);
}
if (widthSize > maxWidthPixel && maxWidthPixel > 0) {
widthMeasureSpec = makeMeasureSpec(widthMeasureSpec, maxWidthPixel);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment