Commit 4a418539 authored by Sinan Sahin's avatar Sinan Sahin Committed by Commit Bot

[Offline indicator v2] Fix for the NTP

This CL modifies the NTP to work with the status indicator.

When the top controls height changes, the layout's margin will be
updated without any animation.

Bug: 1059438
Change-Id: I06285cda66681fd5af2ecd5abcb972965aa6e9f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108182
Commit-Queue: Sinan Sahin <sinansahin@google.com>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751820}
parent eab1fda3
...@@ -120,6 +120,8 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide ...@@ -120,6 +120,8 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
// Whether destroy() has been called. // Whether destroy() has been called.
private boolean mIsDestroyed; private boolean mIsDestroyed;
private final int mTabStripAndToolbarHeight;
@Override @Override
public void onContentOffsetChanged(int offset) {} public void onContentOffsetChanged(int offset) {}
...@@ -135,6 +137,11 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide ...@@ -135,6 +137,11 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
updateMargins(); updateMargins();
} }
@Override
public void onTopControlsHeightChanged(int topControlsHeight, int topControlsMinHeight) {
updateMargins();
}
/** /**
* Allows clients to listen for updates to the scroll changes of the search box on the * Allows clients to listen for updates to the scroll changes of the search box on the
* NTP. * NTP.
...@@ -349,6 +356,9 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide ...@@ -349,6 +356,9 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
DownloadManagerService.getDownloadManagerService().checkForExternallyRemovedDownloads( DownloadManagerService.getDownloadManagerService().checkForExternallyRemovedDownloads(
/*isOffTheRecord=*/false); /*isOffTheRecord=*/false);
mTabStripAndToolbarHeight =
activity.getResources().getDimensionPixelSize(R.dimen.tab_strip_and_toolbar_height);
NewTabPageUma.recordIsUserOnline(); NewTabPageUma.recordIsUserOnline();
NewTabPageUma.recordLoadType(activity); NewTabPageUma.recordLoadType(activity);
NewTabPageUma.recordContentSuggestionsDisplayStatus(); NewTabPageUma.recordContentSuggestionsDisplayStatus();
...@@ -422,6 +432,7 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide ...@@ -422,6 +432,7 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
layoutParams.bottomMargin = mFullscreenManager.getBottomControlsHeight() layoutParams.bottomMargin = mFullscreenManager.getBottomControlsHeight()
- mFullscreenManager.getBottomControlOffset(); - mFullscreenManager.getBottomControlOffset();
layoutParams.topMargin = getToolbarExtraYOffset();
view.setLayoutParams(layoutParams); view.setLayoutParams(layoutParams);
...@@ -433,6 +444,16 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide ...@@ -433,6 +444,16 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
R.dimen.duet_ntp_logo_top_margin)); R.dimen.duet_ntp_logo_top_margin));
} }
// TODO(sinansahin): This is the same as {@link ToolbarManager#getToolbarExtraYOffset}. So, we
// should look into sharing the logic.
/**
* @return The height that is included in the top controls but not in the toolbar or the tab
* strip.
*/
private int getToolbarExtraYOffset() {
return mFullscreenManager.getTopControlsHeight() - mTabStripAndToolbarHeight;
}
/** @return The view container for the new tab page. */ /** @return The view container for the new tab page. */
@VisibleForTesting @VisibleForTesting
public NewTabPageView getNewTabPageView() { public NewTabPageView getNewTabPageView() {
......
...@@ -209,7 +209,7 @@ public class TabbedRootUiCoordinator extends RootUiCoordinator implements Native ...@@ -209,7 +209,7 @@ public class TabbedRootUiCoordinator extends RootUiCoordinator implements Native
final ChromeFullscreenManager fullscreenManager = mActivity.getFullscreenManager(); final ChromeFullscreenManager fullscreenManager = mActivity.getFullscreenManager();
Supplier<Boolean> canAnimateBrowserControls = () -> { Supplier<Boolean> canAnimateBrowserControls = () -> {
final Tab tab = mActivity.getActivityTabProvider().get(); final Tab tab = mActivity.getActivityTabProvider().get();
return tab != null && tab.isUserInteractable(); return tab != null && tab.isUserInteractable() && !tab.isNativePage();
}; };
mToolbarManager.setCanAnimateNativeBrowserControlsSupplier(canAnimateBrowserControls); mToolbarManager.setCanAnimateNativeBrowserControlsSupplier(canAnimateBrowserControls);
mStatusIndicatorCoordinator = new StatusIndicatorCoordinator(mActivity, mStatusIndicatorCoordinator = new StatusIndicatorCoordinator(mActivity,
......
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