Commit 37708771 authored by Matt Jones's avatar Matt Jones Committed by Commit Bot

Add BottomSheetControllerFactory, hide impl from everything else

Bug: 1002277
Change-Id: I70219c5eef14630f8fd1584d2af085c4a9c3ae21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2236503
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776746}
parent 572d4fd2
...@@ -1769,6 +1769,7 @@ chrome_java_sources = [ ...@@ -1769,6 +1769,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/widget/ScrimView.java", "java/src/org/chromium/chrome/browser/widget/ScrimView.java",
"java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java", "java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java",
"java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetController.java", "java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetController.java",
"java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetControllerFactory.java",
"java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetControllerImpl.java", "java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetControllerImpl.java",
"java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetControllerInternal.java", "java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetControllerInternal.java",
"java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetObserver.java", "java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetObserver.java",
......
...@@ -23,7 +23,7 @@ import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager; ...@@ -23,7 +23,7 @@ import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.chrome.browser.vr.VrModuleProvider; import org.chromium.chrome.browser.vr.VrModuleProvider;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController.StateChangeReason; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController.StateChangeReason;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetControllerImpl; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetControllerInternal;
import org.chromium.chrome.browser.widget.bottomsheet.EmptyBottomSheetObserver; import org.chromium.chrome.browser.widget.bottomsheet.EmptyBottomSheetObserver;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetContent; import org.chromium.components.browser_ui.bottomsheet.BottomSheetContent;
import org.chromium.content_public.browser.SelectionPopupController; import org.chromium.content_public.browser.SelectionPopupController;
...@@ -70,8 +70,10 @@ class BottomSheetManager extends EmptyBottomSheetObserver implements Destroyable ...@@ -70,8 +70,10 @@ class BottomSheetManager extends EmptyBottomSheetObserver implements Destroyable
/** A token for suppressing tab modal dialogs. */ /** A token for suppressing tab modal dialogs. */
private int mTabModalToken = TokenHolder.INVALID_TOKEN; private int mTabModalToken = TokenHolder.INVALID_TOKEN;
/** A handle to the {@link BottomSheetControllerImpl} this class manages interactions with. */ /**
private BottomSheetControllerImpl mSheetController; * A handle to the {@link BottomSheetControllerInternal} this class manages interactions with.
*/
private BottomSheetControllerInternal mSheetController;
/** A mechanism for accessing the currently active tab. */ /** A mechanism for accessing the currently active tab. */
private ActivityTabProvider mTabProvider; private ActivityTabProvider mTabProvider;
...@@ -104,8 +106,9 @@ class BottomSheetManager extends EmptyBottomSheetObserver implements Destroyable ...@@ -104,8 +106,9 @@ class BottomSheetManager extends EmptyBottomSheetObserver implements Destroyable
/** The token used to enable browser controls persistence. */ /** The token used to enable browser controls persistence. */
private int mPersistentControlsToken; private int mPersistentControlsToken;
public BottomSheetManager(BottomSheetControllerImpl controller, ActivityTabProvider tabProvider, public BottomSheetManager(BottomSheetControllerInternal controller,
ChromeFullscreenManager fullscreenManager, Supplier<ModalDialogManager> dialogManager, ActivityTabProvider tabProvider, ChromeFullscreenManager fullscreenManager,
Supplier<ModalDialogManager> dialogManager,
Supplier<SnackbarManager> snackbarManagerSupplier, Supplier<SnackbarManager> snackbarManagerSupplier,
TabObscuringHandler obscuringDelegate, TabObscuringHandler obscuringDelegate,
ObservableSupplier<Boolean> omniboxFocusStateSupplier, ObservableSupplier<Boolean> omniboxFocusStateSupplier,
......
...@@ -65,7 +65,7 @@ import org.chromium.chrome.browser.vr.VrModuleProvider; ...@@ -65,7 +65,7 @@ import org.chromium.chrome.browser.vr.VrModuleProvider;
import org.chromium.chrome.browser.widget.ScrimView; import org.chromium.chrome.browser.widget.ScrimView;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController.SheetState; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController.SheetState;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetControllerImpl; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetControllerFactory;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetControllerInternal; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetControllerInternal;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetObserver; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetObserver;
import org.chromium.chrome.browser.widget.bottomsheet.EmptyBottomSheetObserver; import org.chromium.chrome.browser.widget.bottomsheet.EmptyBottomSheetObserver;
...@@ -126,7 +126,7 @@ public class RootUiCoordinator ...@@ -126,7 +126,7 @@ public class RootUiCoordinator
private VrModeObserver mVrModeObserver; private VrModeObserver mVrModeObserver;
private BottomSheetManager mBottomSheetManager; private BottomSheetManager mBottomSheetManager;
private BottomSheetControllerImpl mBottomSheetController; private BottomSheetControllerInternal mBottomSheetController;
private SnackbarManager mBottomSheetSnackbarManager; private SnackbarManager mBottomSheetSnackbarManager;
private ScrimView mScrimView; private ScrimView mScrimView;
...@@ -638,9 +638,8 @@ public class RootUiCoordinator ...@@ -638,9 +638,8 @@ public class RootUiCoordinator
Supplier<OverlayPanelManager> panelManagerSupplier = () Supplier<OverlayPanelManager> panelManagerSupplier = ()
-> mActivity.getCompositorViewHolder().getLayoutManager().getOverlayPanelManager(); -> mActivity.getCompositorViewHolder().getLayoutManager().getOverlayPanelManager();
mBottomSheetController = new BottomSheetControllerImpl(() mBottomSheetController = BottomSheetControllerFactory.createBottomSheetController(
-> mScrimCoordinator, () -> mScrimCoordinator, sheetViewSupplier, mActivity.getWindow(),
sheetViewSupplier, mActivity.getWindow(),
mActivity.getWindowAndroid().getKeyboardDelegate()); mActivity.getWindowAndroid().getKeyboardDelegate());
mBottomSheetManager = new BottomSheetManager(mBottomSheetController, mActivityTabProvider, mBottomSheetManager = new BottomSheetManager(mBottomSheetController, mActivityTabProvider,
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.widget.bottomsheet;
import android.view.View;
import android.view.Window;
import org.chromium.base.supplier.Supplier;
import org.chromium.components.browser_ui.widget.scrim.ScrimCoordinator;
import org.chromium.ui.KeyboardVisibilityDelegate;
/** A factory for producing a {@link BottomSheetController}. */
public class BottomSheetControllerFactory {
/**
* @param scrim A supplier of scrim to be shown behind the sheet.
* @param bottomSheetViewSupplier A means of creating the sheet's view.
* @param window The activity's window.
* @param keyboardDelegate A means of hiding the keyboard.
* @return A new instance of the {@link BottomSheetController}.
*/
public static BottomSheetControllerInternal createBottomSheetController(
final Supplier<ScrimCoordinator> scrim, Supplier<View> bottomSheetViewSupplier,
Window window, KeyboardVisibilityDelegate keyboardDelegate) {
return new BottomSheetControllerImpl(
scrim, bottomSheetViewSupplier, window, keyboardDelegate);
}
}
...@@ -28,7 +28,7 @@ import java.util.PriorityQueue; ...@@ -28,7 +28,7 @@ import java.util.PriorityQueue;
* and call {@link #requestShowContent(BottomSheetContent, boolean)} which will return true if the * and call {@link #requestShowContent(BottomSheetContent, boolean)} which will return true if the
* content was actually shown (see full doc on method). * content was actually shown (see full doc on method).
*/ */
public class BottomSheetControllerImpl implements BottomSheetControllerInternal { class BottomSheetControllerImpl implements BottomSheetControllerInternal {
/** The initial capacity for the priority queue handling pending content show requests. */ /** The initial capacity for the priority queue handling pending content show requests. */
private static final int INITIAL_QUEUE_CAPACITY = 1; private static final int INITIAL_QUEUE_CAPACITY = 1;
...@@ -192,7 +192,7 @@ public class BottomSheetControllerImpl implements BottomSheetControllerInternal ...@@ -192,7 +192,7 @@ public class BottomSheetControllerImpl implements BottomSheetControllerInternal
mSheetInitializer = null; mSheetInitializer = null;
} }
/** @param ratio The hidden ratio of the browser controls. */ @Override
public void setBrowserControlsHiddenRatio(float ratio) { public void setBrowserControlsHiddenRatio(float ratio) {
if (mBottomSheet != null) mBottomSheet.setBrowserControlsHiddenRatio(ratio); if (mBottomSheet != null) mBottomSheet.setBrowserControlsHiddenRatio(ratio);
} }
......
...@@ -38,6 +38,12 @@ public interface BottomSheetControllerInternal extends BottomSheetController { ...@@ -38,6 +38,12 @@ public interface BottomSheetControllerInternal extends BottomSheetController {
*/ */
boolean handleBackPress(); boolean handleBackPress();
/**
* Set the hidden ratio of the browser controls.
* @param ratio The hidden ratio of the browser controls in range [0, 1].
*/
void setBrowserControlsHiddenRatio(float ratio);
/** Clean up any state maintained by the controller. */ /** Clean up any state maintained by the controller. */
void destroy(); void destroy();
} }
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