Skip to content

Commit

Permalink
merged pr-152 in test-pr-152
Browse files Browse the repository at this point in the history
  • Loading branch information
DevT75 committed Oct 29, 2024
2 parents 6cc7553 + 5a3717d commit 5e0289f
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ private static void setFavicon(
private static void updateColor(
ViewLookupCachingFrameLayout rootView, boolean isIncognito, boolean isSelected) {
View cardView = rootView.fastFindViewById(R.id.card_view);
// TextView titleView = (TextView) rootView.fastFindViewById(R.id.tab_title);
TextView titleView = (TextView) rootView.fastFindViewById(R.id.tab_title);
TabThumbnailView thumbnail =
(TabThumbnailView) rootView.fastFindViewById(R.id.tab_thumbnail);
ChromeImageView backgroundView =
Expand All @@ -423,8 +423,8 @@ private static void updateColor(
cardView.getContext(), isIncognito, isSelected);
ViewCompat.setBackgroundTintList(cardView, ColorStateList.valueOf(backgroundColor));

// titleView.setTextColor(
// TabUiThemeUtils.getTitleTextColor(titleView.getContext(), isIncognito, isSelected));
titleView.setTextColor(
TabUiThemeUtils.getTitleTextColor(titleView.getContext(), isIncognito, false));

thumbnail.updateThumbnailPlaceholder(isIncognito, isSelected);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,25 +277,29 @@ private SyncOneshotSupplier<ShrinkExpandAnimationData> requestAnimationData(
recyclerViewRect.bottom = rootViewRect.bottom;
}

// Setting the rootViewRect as the initialRect (case: isShrik -> true) and
// finalRect (case: isShrink -> false) instead of recyclerViewRect as we are
// migrating from TabSwitcherView to HubLayout.
Rect rootViewRect = new Rect();
mRootView.getRootView().getGlobalVisibleRect(rootViewRect);

int leftOffset = 0;
if (isShrink) {
initialRect = recyclerViewRect;
initialRect = rootViewRect;
finalRect = coordinator.getTabThumbnailRect(tabId);
leftOffset = initialRect.left;
finalRect.offset(leftOffset, -hubRect.top);
} else {
initialRect = coordinator.getTabThumbnailRect(tabId);
finalRect = recyclerViewRect;
leftOffset = finalRect.left;
finalRect = rootViewRect;
initialRect.offset(leftOffset, -hubRect.top);
}

boolean useFallbackAnimation = false;
if (initialRect.isEmpty() || finalRect.isEmpty()) {
Log.d(TAG, "Geometry not ready using fallback animation.");
useFallbackAnimation = true;
}
// Ignore left offset and just ensure the width is correct. See crbug/1502437.
initialRect.offset(-leftOffset, -hubRect.top);
finalRect.offset(-leftOffset, -hubRect.top);

animationDataSupplier.set(
new ShrinkExpandAnimationData(
initialRect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,11 @@ public void onTabCreated(
View paneHost = mHubController.getPaneHostView();
assert paneHost.isLaidOut();
Rect finalRect = new Rect();
paneHost.getGlobalVisibleRect(finalRect);
mRootView.getRootView().getGlobalVisibleRect(finalRect);
// paneHost.getGlobalVisibleRect(finalRect);
// Ignore left offset and just ensure the width is correct. See crbug/1502437.
int leftOffset = finalRect.left;
finalRect.offset(-leftOffset, -containerViewRect.top);
int leftOffset = 0;
finalRect.offset(leftOffset, 0);

// TODO(crbug.com/40285429): Supply this from HubController so it can look like the
// animation
Expand Down
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 @@ -139,6 +139,7 @@ public void setHubLayoutController(@NonNull HubLayoutController hubLayoutControl

@Override
public @Nullable View getPaneHostView() {
ensureHubCoordinatorIsInitializedForPane();
assert mHubCoordinator != null : "Access of a Hub pane host view that doesn't exist";
return mHubContainerView.findViewById(R.id.hub_pane_host);
}
Expand Down Expand Up @@ -178,6 +179,11 @@ public boolean onHubLayoutBackPressed() {
}
}

private void ensureHubCoordinatorIsInitializedForPane() {
if (mHubCoordinator != null) return;
ensureHubCoordinatorIsInitialized();
}

private void ensureHubCoordinatorIsInitialized() {
if (mHubCoordinator != null) return;

Expand Down
3 changes: 3 additions & 0 deletions src/chrome/browser/ui/android/appmenu/internal/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ android_library("java") {
deps = [
":java_resources",
"//base:base_java",
"//base/version_info/android:version_constants_java",
"//chrome/android:chrome_java",
"//chrome/browser/android/content:java",
"//chrome/browser/android/lifecycle:java",
Expand All @@ -34,11 +35,13 @@ android_library("java") {
"//components/browser_ui/styles/android:java",
"//components/browser_ui/widget/android:java",
"//components/embedder_support/android:content_view_java",
"//components/embedder_support/android:web_contents_delegate_java",
"//components/thin_webview:factory_java",
"//components/thin_webview:java",
"//content/public/android:content_java",
"//third_party/android_deps:material_design_java",
"//third_party/androidx:androidx_annotation_annotation_java",
"//third_party/androidx:androidx_appcompat_appcompat_java",
"//third_party/androidx:androidx_appcompat_appcompat_resources_java",
"//third_party/androidx:androidx_coordinatorlayout_coordinatorlayout_java",
"//third_party/androidx:androidx_core_core_java",
Expand Down
Loading

0 comments on commit 5e0289f

Please sign in to comment.