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 ...@@ -123,8 +123,7 @@ public class ChromeTabModalPresenter
MarginLayoutParams params = (MarginLayoutParams) dialogContainer.getLayoutParams(); MarginLayoutParams params = (MarginLayoutParams) dialogContainer.getLayoutParams();
params.width = ViewGroup.MarginLayoutParams.MATCH_PARENT; params.width = ViewGroup.MarginLayoutParams.MATCH_PARENT;
params.height = ViewGroup.MarginLayoutParams.MATCH_PARENT; params.height = ViewGroup.MarginLayoutParams.MATCH_PARENT;
params.topMargin = getContainerTopMargin( params.topMargin = getContainerTopMargin(resources, mChromeActivity.getFullscreenManager());
resources, mChromeActivity.getControlContainerHeightResource());
params.bottomMargin = getContainerBottomMargin(mChromeActivity.getFullscreenManager()); params.bottomMargin = getContainerBottomMargin(mChromeActivity.getFullscreenManager());
dialogContainer.setLayoutParams(params); dialogContainer.setLayoutParams(params);
...@@ -144,6 +143,8 @@ public class ChromeTabModalPresenter ...@@ -144,6 +143,8 @@ public class ChromeTabModalPresenter
protected void showDialogContainer() { protected void showDialogContainer() {
if (mShouldUpdateContainerLayoutParams) { if (mShouldUpdateContainerLayoutParams) {
MarginLayoutParams params = (MarginLayoutParams) getDialogContainer().getLayoutParams(); MarginLayoutParams params = (MarginLayoutParams) getDialogContainer().getLayoutParams();
params.topMargin =
getContainerTopMargin(mChromeActivity.getResources(), mChromeFullscreenManager);
params.bottomMargin = mBottomControlsHeight; params.bottomMargin = mBottomControlsHeight;
getDialogContainer().setLayoutParams(params); getDialogContainer().setLayoutParams(params);
mShouldUpdateContainerLayoutParams = false; mShouldUpdateContainerLayoutParams = false;
...@@ -234,6 +235,11 @@ public class ChromeTabModalPresenter ...@@ -234,6 +235,11 @@ public class ChromeTabModalPresenter
mShouldUpdateContainerLayoutParams = true; mShouldUpdateContainerLayoutParams = true;
} }
@Override
public void onTopControlsHeightChanged(int topControlsHeight, int topControlsMinHeight) {
mShouldUpdateContainerLayoutParams = true;
}
@Override @Override
public void updateContainerHierarchy(boolean toFront) { public void updateContainerHierarchy(boolean toFront) {
super.updateContainerHierarchy(toFront); super.updateContainerHierarchy(toFront);
...@@ -248,19 +254,24 @@ public class ChromeTabModalPresenter ...@@ -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. * Calculate the top margin of the dialog container and the dialog scrim so that the scrim
public static int getContainerTopMargin(Resources resources, int containerHeightResource) { * 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 = int scrimVerticalMargin =
resources.getDimensionPixelSize(R.dimen.tab_modal_scrim_vertical_margin); resources.getDimensionPixelSize(R.dimen.tab_modal_scrim_vertical_margin);
int containerVerticalMargin = -scrimVerticalMargin; return manager.getTopControlsHeight() - scrimVerticalMargin;
if (containerHeightResource != ChromeActivity.NO_CONTROL_CONTAINER) {
containerVerticalMargin += resources.getDimensionPixelSize(containerHeightResource);
}
return containerVerticalMargin;
} }
// 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) { public static int getContainerBottomMargin(ChromeFullscreenManager manager) {
return manager.getBottomControlsHeight(); return manager.getBottomControlsHeight();
} }
......
...@@ -97,8 +97,7 @@ class PasswordManagerDialogMediator implements View.OnLayoutChangeListener { ...@@ -97,8 +97,7 @@ class PasswordManagerDialogMediator implements View.OnLayoutChangeListener {
private boolean hasSufficientSpaceForIllustration(int heightPx) { private boolean hasSufficientSpaceForIllustration(int heightPx) {
// If |mResources| is null, it means that the dialog was not initialized yet. // If |mResources| is null, it means that the dialog was not initialized yet.
if (mResources == null) return false; if (mResources == null) return false;
heightPx -= heightPx -= ChromeTabModalPresenter.getContainerTopMargin(mResources, mFullscreenManager);
ChromeTabModalPresenter.getContainerTopMargin(mResources, mContainerHeightResource);
heightPx -= ChromeTabModalPresenter.getContainerBottomMargin(mFullscreenManager); heightPx -= ChromeTabModalPresenter.getContainerBottomMargin(mFullscreenManager);
return heightPx >= mResources.getDimensionPixelSize( return heightPx >= mResources.getDimensionPixelSize(
R.dimen.password_manager_dialog_min_vertical_space_to_show_illustration); R.dimen.password_manager_dialog_min_vertical_space_to_show_illustration);
......
...@@ -100,8 +100,7 @@ class PasswordManagerDialogPasswordChangeMediator implements View.OnLayoutChange ...@@ -100,8 +100,7 @@ class PasswordManagerDialogPasswordChangeMediator implements View.OnLayoutChange
private boolean hasSufficientSpaceForIllustration(int heightPx) { private boolean hasSufficientSpaceForIllustration(int heightPx) {
// If |mResources| is null, it means that the dialog was not initialized yet. // If |mResources| is null, it means that the dialog was not initialized yet.
if (mResources == null) return false; if (mResources == null) return false;
heightPx -= heightPx -= ChromeTabModalPresenter.getContainerTopMargin(mResources, mFullscreenManager);
ChromeTabModalPresenter.getContainerTopMargin(mResources, mContainerHeightResource);
heightPx -= ChromeTabModalPresenter.getContainerBottomMargin(mFullscreenManager); heightPx -= ChromeTabModalPresenter.getContainerBottomMargin(mFullscreenManager);
return heightPx >= mResources.getDimensionPixelSize( return heightPx >= mResources.getDimensionPixelSize(
R.dimen.password_manager_dialog_min_vertical_space_to_show_illustration); 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