Commit cbd2ab58 authored by Troy Hildebrandt's avatar Troy Hildebrandt Committed by Commit Bot

Fix URL bar text being cropped by action buttons.

A recent change to the layout of the URL bar and the action buttons
container broke the calculation and application of margin to the URL bar
to avoid overlap between the action buttons and the URL bar.

This CL fixes the calculation of the new action container's width and
the appropriate margin to apply to the URL bar, fixing the issue where
text in the URL bar was hidden underneath the action container.

Bug: 816432,816376
Change-Id: Ic1793f29885392aae97f1b767b65276b597795e7
Reviewed-on: https://chromium-review.googlesource.com/938383
Commit-Queue: Troy Hildebrandt <thildebr@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarMaria Khomenko <mariakhomenko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540394}
parent 856375c1
......@@ -47,6 +47,7 @@ import android.view.ViewStub;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
......@@ -160,6 +161,7 @@ public class LocationBarLayout extends FrameLayout
protected TintedImageButton mDeleteButton;
protected TintedImageButton mMicButton;
protected UrlBar mUrlBar;
private LinearLayout mUrlActionContainer;
/** A handle to the bottom sheet for chrome home. */
protected BottomSheet mBottomSheet;
......@@ -720,6 +722,8 @@ public class LocationBarLayout extends FrameLayout
mSuggestionListAdapter = new OmniboxResultsAdapter(getContext(), this, mSuggestionItems);
mMicButton = (TintedImageButton) findViewById(R.id.mic_button);
mUrlActionContainer = (LinearLayout) findViewById(R.id.url_action_container);
}
@Override
......@@ -1534,22 +1538,21 @@ public class LocationBarLayout extends FrameLayout
}
}
assert urlContainerChildIndex != -1;
int urlContainerMarginEnd = 0;
// When Chrome Home is enabled, the URL actions container slides out of view during the
// URL defocus animation. Adding margin during this animation creates a hole.
boolean addMarginForActionsContainer =
mBottomSheet == null || !mUrlFocusChangeInProgress || mUrlHasFocus;
(mBottomSheet == null || !mUrlFocusChangeInProgress || mUrlHasFocus)
&& mUrlActionContainer.getVisibility() != GONE;
int urlContainerMarginEnd = 0;
if (addMarginForActionsContainer) {
for (int i = urlContainerChildIndex + 1; i < getChildCount(); i++) {
View childView = getChildAt(i);
if (childView.getVisibility() != GONE) {
LayoutParams childLayoutParams = (LayoutParams) childView.getLayoutParams();
urlContainerMarginEnd = Math.max(urlContainerMarginEnd,
childLayoutParams.width
+ ApiCompatibilityUtils.getMarginStart(childLayoutParams)
+ ApiCompatibilityUtils.getMarginEnd(childLayoutParams));
for (int i = 0; i < mUrlActionContainer.getChildCount(); i++) {
View button = mUrlActionContainer.getChildAt(i);
LinearLayout.LayoutParams buttonLayoutParams =
(LinearLayout.LayoutParams) button.getLayoutParams();
if (button.getVisibility() != GONE) {
urlContainerMarginEnd += buttonLayoutParams.width
+ ApiCompatibilityUtils.getMarginStart(buttonLayoutParams)
+ ApiCompatibilityUtils.getMarginEnd(buttonLayoutParams);
}
}
}
......
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