[cr143][Android] Apply material style on new tab button on bottom controls
This is to match current look of the upstream's new tab button on the top toolbar. Chromium changes: https://chromium.googlesource.com/chromium/src/+/6b0c6d0a59741c881f38a425053e36d469363844 commit 6b0c6d0a59741c881f38a425053e36d469363844 Author: Sinan Sahin <sinansahin@google.com> Date: Tue Sep 30 10:18:16 2025 -0700 Reland "Migrate to Material3Expressive" This is a reland of commit ddc59318c9524bb0e98a3aac20a085dd57731cee The original CL caused test failures in CI because of an R8 issue. It's since been fixed in cl/811001846. Original change's description: > Migrate to Material3Expressive > > Bug: 427971093 > Change-Id: I14790d37aab135fbf18453a58dc88c4553b14b61 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6961040 > Commit-Queue: Sinan Sahin <sinansahin@google.com> > Reviewed-by: Theresa Sullivan <twellington@chromium.org> > Reviewed-by: Wenyu Fu <wenyufu@chromium.org> > Cr-Commit-Position: refs/heads/main@{#1518087} Bug: 427971093 Fixed: 446644585 Change-Id: I4932b3a1a957f2b287a1d0be6c453257b6281a3a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6974420 Reviewed-by: Wenyu Fu <wenyufu@chromium.org> Reviewed-by: Theresa Sullivan <twellington@chromium.org> Commit-Queue: Sinan Sahin <sinansahin@google.com> Reviewed-by: Sky Malice <skym@chromium.org> Cr-Commit-Position: refs/heads/main@{#1522968}
This commit is contained in:
@@ -415,7 +415,6 @@ brave_java_sources = [
|
||||
"../../brave/android/java/org/chromium/chrome/browser/toolbar/bottom/BookmarksButton.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarConfiguration.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarCoordinator.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarNewTabButton.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/toolbar/bottom/BottomToolbarVariationManager.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/toolbar/bottom/BraveBottomControlsCoordinator.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/toolbar/bottom/BraveScrollingBottomViewResourceFrameLayout.java",
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
android:paddingStart="@dimen/bottom_toolbar_padding"
|
||||
android:paddingEnd="@dimen/bottom_toolbar_padding" >
|
||||
|
||||
<!-- <include layout="@layout/toolbar_space" /> -->
|
||||
|
||||
<org.chromium.chrome.browser.toolbar.BraveHomeButton
|
||||
android:id="@+id/bottom_home_button"
|
||||
app:tint="@color/default_icon_color_tint_list"
|
||||
@@ -26,17 +24,6 @@
|
||||
android:visibility="gone"
|
||||
style="@style/SplitToolbarButton" />
|
||||
|
||||
<!--
|
||||
<org.chromium.chrome.browser.toolbar.bottom.BottomToolbarNewTabButton
|
||||
android:id="@+id/bottom_new_tab_button"
|
||||
android:contentDescription="@string/accessibility_toolbar_btn_new_tab"
|
||||
app:tint="@color/default_icon_color_tint_list"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
app:srcCompat="@drawable/new_tab_icon"
|
||||
android:visibility="gone"
|
||||
style="@style/SplitToolbarButton" />
|
||||
-->
|
||||
|
||||
<include layout="@layout/toolbar_space" />
|
||||
<include layout="@layout/brave_bookmark_toolbar" />
|
||||
<include layout="@layout/toolbar_space" />
|
||||
@@ -54,7 +41,6 @@
|
||||
app:srcCompat="@drawable/ic_search_21dp"/>
|
||||
<include layout="@layout/brave_bottom_new_tab_button" />
|
||||
|
||||
<!-- <include layout="@layout/toolbar_space" /> -->
|
||||
<include layout="@layout/toolbar_space" />
|
||||
|
||||
<org.chromium.chrome.browser.toolbar.TabSwitcherButtonView
|
||||
|
||||
@@ -28,14 +28,13 @@
|
||||
android:paddingStart="@dimen/bottom_toolbar_padding"
|
||||
android:paddingEnd="@dimen/bottom_toolbar_padding" >
|
||||
|
||||
<org.chromium.chrome.browser.toolbar.bottom.BottomToolbarNewTabButton
|
||||
<Button
|
||||
android:id="@+id/tab_switcher_new_tab_button"
|
||||
android:layout_width="@dimen/search_accelerator_height"
|
||||
android:layout_height="@dimen/search_accelerator_height"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:contentDescription="@string/accessibility_toolbar_btn_new_tab"
|
||||
android:paddingTop="@dimen/search_accelerator_height_padding"
|
||||
android:paddingBottom="@dimen/search_accelerator_height_padding" />
|
||||
style="?attr/newTabButtonStyle" />
|
||||
|
||||
<include layout="@layout/toolbar_space" />
|
||||
|
||||
|
||||
@@ -7,15 +7,17 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" >
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical" >
|
||||
|
||||
<org.chromium.chrome.browser.toolbar.bottom.BottomToolbarNewTabButton
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/bottom_new_tab_button"
|
||||
android:layout_width="@dimen/hub_toolbar_action_button_size"
|
||||
android:layout_height="@dimen/hub_toolbar_action_button_size"
|
||||
android:contentDescription="@string/accessibility_toolbar_btn_new_tab"
|
||||
app:tint="@color/default_icon_color_tint_list"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
app:srcCompat="@drawable/new_tab_icon"
|
||||
android:visibility="gone"
|
||||
style="@style/SplitToolbarButton" />
|
||||
app:icon="@drawable/new_tab_icon"
|
||||
app:iconGravity="textStart"
|
||||
style="?attr/newTabButtonStyle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
+3
-1
@@ -14,6 +14,8 @@ import android.view.ViewStub;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
||||
import org.chromium.base.Callback;
|
||||
import org.chromium.base.CallbackController;
|
||||
import org.chromium.base.ContextUtils;
|
||||
@@ -75,7 +77,7 @@ class BottomToolbarCoordinator implements View.OnLongClickListener {
|
||||
private final BraveScrollingBottomViewResourceFrameLayout mScrollingBottomView;
|
||||
private HomeButton mHomeButton;
|
||||
private BookmarksButton mBookmarksButton;
|
||||
private BottomToolbarNewTabButton mNewTabButton;
|
||||
private MaterialButton mNewTabButton;
|
||||
private final View mBottomContainerTopShadow;
|
||||
private boolean mBookmarkButtonFilled;
|
||||
private final ObservableSupplier<BookmarkModel> mBookmarkModelSupplier;
|
||||
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.chrome.browser.toolbar.bottom;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.widget.ImageViewCompat;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.tabmodel.IncognitoStateProvider;
|
||||
import org.chromium.chrome.browser.tabmodel.IncognitoStateProvider.IncognitoStateObserver;
|
||||
import org.chromium.chrome.browser.theme.ThemeColorProvider;
|
||||
import org.chromium.chrome.browser.theme.ThemeColorProvider.ThemeColorObserver;
|
||||
import org.chromium.chrome.browser.theme.ThemeColorProvider.TintObserver;
|
||||
import org.chromium.chrome.browser.theme.ThemeUtils;
|
||||
import org.chromium.chrome.browser.ui.theme.BrandedColorScheme;
|
||||
import org.chromium.ui.widget.ChromeImageButton;
|
||||
|
||||
/** The tab switcher new tab button. */
|
||||
class BottomToolbarNewTabButton extends ChromeImageButton
|
||||
implements IncognitoStateObserver, ThemeColorObserver, TintObserver {
|
||||
/** The gray pill background behind the plus icon. */
|
||||
private Drawable mBackground;
|
||||
|
||||
/** The {@link Context} used to compute the background color. */
|
||||
private final Context mContext;
|
||||
|
||||
/** A provider that notifies when incognito mode is entered or exited. */
|
||||
private IncognitoStateProvider mIncognitoStateProvider;
|
||||
|
||||
/** A provider that notifies when the theme color changes.*/
|
||||
private ThemeColorProvider mThemeColorProvider;
|
||||
|
||||
public BottomToolbarNewTabButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackground(Drawable background) {
|
||||
super.setBackground(background);
|
||||
mBackground = background;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up any state when the new tab button is destroyed.
|
||||
*/
|
||||
void destroy() {
|
||||
if (mIncognitoStateProvider != null) {
|
||||
mIncognitoStateProvider.removeObserver(this);
|
||||
mIncognitoStateProvider = null;
|
||||
}
|
||||
if (mThemeColorProvider != null) {
|
||||
mThemeColorProvider.removeThemeColorObserver(this);
|
||||
mThemeColorProvider.removeTintObserver(this);
|
||||
mThemeColorProvider = null;
|
||||
}
|
||||
}
|
||||
|
||||
void setIncognitoStateProvider(IncognitoStateProvider incognitoStateProvider) {
|
||||
mIncognitoStateProvider = incognitoStateProvider;
|
||||
mIncognitoStateProvider.addIncognitoStateObserverAndTrigger(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncognitoStateChanged(boolean isIncognito) {
|
||||
@StringRes
|
||||
int resId = isIncognito ? R.string.accessibility_toolbar_btn_new_incognito_tab
|
||||
: R.string.accessibility_toolbar_btn_new_tab;
|
||||
setContentDescription(getResources().getText(resId));
|
||||
updateBackground();
|
||||
}
|
||||
|
||||
void setThemeColorProvider(ThemeColorProvider themeColorProvider) {
|
||||
mThemeColorProvider = themeColorProvider;
|
||||
mThemeColorProvider.addThemeColorObserver(this);
|
||||
mThemeColorProvider.addTintObserver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onThemeColorChanged(int primaryColor, boolean shouldAnimate) {
|
||||
updateBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTintChanged(
|
||||
ColorStateList tint,
|
||||
ColorStateList activityFocusTint,
|
||||
@BrandedColorScheme int brandedColorScheme) {
|
||||
ImageViewCompat.setImageTintList(this, tint);
|
||||
updateBackground();
|
||||
}
|
||||
|
||||
private void updateBackground() {
|
||||
if (mThemeColorProvider == null || mIncognitoStateProvider == null || mBackground == null) {
|
||||
return;
|
||||
}
|
||||
mBackground.setColorFilter(
|
||||
ThemeUtils.getTextBoxColorForToolbarBackgroundInNonNativePage(
|
||||
mContext,
|
||||
mThemeColorProvider.getThemeColor(),
|
||||
mIncognitoStateProvider.isIncognitoSelected(),
|
||||
false /*isCustomTab*/),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
}
|
||||
+3
-7
@@ -9,6 +9,8 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnLongClickListener;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
|
||||
import org.chromium.base.Callback;
|
||||
import org.chromium.base.ContextUtils;
|
||||
import org.chromium.base.Log;
|
||||
@@ -50,7 +52,7 @@ public class BrowsingModeBottomToolbarCoordinator {
|
||||
private final BraveHomeButton mBraveHomeButton;
|
||||
|
||||
/** The new tab button that lives in the bottom toolbar. */
|
||||
private final BottomToolbarNewTabButton mNewTabButton;
|
||||
private final MaterialButton mNewTabButton;
|
||||
|
||||
/** The search accelerator that lives in the bottom toolbar. */
|
||||
private final SearchAccelerator mSearchAccelerator;
|
||||
@@ -192,12 +194,6 @@ public class BrowsingModeBottomToolbarCoordinator {
|
||||
}
|
||||
if (BottomToolbarVariationManager.isNewTabButtonOnBottomControls()) {
|
||||
mNewTabButton.setOnClickListener(newTabListener);
|
||||
mNewTabButton.setThemeColorProvider(themeColorProvider);
|
||||
mNewTabButton.setIncognitoStateProvider(incognitoStateProvider);
|
||||
mNewTabButton.onTintChanged(
|
||||
mThemeColorProvider.getTint(),
|
||||
mThemeColorProvider.getTint(),
|
||||
mThemeColorProvider.getBrandedColorScheme());
|
||||
}
|
||||
|
||||
if (BottomToolbarVariationManager.isHomeButtonOnBottomControls()) {
|
||||
|
||||
+3
-14
@@ -5,13 +5,12 @@
|
||||
|
||||
package org.chromium.chrome.browser.toolbar.bottom;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewStub;
|
||||
import android.widget.Button;
|
||||
|
||||
import org.chromium.base.ApiCompatibilityUtils;
|
||||
import org.chromium.base.supplier.ObservableSupplier;
|
||||
import org.chromium.base.supplier.OneShotCallback;
|
||||
import org.chromium.chrome.R;
|
||||
@@ -38,7 +37,7 @@ public class TabSwitcherBottomToolbarCoordinator {
|
||||
private final TabSwitcherBottomToolbarMediator mMediator;
|
||||
|
||||
/** The new tab button that lives in the tab switcher bottom toolbar. */
|
||||
private final BottomToolbarNewTabButton mNewTabButton;
|
||||
private final Button mNewTabButton;
|
||||
|
||||
/** The menu button that lives in the tab switcher bottom toolbar. */
|
||||
private final MenuButton mMenuButton;
|
||||
@@ -86,14 +85,7 @@ public class TabSwitcherBottomToolbarCoordinator {
|
||||
mMediator = new TabSwitcherBottomToolbarMediator(mModel, themeColorProvider);
|
||||
|
||||
mNewTabButton = root.findViewById(R.id.tab_switcher_new_tab_button);
|
||||
Drawable background =
|
||||
ApiCompatibilityUtils.getDrawable(
|
||||
root.getResources(), R.drawable.home_surface_search_box_background);
|
||||
background.mutate();
|
||||
mNewTabButton.setBackground(background);
|
||||
mNewTabButton.setOnClickListener(newTabClickListener);
|
||||
mNewTabButton.setIncognitoStateProvider(incognitoStateProvider);
|
||||
mNewTabButton.setThemeColorProvider(themeColorProvider);
|
||||
|
||||
mMenuButton = root.findViewById(R.id.menu_button_wrapper);
|
||||
if (mMenuButton != null) {
|
||||
@@ -124,11 +116,8 @@ public class TabSwitcherBottomToolbarCoordinator {
|
||||
mModel.set(TabSwitcherBottomToolbarModel.IS_VISIBLE, visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up any state when the bottom toolbar is destroyed.
|
||||
*/
|
||||
/** Clean up any state when the bottom toolbar is destroyed. */
|
||||
public void destroy() {
|
||||
mMediator.destroy();
|
||||
mNewTabButton.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user