Commit bb869dc4 authored by Sinan Sahin's avatar Sinan Sahin Committed by Commit Bot

[Offline indicator v2] Fix for TabModalPresenter

Bug: 1049314
Change-Id: Ib5f8deb4e2b3aa32c6c99f6488c5f01b9d44bbc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2128938Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Sinan Sahin <sinansahin@google.com>
Cr-Commit-Position: refs/heads/master@{#755181}
parent 02f8975c
......@@ -123,8 +123,7 @@ public class ChromeTabModalPresenter
MarginLayoutParams params = (MarginLayoutParams) dialogContainer.getLayoutParams();
params.width = ViewGroup.MarginLayoutParams.MATCH_PARENT;
params.height = ViewGroup.MarginLayoutParams.MATCH_PARENT;
params.topMargin = getContainerTopMargin(
resources, mChromeActivity.getControlContainerHeightResource());
params.topMargin = getContainerTopMargin(resources, mChromeActivity.getFullscreenManager());
params.bottomMargin = getContainerBottomMargin(mChromeActivity.getFullscreenManager());
dialogContainer.setLayoutParams(params);
......@@ -144,6 +143,8 @@ public class ChromeTabModalPresenter
protected void showDialogContainer() {
if (mShouldUpdateContainerLayoutParams) {
MarginLayoutParams params = (MarginLayoutParams) getDialogContainer().getLayoutParams();
params.topMargin =
getContainerTopMargin(mChromeActivity.getResources(), mChromeFullscreenManager);
params.bottomMargin = mBottomControlsHeight;
getDialogContainer().setLayoutParams(params);
mShouldUpdateContainerLayoutParams = false;
......@@ -234,6 +235,11 @@ public class ChromeTabModalPresenter
mShouldUpdateContainerLayoutParams = true;
}
@Override
public void onTopControlsHeightChanged(int topControlsHeight, int topControlsMinHeight) {
mShouldUpdateContainerLayoutParams = true;
}
@Override
public void updateContainerHierarchy(boolean toFront) {
super.updateContainerHierarchy(toFront);
......@@ -248,19 +254,24 @@ public class ChromeTabModalPresenter
}
}
// Calculate the top margin of the dialog container and the dialog scrim
// so that the scrim doesn't overlap the toolbar.
public static int getContainerTopMargin(Resources resources, int containerHeightResource) {
/**
* Calculate the top margin of the dialog container and the dialog scrim so that the scrim
* doesn't overlap the toolbar.
* @param resources {@link Resources} to use to get the scrim vertical margin.
* @param manager {@link ChromeFullscreenManager} for browser controls heights.
* @return The container top margin.
*/
public static int getContainerTopMargin(Resources resources, ChromeFullscreenManager manager) {
int scrimVerticalMargin =
resources.getDimensionPixelSize(R.dimen.tab_modal_scrim_vertical_margin);
int containerVerticalMargin = -scrimVerticalMargin;
if (containerHeightResource != ChromeActivity.NO_CONTROL_CONTAINER) {
containerVerticalMargin += resources.getDimensionPixelSize(containerHeightResource);
}
return containerVerticalMargin;
return manager.getTopControlsHeight() - scrimVerticalMargin;
}
// Calculate the bottom margin of the dialog container.
/**
* Calculate the bottom margin of the dialog container.
* @param manager {@link ChromeFullscreenManager} for browser controls heights.
* @return The container bottom margin.
*/
public static int getContainerBottomMargin(ChromeFullscreenManager manager) {
return manager.getBottomControlsHeight();
}
......
......@@ -97,8 +97,7 @@ class PasswordManagerDialogMediator implements View.OnLayoutChangeListener {
private boolean hasSufficientSpaceForIllustration(int heightPx) {
// If |mResources| is null, it means that the dialog was not initialized yet.
if (mResources == null) return false;
heightPx -=
ChromeTabModalPresenter.getContainerTopMargin(mResources, mContainerHeightResource);
heightPx -= ChromeTabModalPresenter.getContainerTopMargin(mResources, mFullscreenManager);
heightPx -= ChromeTabModalPresenter.getContainerBottomMargin(mFullscreenManager);
return heightPx >= mResources.getDimensionPixelSize(
R.dimen.password_manager_dialog_min_vertical_space_to_show_illustration);
......
......@@ -100,8 +100,7 @@ class PasswordManagerDialogPasswordChangeMediator implements View.OnLayoutChange
private boolean hasSufficientSpaceForIllustration(int heightPx) {
// If |mResources| is null, it means that the dialog was not initialized yet.
if (mResources == null) return false;
heightPx -=
ChromeTabModalPresenter.getContainerTopMargin(mResources, mContainerHeightResource);
heightPx -= ChromeTabModalPresenter.getContainerTopMargin(mResources, mFullscreenManager);
heightPx -= ChromeTabModalPresenter.getContainerBottomMargin(mFullscreenManager);
return heightPx >= mResources.getDimensionPixelSize(
R.dimen.password_manager_dialog_min_vertical_space_to_show_illustration);
......
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