Commit 64c3f931 authored by Ehimare Okoyomon's avatar Ehimare Okoyomon Committed by Commit Bot

Adjust CookieControlsCard width programmatically

Rotating the screen could cause UI issues with cookie controls card if
the screen is big enough for resizing. Set the width dynamically based
on this.

Bug: 1040091
Change-Id: Ieaf39b55662953db7dbeb05c954b8a32e148e1d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089904Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Ehimare Okoyomon <eokoyomon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747914}
parent 12ca428a
...@@ -40,6 +40,7 @@ import java.util.Locale; ...@@ -40,6 +40,7 @@ import java.util.Locale;
public class IncognitoDescriptionView extends LinearLayout { public class IncognitoDescriptionView extends LinearLayout {
private int mWidthDp; private int mWidthDp;
private int mHeightDp; private int mHeightDp;
private boolean mShowCard;
private LinearLayout mContainer; private LinearLayout mContainer;
private TextView mHeader; private TextView mHeader;
...@@ -130,6 +131,7 @@ public class IncognitoDescriptionView extends LinearLayout { ...@@ -130,6 +131,7 @@ public class IncognitoDescriptionView extends LinearLayout {
adjustIcon(); adjustIcon();
adjustLayout(); adjustLayout();
adjustLearnMore(); adjustLearnMore();
adjustCookieControlsCard();
} }
/** /**
...@@ -299,12 +301,29 @@ public class IncognitoDescriptionView extends LinearLayout { ...@@ -299,12 +301,29 @@ public class IncognitoDescriptionView extends LinearLayout {
mSubtitle.setMovementMethod(LinkMovementMethod.getInstance()); mSubtitle.setMovementMethod(LinkMovementMethod.getInstance());
} }
/** Adjust the Cookie Controls Card. */
private void adjustCookieControlsCard() {
if (mShowCard) {
if (mWidthDp <= WIDE_LAYOUT_THRESHOLD_DP) {
// Portrait
mCookieControlsCard.getLayoutParams().width =
LinearLayout.LayoutParams.MATCH_PARENT;
} else {
// Landscape
mCookieControlsCard.getLayoutParams().width =
dpToPx(getContext(), CONTENT_WIDTH_DP);
}
}
}
/** /**
* Adjust the Cookie Controls Card. * Adjust the Cookie Controls Card.
* @param showCard A boolean indicating if the card should be visible or not. * @param showCard A boolean indicating if the card should be visible or not.
*/ */
public void showCookieControlsCard(boolean showCard) { public void showCookieControlsCard(boolean showCard) {
mShowCard = showCard;
mCookieControlsCard.setVisibility(showCard ? View.VISIBLE : View.GONE); mCookieControlsCard.setVisibility(showCard ? View.VISIBLE : View.GONE);
adjustCookieControlsCard();
} }
/** /**
......
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