Commit add1a372 authored by Yue Zhang's avatar Yue Zhang Committed by Commit Bot

Remove TabGridPanelToolbarCoordinator

Since TabGridPanelToolbarCoordinator only handles layout inflation and
PropertyModel creation, this CL removes this class and moves related
logic back to TabGridDialogCoordinator.

Bug: 1067080
Change-Id: I188d3de5a8d1baf064ddd22f857a110b815ba4e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2133077Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Yue Zhang <yuezhanggg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755842}
parent ce4341b3
......@@ -117,7 +117,6 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGridIphDialogViewBinder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGridItemTouchHelperCallback.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGridPanelProperties.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGridPanelToolbarCoordinator.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGridPanelViewBinder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGridViewBinder.java",
"java/src/org/chromium/chrome/browser/tasks/tab_management/TabGroupPopupUiCoordinator.java",
......
......@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.tasks.tab_management;
import android.content.Context;
import android.graphics.Rect;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
......@@ -19,7 +20,9 @@ import org.chromium.chrome.browser.share.ShareDelegate;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabCreatorManager;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.tab_ui.R;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
import java.util.List;
......@@ -32,8 +35,8 @@ public class TabGridDialogCoordinator implements TabGridDialogMediator.DialogCon
private final String mComponentName;
private final TabListCoordinator mTabListCoordinator;
private final TabGridDialogMediator mMediator;
private final PropertyModel mToolbarPropertyModel;
private final TabGridPanelToolbarCoordinator mToolbarCoordinator;
private final PropertyModel mModel;
private final PropertyModelChangeProcessor mModelChangeProcessor;
private final TabGridDialogParent mParentLayout;
private TabSelectionEditorCoordinator mTabSelectionEditorCoordinator;
......@@ -49,14 +52,14 @@ public class TabGridDialogCoordinator implements TabGridDialogMediator.DialogCon
mComponentName = animationSourceViewProvider == null ? "TabGridDialogFromStrip"
: "TabGridDialogInSwitcher";
mToolbarPropertyModel = new PropertyModel(TabGridPanelProperties.ALL_KEYS);
mModel = new PropertyModel(TabGridPanelProperties.ALL_KEYS);
mContainerView = containerView;
mParentLayout = new TabGridDialogParent(context, containerView);
mMediator = new TabGridDialogMediator(context, this, mToolbarPropertyModel,
tabModelSelector, tabCreatorManager, resetHandler, animationSourceViewProvider,
shareDelegateSupplier, mComponentName);
mMediator = new TabGridDialogMediator(context, this, mModel, tabModelSelector,
tabCreatorManager, resetHandler, animationSourceViewProvider, shareDelegateSupplier,
mComponentName);
// TODO(crbug.com/1031349) : Remove the inline mode logic here, make the constructor to take
// in a mode parameter instead.
......@@ -69,8 +72,17 @@ public class TabGridDialogCoordinator implements TabGridDialogMediator.DialogCon
false, gridCardOnClickListenerProvider, mMediator.getTabGridDialogHandler(),
TabProperties.UiType.CLOSABLE, null, containerView, false, mComponentName);
TabListRecyclerView recyclerView = mTabListCoordinator.getContainerView();
mToolbarCoordinator = new TabGridPanelToolbarCoordinator(
context, recyclerView, mToolbarPropertyModel, mParentLayout);
TabGroupUiToolbarView toolbarView =
(TabGroupUiToolbarView) LayoutInflater.from(context).inflate(
R.layout.bottom_tab_grid_toolbar, recyclerView, false);
toolbarView.setupDialogToolbarLayout();
if (!TabUiFeatureUtilities.isTabGroupsAndroidContinuationEnabled()) {
toolbarView.hideTabGroupsContinuationWidgets();
}
mModelChangeProcessor = PropertyModelChangeProcessor.create(mModel,
new TabGridPanelViewBinder.ViewHolder(toolbarView, recyclerView, mParentLayout),
TabGridPanelViewBinder::bind);
}
public void initWithNative(Context context, TabModelSelector tabModelSelector,
......@@ -99,14 +111,11 @@ public class TabGridDialogCoordinator implements TabGridDialogMediator.DialogCon
public void destroy() {
mTabListCoordinator.destroy();
mMediator.destroy();
mToolbarCoordinator.destroy();
mParentLayout.destroy();
mModelChangeProcessor.destroy();
if (mTabSelectionEditorCoordinator != null) {
mTabSelectionEditorCoordinator.destroy();
}
if (mToolbarCoordinator != null) {
mToolbarCoordinator.destroy();
}
}
boolean isVisible() {
......
// Copyright 2019 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.tasks.tab_management;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import org.chromium.chrome.browser.lifecycle.Destroyable;
import org.chromium.chrome.tab_ui.R;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
/**
* Coordinator for the toolbar component that will be shown on top of the tab
* grid components, used in {@link TabGridDialogCoordinator}.
*/
class TabGridPanelToolbarCoordinator implements Destroyable {
private final TabGroupUiToolbarView mToolbarView;
private final PropertyModelChangeProcessor mModelChangeProcessor;
/**
* Construct a new {@link TabGridPanelToolbarCoordinator}.
*
* @param context The {@link Context} used to retrieve resources.
* @param contentView The {@link View} to which the content will
* eventually be attached.
* @param toolbarPropertyModel The {@link PropertyModel} instance representing
* the toolbar.
*/
TabGridPanelToolbarCoordinator(
Context context, RecyclerView contentView, PropertyModel toolbarPropertyModel) {
this(context, contentView, toolbarPropertyModel, null);
}
TabGridPanelToolbarCoordinator(Context context, RecyclerView contentView,
PropertyModel toolbarPropertyModel, TabGridDialogParent dialog) {
mToolbarView = (TabGroupUiToolbarView) LayoutInflater.from(context).inflate(
R.layout.bottom_tab_grid_toolbar, contentView, false);
mToolbarView.setupToolbarLayout();
if (!TabUiFeatureUtilities.isTabGroupsAndroidContinuationEnabled()) {
mToolbarView.hideTabGroupsContinuationWidgets();
}
mModelChangeProcessor = PropertyModelChangeProcessor.create(toolbarPropertyModel,
new TabGridPanelViewBinder.ViewHolder(mToolbarView, contentView, dialog),
TabGridPanelViewBinder::bind);
}
/** @return The content {@link View}. */
View getView() {
return mToolbarView;
}
/** Destroy the toolbar component. */
@Override
public void destroy() {
mModelChangeProcessor.destroy();
}
}
......@@ -118,9 +118,9 @@ public class TabGroupUiToolbarView extends FrameLayout {
}
/**
* Setup the toolbar layout base on the component it belongs to.
* Setup the toolbar layout for TabGridDialog.
*/
void setupToolbarLayout() {
void setupDialogToolbarLayout() {
Context context = getContext();
mLeftButton.setImageResource(org.chromium.chrome.R.drawable.ic_arrow_back_24dp);
int topicMargin =
......
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