Commit c20e491e authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Consolidate BottomSheet setters and clean up a bit

This change removes two setters for the fullscreen manager and the
tab model selector as they can be accessed in init from
ChromeActivity. The height ratios of the sheet are now also referenced
by their respective state.

BUG=814528

Change-Id: I5a58a2ff367c7ad567d6b88b7bb8a3920632a57c
Reviewed-on: https://chromium-review.googlesource.com/956342Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541912}
parent 95f838f6
......@@ -1262,8 +1262,6 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
getLayoutInflater().inflate(R.layout.bottom_sheet, coordinator);
mBottomSheet = coordinator.findViewById(R.id.bottom_sheet);
mBottomSheet.init(coordinator, this);
mBottomSheet.setTabModelSelector(mTabModelSelector);
mBottomSheet.setFullscreenManager(mFullscreenManager);
mFadingBackgroundView = (FadingBackgroundView) findViewById(R.id.fading_focus_target);
mBottomSheet.addObserver(new EmptyBottomSheetObserver() {
......
......@@ -166,7 +166,7 @@ public class PermissionDialogController
// whereby the tab is obscured so modals don't pop up on top of (e.g.) the tab switcher or
// the three-dot menu.
final BottomSheet bottomSheet = activity.getBottomSheet();
if (bottomSheet == null || !bottomSheet.isVisible()) {
if (bottomSheet == null || !bottomSheet.isSheetOpen()) {
showDialog();
} else {
bottomSheet.addObserver(new EmptyBottomSheetObserver() {
......
......@@ -638,13 +638,6 @@ public class BottomSheet
return true;
}
/**
* @param tabModelSelector A TabModelSelector for getting the current tab and activity.
*/
public void setTabModelSelector(TabModelSelector tabModelSelector) {
mTabModelSelector = tabModelSelector;
}
/**
* @param layoutManager The {@link LayoutManagerChrome} used to show and hide overview mode.
*/
......@@ -652,14 +645,6 @@ public class BottomSheet
getIphBubbleController().setLayoutManagerChrome(layoutManager);
}
/**
* @param fullscreenManager Chrome's fullscreen manager for information about toolbar offsets.
*/
public void setFullscreenManager(ChromeFullscreenManager fullscreenManager) {
mFullscreenManager = fullscreenManager;
getIphBubbleController().setFullscreenManager(fullscreenManager);
}
/**
* @return Whether or not the toolbar Android View is hidden due to being scrolled off-screen.
*/
......@@ -685,6 +670,10 @@ public class BottomSheet
* @param activity The activity displaying the bottom sheet.
*/
public void init(View root, ChromeActivity activity) {
mTabModelSelector = activity.getTabModelSelector();
mFullscreenManager = activity.getFullscreenManager();
getIphBubbleController().setFullscreenManager(mFullscreenManager);
mToolbarHolder =
(TouchRestrictingFrameLayout) findViewById(R.id.bottom_sheet_toolbar_container);
mDefaultToolbarView = mToolbarHolder.findViewById(R.id.bottom_sheet_toolbar);
......@@ -803,7 +792,7 @@ public class BottomSheet
}
});
mActivity.getFullscreenManager().addListener(new FullscreenListener() {
mFullscreenManager.addListener(new FullscreenListener() {
@Override
public void onToggleOverlayVideoMode(boolean enabled) {
if (isSheetOpen()) setSheetState(SHEET_STATE_PEEK, false);
......@@ -1165,10 +1154,11 @@ public class BottomSheet
// the correct toolbar height and container height are not know until those views are
// inflated. The other views are a specific DP distance from the top and bottom and are
// also updated.
mStateRatios[0] = (mToolbarHeight + mToolbarShadowHeight) / mContainerHeight;
mStateRatios[1] = HALF_HEIGHT_RATIO;
mStateRatios[SHEET_STATE_PEEK] = (mToolbarHeight + mToolbarShadowHeight) / mContainerHeight;
mStateRatios[SHEET_STATE_HALF] = HALF_HEIGHT_RATIO;
// The max height ratio will be greater than 1 to account for the toolbar shadow.
mStateRatios[2] = (mContainerHeight + mToolbarShadowHeight) / mContainerHeight;
mStateRatios[SHEET_STATE_FULL] =
(mContainerHeight + mToolbarShadowHeight) / mContainerHeight;
if (mCurrentState == SHEET_STATE_HALF && isSmallScreen()) {
setSheetState(SHEET_STATE_FULL, false);
......@@ -1277,7 +1267,7 @@ public class BottomSheet
*/
@VisibleForTesting
public float getPeekRatio() {
return mStateRatios[0];
return mStateRatios[SHEET_STATE_PEEK];
}
/**
......@@ -1285,7 +1275,7 @@ public class BottomSheet
*/
@VisibleForTesting
public float getHalfRatio() {
return mStateRatios[1];
return mStateRatios[SHEET_STATE_HALF];
}
/**
......@@ -1293,7 +1283,7 @@ public class BottomSheet
*/
@VisibleForTesting
public float getFullRatio() {
return mStateRatios[2];
return mStateRatios[SHEET_STATE_FULL];
}
/**
......
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