Commit daded82b authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Toolbar: Do not use ChromeActivity in ActionBar

ToolbarManager injects the necessary objects through ViewShifting-
ActionBarDelegate to remove the dependendency on ChromeActivity
in the class.

Bug: 1127732
Change-Id: Ief8e4a5f12d2488389e02c4fbe5af0e353f3d8de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2430566Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819212}
parent 83e87751
......@@ -254,7 +254,8 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
mActivity = activity;
mBrowserControlsSizer = controlsSizer;
mFullscreenManager = fullscreenManager;
mActionBarDelegate = new ViewShiftingActionBarDelegate(activity, controlContainer);
mActionBarDelegate = new ViewShiftingActionBarDelegate(activity.getSupportActionBar(),
controlContainer, activity.findViewById(R.id.action_bar_black_background));
mShareDelegateSupplier = shareDelegateSupplier;
mCanAnimateNativeBrowserControls = canAnimateNativeBrowserControls;
mScrimCoordinator = scrimCoordinator;
......
......@@ -9,26 +9,29 @@ import android.view.ViewGroup;
import androidx.appcompat.app.ActionBar;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.app.ChromeActivity;
/**
* An {@link ActionModeController.ActionBarDelegate} that shifts a view as the action bar appears.
*/
public class ViewShiftingActionBarDelegate implements ActionModeController.ActionBarDelegate {
/** The action bar which this delegate works for. */
private final ActionBar mActionBar;
/** The view that will be shifted as the action bar appears. */
private final View mShiftingView;
/** A handle to a {@link ChromeActivity}. */
private final ChromeActivity mActivity;
/** Action bar background view. */
private final View mBackgroundView;
/**
* @param activity A handle to the {@link ChromeActivity}.
* @param actionBar The {@link ActionBar} in use.
* @param shiftingView The view that will shift when the action bar appears.
* @param backgroundView Background view for shadow effect.
*/
public ViewShiftingActionBarDelegate(ChromeActivity activity, View shiftingView) {
mActivity = activity;
public ViewShiftingActionBarDelegate(
ActionBar actionBar, View shiftingView, View backgroundView) {
mActionBar = actionBar;
mShiftingView = shiftingView;
mBackgroundView = backgroundView;
}
@Override
......@@ -48,13 +51,13 @@ public class ViewShiftingActionBarDelegate implements ActionModeController.Actio
@Override
public ActionBar getSupportActionBar() {
return mActivity.getSupportActionBar();
return mActionBar;
}
@Override
public void setActionBarBackgroundVisibility(boolean visible) {
int visibility = visible ? View.VISIBLE : View.GONE;
mActivity.findViewById(R.id.action_bar_black_background).setVisibility(visibility);
mBackgroundView.setVisibility(visibility);
// TODO(tedchoc): Add support for changing the color based on the brand color.
}
}
\ No newline at end of file
}
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