Skip to content

Commit

Permalink
Uplift of #25923 (squashed) to release
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-builds committed Oct 11, 2024
1 parent 7d51df6 commit f762ece
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions android/java/apk_for_test.flags
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@

-keep class org.chromium.chrome.browser.tabbed_mode.TabbedNavigationBarColorController {
*** mContext;
*** mTabModelSelector;
}

-keep class org.chromium.chrome.browser.tabbed_mode.BraveTabbedNavigationBarColorControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import android.os.Build;

import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import org.chromium.base.BraveReflectionUtil;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.toolbar.bottom.BottomToolbarConfiguration;
import org.chromium.chrome.browser.toolbar.menu_button.BraveMenuButtonCoordinator;

Expand All @@ -23,7 +25,9 @@ class BraveTabbedNavigationBarColorControllerBase {
* This variable will be used instead of `TabGroupModelFilter#mContext`, that will be deleted in
* bytecode.
*/
protected Context mContext;
protected @Nullable Context mContext;

protected @Nullable TabModelSelector mTabModelSelector;

// Calls from the upstream's private function
// `TabbedNavigationBarColorController#getNavigationBarColor`
Expand All @@ -33,8 +37,13 @@ public int getNavigationBarColor(boolean forceDarkNavigationBar) {
// Adjust navigation bar color to match the bottom toolbar color when it is visible.
if (BottomToolbarConfiguration.isBottomToolbarEnabled()
&& BraveMenuButtonCoordinator.isMenuFromBottom()
&& mContext != null) {
return mContext.getColor(R.color.default_bg_color_baseline);
&& mContext != null
&& mTabModelSelector != null) {
if (mTabModelSelector.isIncognitoSelected()) {
return mContext.getColor(R.color.toolbar_background_primary_dark);
} else {
return mContext.getColor(R.color.default_bg_color_baseline);
}
}

// Otherwise just call upstream's method.
Expand Down
2 changes: 2 additions & 0 deletions android/java/res/values/brave_colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<color name="systemfeedback_info_text">#0061aa</color>
<color name="text_interactive">#3f39e8</color>
<color name="container_background">#ffffff</color>
<color name="primitive_private_window_5">#160041</color>

<!-- Sync colors -->
<color name="brave_sync_bg_color">@android:color/transparent</color>
Expand Down Expand Up @@ -143,6 +144,7 @@
<color name="news_settings_unfollow_color">#4C54D2</color>

<!-- Incognito mode colors -->
<color name="toolbar_background_primary_dark">@color/primitive_private_window_5</color>
<color name="ntp_bg_incognito">@color/incognito_modern_primary_color</color>
<color name="brave_private_tabs_bg_color">#13052A</color>
<color name="brave_private_reauth_unlock_button_bg_color">#4B415D</color>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,10 @@ public void testFieldsExist() throws Exception {
fieldExists(
"org/chromium/chrome/browser/tabbed_mode/TabbedNavigationBarColorController", // presubmit: ignore-long-line
"mContext"));
Assert.assertFalse(
fieldExists(
"org/chromium/chrome/browser/tabbed_mode/TabbedNavigationBarColorController", // presubmit: ignore-long-line
"mTabModelSelector"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public BraveTabbedNavigationBarColorControllerBaseClassAdapter(ClassVisitor visi

deleteField(sTabbedNavigationBarColorControllerClassName, "mContext");

deleteField(sTabbedNavigationBarColorControllerClassName, "mTabModelSelector");

changeMethodOwner(
sTabbedNavigationBarColorControllerClassName,
"getNavigationBarColor",
Expand Down

0 comments on commit f762ece

Please sign in to comment.