Commit ec57b4a2 authored by Theresa's avatar Theresa Committed by Commit Bot

Revert "Clean up scrim logic in LocationBarLayout"

This reverts commit b422141f.

Reason for revert: Suspect that this broke ui automator tests

Original change's description:
> Clean up scrim logic in LocationBarLayout
> 
> Scrim visibility in the location bar is now completely controlled by
> a single function. The scrim observer is now added and removed based
> on the scrim visibility to avoid conflict with other observers (like
> the bottom sheet).
> 
> Bug: 834927
> Change-Id: I172ca637dde5bc026b1b7f629bc34c6d939dff2d
> Reviewed-on: https://chromium-review.googlesource.com/1026168
> Commit-Queue: Matthew Jones <mdjones@chromium.org>
> Reviewed-by: Ted Choc <tedchoc@chromium.org>
> Reviewed-by: Theresa <twellington@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#558785}

TBR=tedchoc@chromium.org,twellington@chromium.org,mdjones@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 834927
Change-Id: I46401b29a91f67cfa6aa6611b7d9bf854d1fd610
Reviewed-on: https://chromium-review.googlesource.com/1070890Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561317}
parent 4d001793
...@@ -179,7 +179,7 @@ public class LocationBarLayout ...@@ -179,7 +179,7 @@ public class LocationBarLayout
private Runnable mRequestSuggestions; private Runnable mRequestSuggestions;
private ViewGroup mOmniboxResultsContainer; private ViewGroup mOmniboxResultsContainer;
private FadingBackgroundView mFadingView; protected FadingBackgroundView mFadingView;
private boolean mSuggestionsShown; private boolean mSuggestionsShown;
private boolean mUrlHasFocus; private boolean mUrlHasFocus;
...@@ -878,8 +878,8 @@ public class LocationBarLayout ...@@ -878,8 +878,8 @@ public class LocationBarLayout
listener.onUrlFocusChange(hasFocus); listener.onUrlFocusChange(hasFocus);
} }
maybeShowOmniboxResultsContainer(); updateOmniboxResultsContainer();
updateFadingBackgroundView(hasFocus, false); if (hasFocus) updateFadingBackgroundView(true);
} }
/** /**
...@@ -1480,7 +1480,7 @@ public class LocationBarLayout ...@@ -1480,7 +1480,7 @@ public class LocationBarLayout
mSuggestionList.setVisibility(GONE); mSuggestionList.setVisibility(GONE);
} }
} }
maybeShowOmniboxResultsContainer(); updateOmniboxResultsContainer();
} }
/** /**
...@@ -2058,10 +2058,12 @@ public class LocationBarLayout ...@@ -2058,10 +2058,12 @@ public class LocationBarLayout
mOmniboxResultsContainer = (ViewGroup) overlayStub.inflate(); mOmniboxResultsContainer = (ViewGroup) overlayStub.inflate();
} }
private void maybeShowOmniboxResultsContainer() { private void updateOmniboxResultsContainer() {
if (mSuggestionsShown || mUrlHasFocus) { if (mSuggestionsShown || mUrlHasFocus) {
initOmniboxResultsContainer(); initOmniboxResultsContainer();
updateOmniboxResultsContainerVisibility(true); updateOmniboxResultsContainerVisibility(true);
} else if (mOmniboxResultsContainer != null) {
updateFadingBackgroundView(false);
} }
} }
...@@ -2078,10 +2080,21 @@ public class LocationBarLayout ...@@ -2078,10 +2080,21 @@ public class LocationBarLayout
} }
} }
/**
* Initialize the fading background for when the omnibox is focused.
*/
protected void initFadingOverlayView() {
mFadingView =
(FadingBackgroundView) getRootView().findViewById(R.id.fading_focus_target);
mFadingView.addObserver(this);
}
@Override @Override
public void onFadingViewClick() { public void onFadingViewClick() {
setUrlBarFocus(false); setUrlBarFocus(false);
updateFadingBackgroundView(false, false);
// If the bottom sheet is used, it will control the fading view.
if (mBottomSheet == null) updateFadingBackgroundView(false);
} }
@Override @Override
...@@ -2102,22 +2115,23 @@ public class LocationBarLayout ...@@ -2102,22 +2115,23 @@ public class LocationBarLayout
* Update the fading background view that shows when the omnibox is focused. If Chrome Home is * Update the fading background view that shows when the omnibox is focused. If Chrome Home is
* enabled, this method is a no-op. * enabled, this method is a no-op.
* @param visible Whether the background should be made visible. * @param visible Whether the background should be made visible.
* @param ignoreNtpChecks Whether the checks for the ntp should be considered when updating the
* scrim.
*/ */
protected void updateFadingBackgroundView(boolean visible, boolean ignoreNtpChecks) { private void updateFadingBackgroundView(boolean visible) {
if (mFadingView == null) mFadingView = getRootView().findViewById(R.id.fading_focus_target); if (mFadingView == null) initFadingOverlayView();
// If Chrome Home is enabled (the bottom sheet is not null), it will be controlling the
// fading view, so block any updating here.
if (mToolbarDataProvider == null || mBottomSheet != null) return;
NewTabPage ntp = mToolbarDataProvider.getNewTabPageForCurrentTab(); NewTabPage ntp = mToolbarDataProvider.getNewTabPageForCurrentTab();
boolean locationBarShownInNTP = ntp != null && ntp.isLocationBarShownInNTP(); boolean locationBarShownInNTP = ntp != null && ntp.isLocationBarShownInNTP();
if (visible && (!locationBarShownInNTP || ignoreNtpChecks)) { if (visible && !locationBarShownInNTP) {
mFadingView.addObserver(this);
// If the location bar is shown in the NTP, the toolbar will eventually trigger a // If the location bar is shown in the NTP, the toolbar will eventually trigger a
// fade in. // fade in.
mFadingView.showFadingOverlay(); mFadingView.showFadingOverlay();
} else { } else {
mFadingView.hideFadingOverlay(!locationBarShownInNTP); mFadingView.hideFadingOverlay(!locationBarShownInNTP);
mFadingView.removeObserver(this);
} }
} }
......
...@@ -188,7 +188,8 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -188,7 +188,8 @@ public class LocationBarPhone extends LocationBarLayout {
NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
if (hasFocus && ntp != null && ntp.isLocationBarShownInNTP() && mBottomSheet == null) { if (hasFocus && ntp != null && ntp.isLocationBarShownInNTP() && mBottomSheet == null) {
updateFadingBackgroundView(true, true); if (mFadingView == null) initFadingOverlayView();
mFadingView.showFadingOverlay();
} }
} }
......
...@@ -172,14 +172,6 @@ public class FadingBackgroundView extends View implements View.OnClickListener { ...@@ -172,14 +172,6 @@ public class FadingBackgroundView extends View implements View.OnClickListener {
mObservers.addObserver(observer); mObservers.addObserver(observer);
} }
/**
* Removes an observer to this fading view.
* @param observer The observer to be removed.
*/
public void removeObserver(FadingViewObserver observer) {
mObservers.removeObserver(observer);
}
@Override @Override
public void onClick(View view) { public void onClick(View view) {
for (FadingViewObserver o : mObservers) o.onFadingViewClick(); for (FadingViewObserver o : mObservers) o.onFadingViewClick();
......
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