Commit 82d6a7b4 authored by Troy Hildebrandt's avatar Troy Hildebrandt Committed by Commit Bot

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