Skip to content

Commit

Permalink
Static Theme color for toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
1311-hack1 committed Oct 27, 2024
1 parent 774bf44 commit c15c4da
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import android.view.accessibility.AccessibilityEvent;
import android.view.autofill.AutofillValue;

import android.util.Log;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -28,7 +30,7 @@

import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
// import org.chromium.base.Log;
import org.chromium.base.ObserverList;
import org.chromium.base.ObserverList.RewindableIterator;
import org.chromium.base.ThreadUtils;
Expand Down Expand Up @@ -491,14 +493,14 @@ public int getThemeColor() {

@Override
public int getBackgroundColor() {
if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()) {
if (mCustomView != null && mCustomViewBackgroundColor != null) {
return mCustomViewBackgroundColor;
}
if (mNativePage != null) {
return mNativePage.getBackgroundColor();
}
}
// if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()) {
// if (mCustomView != null && mCustomViewBackgroundColor != null) {
// return mCustomViewBackgroundColor;
// }
// if (mNativePage != null) {
// return mNativePage.getBackgroundColor();
// }
// }
return mWebContentBackgroundColor;
}

Expand Down Expand Up @@ -1474,10 +1476,10 @@ void changeWebContentBackgroundColor(int color) {

/** Called to notify when the page had painted something non-empty. */
void notifyDidFirstVisuallyNonEmptyPaint() {
if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()
&& mWaitingOnBgColorAfterHidingNativePage) {
onBackgroundColorChanged();
}
// if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()
// && mWaitingOnBgColorAfterHidingNativePage) {
// onBackgroundColorChanged();
// }
mWaitingOnBgColorAfterHidingNativePage = false;
}

Expand Down Expand Up @@ -1701,9 +1703,9 @@ private void showNativePage(NativePage nativePage) {
}
pushNativePageStateToNavigationEntry();

if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()) {
onBackgroundColorChanged();
}
// if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()) {
// onBackgroundColorChanged();
// }
updateThemeColor(TabState.UNSPECIFIED_THEME_COLOR);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

import android.app.Activity;

import android.util.Log;

import androidx.annotation.VisibleForTesting;

import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.Callback;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
// import org.chromium.base.Log;
import org.chromium.base.ObserverList;
import org.chromium.base.ObserverList.RewindableIterator;
import org.chromium.base.TerminationStatus;
Expand Down Expand Up @@ -339,14 +341,14 @@ public void didFirstVisuallyNonEmptyPaint() {

@Override
public void didChangeThemeColor() {
mTab.updateThemeColor(mTab.getWebContents().getThemeColor());
// mTab.updateThemeColor(mTab.getWebContents().getThemeColor());
}

@Override
public void onBackgroundColorChanged() {
if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()) {
mTab.changeWebContentBackgroundColor(mTab.getWebContents().getBackgroundColor());
}
// if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()) {
// mTab.changeWebContentBackgroundColor(mTab.getWebContents().getBackgroundColor());
// }
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import android.view.ViewGroup;
import android.view.Window;

import android.util.Log;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -135,15 +137,15 @@ class TabbedNavigationBarColorController implements BottomAttachedUiObserver.Obs
layoutManagerSupplier,
fullscreenManager,
edgeToEdgeControllerSupplier,
ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()
? new BottomAttachedUiObserver(
browserControlsStateProvider,
snackbarManagerSupplier.get(),
contextualSearchManagerSupplier,
bottomSheetController,
omniboxSuggestionsVisualState,
insetObserver)
: null);
// ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()
// ? new BottomAttachedUiObserver(
// browserControlsStateProvider,
// snackbarManagerSupplier.get(),
// contextualSearchManagerSupplier,
// bottomSheetController,
// omniboxSuggestionsVisualState,
// insetObserver)
null);
}

@VisibleForTesting
Expand Down Expand Up @@ -289,18 +291,18 @@ public void onStartedHiding(@LayoutType int layoutType) {

@Override
public void onFinishedShowing(@LayoutType int layoutType) {
if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()
&& layoutType == LayoutType.BROWSING) {
updateNavigationBarColor();
}
// if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()
// && layoutType == LayoutType.BROWSING) {
// updateNavigationBarColor();
// }
}
};
mLayoutManager.addObserver(mLayoutStateObserver);
updateNavigationBarColor();
}

private void updateActiveTab() {
if (!ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()) return;
// if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()) return;

@Nullable Tab activeTab = mTabModelSelector.getCurrentTab();
if (activeTab == mActiveTab) return;
Expand Down Expand Up @@ -331,18 +333,17 @@ private void updateNavigationBarColor(@Nullable Integer bottomInset, boolean for
mNavigationBarColor = newNavigationBarColor;
mForceShowDivider = forceShowDivider;

if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled() && !toEdge) {
animateNavigationBarColor(currentNavigationBarColor, newNavigationBarColor);
} else {
// if (ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled() && !toEdge) {
// animateNavigationBarColor(currentNavigationBarColor, newNavigationBarColor);
// } else {
mWindow.setNavigationBarColor(mNavigationBarColor);

if (toEdge) return;

setNavigationBarDividerColor(
getNavigationBarDividerColor(mForceDarkNavigationBarColor, false));
UiUtils.setNavigationBarIconColor(
mRootView, !mForceDarkNavigationBarColor && mLightNavigationBar);
}
// }
}

private void animateNavigationBarColor(
Expand Down Expand Up @@ -449,17 +450,19 @@ int getNavigationBarDividerColor(boolean forceDarkNavigationBar, boolean forceSh
}

private boolean useBottomAttachedUiColor() {
return ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()
&& mBottomAttachedUiColor != null
&& getBottomInset() == 0;
// return ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()
// && mBottomAttachedUiColor != null
// && getBottomInset() == 0;
return false;
}

private boolean useActiveTabColor() {
return ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()
&& mLayoutManager != null
&& mLayoutManager.getActiveLayoutType() == LayoutType.BROWSING
&& mActiveTab != null
&& getBottomInset() == 0;
// return ChromeFeatureList.sNavBarColorMatchesTabBackground.isEnabled()
// && mLayoutManager != null
// && mLayoutManager.getActiveLayoutType() == LayoutType.BROWSING
// && mActiveTab != null
// && getBottomInset() == 0;
return false;
}

private int getBottomInset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ public void onTintChanged(
* from the Tab.
*/
public void setShouldUpdateToolbarPrimaryColor(boolean shouldUpdate) {
mShouldUpdateToolbarPrimaryColor = shouldUpdate;
mShouldUpdateToolbarPrimaryColor = true;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7080,10 +7080,10 @@ const FeatureEntry kFeatureEntries[] = {
#endif

#if BUILDFLAG(IS_ANDROID)
{"enable-nav-bar-matches-tab-android",
flag_descriptions::kNavBarColorMatchesTabBackgroundName,
flag_descriptions::kNavBarColorMatchesTabBackgroundDescription, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kNavBarColorMatchesTabBackground)},
// {"enable-nav-bar-matches-tab-android",
// flag_descriptions::kNavBarColorMatchesTabBackgroundName,
// flag_descriptions::kNavBarColorMatchesTabBackgroundDescription, kOsAndroid,
// FEATURE_VALUE_TYPE(chrome::android::kNavBarColorMatchesTabBackground)},

{"enable-new-tab-search-engine-url-android",
flag_descriptions::kNewTabSearchEngineUrlAndroidName,
Expand Down
10 changes: 5 additions & 5 deletions src/chrome/browser/flag-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3428,11 +3428,11 @@
"owners": [ "[email protected]", "[email protected]" ],
"expiry_milestone": 128
},
{
"name": "enable-nav-bar-matches-tab-android",
"owners": [ "[email protected]", "[email protected]"],
"expiry_milestone": 130
},
// {
// "name": "enable-nav-bar-matches-tab-android",
// "owners": [ "[email protected]", "[email protected]"],
// "expiry_milestone": 130
// },
{
"name": "enable-network-and-issuer-icons-for-secure-payment-confirmation",
"owners": [ "[email protected]", "[email protected]" ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.util.List;
import java.util.Map;

import android.util.Log;

/**
* A list of feature flags exposed to Java.
*
Expand Down Expand Up @@ -583,7 +585,7 @@ private static MutableFlagWithSafeDefault newMutableFlagWithSafeDefault(
public static final CachedFlag sDrawNativeEdgeToEdge =
newCachedFlag(DRAW_NATIVE_EDGE_TO_EDGE, false);
public static final CachedFlag sDrawWebEdgeToEdge = newCachedFlag(DRAW_WEB_EDGE_TO_EDGE, false);
public static final CachedFlag sDynamicTopChrome = newCachedFlag(DYNAMIC_TOP_CHROME, true);
public static final CachedFlag sDynamicTopChrome = newCachedFlag(DYNAMIC_TOP_CHROME, false);
public static final CachedFlag sExperimentsForAgsa = newCachedFlag(EXPERIMENTS_FOR_AGSA, true);
public static final CachedFlag sFeedLoadingPlaceholder =
newCachedFlag(FEED_LOADING_PLACEHOLDER, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public void getOutline(View view, Outline outline) {
view.setTag(webContents);

mCurrentWebContents = webContents;
//setupFloatingBackButton();
// setupFloatingBackButton();

return view;
}
Expand All @@ -533,7 +533,7 @@ private void returnToAppMenu() {
}
}
}
/* This code is not used because we are removing the back button from the extension webview
/* This code is not used because we are removing the back button from the extension webview
private void setupFloatingBackButton() {
View view = getView();
if (view != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ public void onBindViewHolder(PreferenceViewHolder holder) {
mCheckBox.setChecked(mDarkenWebsitesEnabled);

assert ThemeType.NUM_ENTRIES == 3;
mButtons.set(
ThemeType.SYSTEM_DEFAULT,
(RadioButtonWithDescription) holder.findViewById(R.id.system_default));
mButtons.set(ThemeType.SYSTEM_DEFAULT,
(RadioButtonWithDescription) holder.findViewById(R.id.system_default));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
mButtons.get(ThemeType.SYSTEM_DEFAULT)
.setDescriptionText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ found in the LICENSE file.
<dimen name="omnibox_suggestion_content_padding">8dp</dimen>
<dimen name="omnibox_suggestion_compact_content_height">48dp</dimen>
<dimen name="omnibox_suggestion_list_divider_line_padding">12dp</dimen>
<dimen name="omnibox_suggestion_list_padding_top">0dp</dimen>
<dimen name="omnibox_suggestion_list_padding_top">8dp</dimen>
<dimen name="omnibox_suggestion_list_padding_bottom">8dp</dimen>
<dimen name="omnibox_suggestion_list_active_top_small_margin">8dp</dimen>
<dimen name="omnibox_suggestion_list_toolbar_overlap">0dp</dimen>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public SuggestionLayout(Context context) {
var res = context.getResources();

int endSpace = res.getDimensionPixelSize(R.dimen.omnibox_suggestion_end_padding_modern);
setPaddingRelative(0, 0, endSpace, 0);
setPaddingRelative(0, 0, endSpace, 8);

mDecorationIconWidthPx =
OmniboxResourceProvider.getSuggestionDecorationIconSizeWidth(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ public void setContentMainCallbackForTests(Runnable r) {
/** Wrap ContentMain.start() for testing. */
@VisibleForTesting
int contentMainStart(boolean startMinimalBrowser) {
Log.d("lalala", "content main start");
return ContentMain.start(startMinimalBrowser);
}

Expand Down
Empty file modified src/scripts/generate_grd.py
100644 → 100755
Empty file.

0 comments on commit c15c4da

Please sign in to comment.