Commit 5172f290 authored by Theresa Wellington's avatar Theresa Wellington Committed by Commit Bot

[Home] Use transparent toolbar bg when shown in NTP

When the toolbar is translated for the search provider logo on the NTP,
the background needs to be transparent to prevent it from covering part
of the RecyclerView's scroll bar.

BUG=791766

Change-Id: I9651c16dccc153d1bdad15925a51fae9acbeb591
Reviewed-on: https://chromium-review.googlesource.com/823575Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarNicolas Dossou-Gbété <dgn@chromium.org>
Commit-Queue: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523797}
parent 86ab327f
......@@ -37,6 +37,7 @@ import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl
import org.chromium.chrome.browser.snackbar.SnackbarManager;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.toolbar.BottomToolbarPhone;
import org.chromium.chrome.browser.util.ViewUtils;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.StateChangeReason;
......@@ -70,6 +71,7 @@ public class SuggestionsBottomSheetContent implements BottomSheet.BottomSheetCon
private final LogoView mLogoView;
private final LogoDelegateImpl mLogoDelegate;
private final LocationBarPhone mLocationBar;
private final BottomToolbarPhone mToolbarView;
private final ViewGroup mControlContainerView;
private final View mToolbarPullHandle;
private final View mToolbarShadow;
......@@ -231,6 +233,7 @@ public class SuggestionsBottomSheetContent implements BottomSheet.BottomSheetCon
mRecyclerView.setOnTouchListener(touchListener);
mControlContainerView = (ViewGroup) activity.findViewById(R.id.control_container);
mToolbarView = (BottomToolbarPhone) activity.findViewById(R.id.toolbar);
mToolbarPullHandle = activity.findViewById(R.id.toolbar_handle);
mToolbarShadow = activity.findViewById(R.id.bottom_toolbar_shadow);
mLogoDelegate = new LogoDelegateImpl(navigationDelegate, mLogoView, profile);
......@@ -407,6 +410,7 @@ public class SuggestionsBottomSheetContent implements BottomSheet.BottomSheetCon
mControlContainerView.setTranslationY(0);
mToolbarPullHandle.setTranslationY(0);
mToolbarShadow.setTranslationY(0);
mToolbarView.setShownInNtp(false);
ViewUtils.setAncestorsShouldClipChildren(mControlContainerView, true);
mRecyclerView.setAlpha(1.0f);
mRecyclerView.setVisibility(View.VISIBLE);
......@@ -447,6 +451,12 @@ public class SuggestionsBottomSheetContent implements BottomSheet.BottomSheetCon
mToolbarPullHandle.setTranslationY(-toolbarOffset);
mToolbarShadow.setTranslationY(-toolbarOffset);
if (toolbarOffset == 0.0f || toolbarOffset == sheetHeightPx) {
mToolbarView.setShownInNtp(false);
} else {
mToolbarView.setShownInNtp(true);
}
// Fade out the whole RecyclerView when the URL bar is focused, and fade it in when it loses
// focus.
final float alpha;
......
......@@ -216,6 +216,9 @@ public class BottomToolbarPhone extends ToolbarPhone {
/** A handle to the {@link ChromeActivity} this toolbar exists in. */
private ChromeActivity mActivity;
/** Whether the toolbar is currently being shown in the NTP. */
private boolean mShownInNtp;
/**
* Constructs a BottomToolbarPhone object.
* @param context The Context in which this View object is created.
......@@ -912,6 +915,16 @@ public class BottomToolbarPhone extends ToolbarPhone {
ApiCompatibilityUtils.getPaddingEnd(otherToolbar), otherToolbar.getPaddingBottom());
}
/**
* @param shownInNtp Whether the toolbar is currently being shown in the NTP.
*/
public void setShownInNtp(boolean shownInNtp) {
if (shownInNtp == mShownInNtp) return;
mShownInNtp = shownInNtp;
updateToolbarBackground(mVisualState);
}
@Override
protected void onAccessibilityStatusChanged(boolean enabled) {
setUseExpandButton();
......@@ -1046,6 +1059,13 @@ public class BottomToolbarPhone extends ToolbarPhone {
return ApiCompatibilityUtils.getColor(getResources(),
DeviceClassManager.enableAccessibilityLayout() ? R.color.incognito_primary_color
: R.color.modern_primary_color);
} else if (visualState == VisualState.NORMAL && mShownInNtp) {
// TODO(twellington): Ideally the VisualState would be set to NEW_TAB_NORMAL and that
// would be used to set the toolbar background. The VisualState is used for some toolbar
// animations that we don't run on BottomToolbarPhone. Those animations need to be
// reworked before the VisualState can be set to NEW_TAB_NORMAL when the Chrome Home NTP
// is showing.
return Color.TRANSPARENT;
} else if (visualState == VisualState.NORMAL
|| visualState == VisualState.TAB_SWITCHER_NORMAL) {
return ApiCompatibilityUtils.getColor(getResources(), R.color.modern_primary_color);
......
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