[Android] Fix for hairline height (#31434)

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/e981dd46821f563acaa6a5a3d8fd51e046e311e2

commit e981dd46821f563acaa6a5a3d8fd51e046e311e2
Author: Patrick Noland <pnoland@google.com>
Date:   Wed Aug 13 13:37:18 2025 -0700

    [Toolbar] Rework hairline positioning

    Manually calculating the margin for the hairline is error-prone and
    tedious when multiple components can alter the height of the toolbar.
    Instead of manual manipulation, we can position it "for free" by using
    coordinator layout's anchor gravity concept.

    This does require switching the toolbar container to be a
    CoordinatorLayout. Mostly this is easy since CoordinatorLayout is a more
    powerful FrameLayout. There is one consideration: OptimizedFrameLayout,
    formerly in the inheritance chain for the toolbar container, reduced the
    number of measure calls on ToolbarLayout for performance reasons.

    This ends up not mattering because CoordinatorLayout performs the same
    number of measure calls.

    NO_IFTTT=Adding block for the first time

    Change-Id: Idfbb41afbbb1d361214cd0e8e585fefa545aee89
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6828889
    Reviewed-by: Xi Han <hanxi@chromium.org>
    Reviewed-by: Wenyu Fu <wenyufu@chromium.org>
    Commit-Queue: Patrick Noland <pnoland@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1501003}
This commit is contained in:
samartnik
2025-09-25 22:26:26 -04:00
committed by GitHub
parent 9201c3d662
commit 9628962880
4 changed files with 2 additions and 45 deletions
@@ -2305,39 +2305,6 @@ public abstract class BraveActivity extends ChromeActivity
return mBrowserControlsManagerSupplier;
}
public int getToolbarShadowHeight() {
View toolbarShadow = findViewById(R.id.toolbar_hairline);
assert toolbarShadow != null;
if (toolbarShadow != null) {
return toolbarShadow.getHeight();
}
return 0;
}
public float getToolbarBottom() {
View toolbarShadow = findViewById(R.id.toolbar_hairline);
assert toolbarShadow != null;
if (toolbarShadow != null) {
return toolbarShadow.getY();
}
return 0;
}
public boolean isViewBelowToolbar(View view) {
View toolbarShadow = findViewById(R.id.toolbar_hairline);
assert toolbarShadow != null;
assert view != null;
if (toolbarShadow != null && view != null) {
int[] coordinatesToolbar = new int[2];
toolbarShadow.getLocationInWindow(coordinatesToolbar);
int[] coordinatesView = new int[2];
view.getLocationInWindow(coordinatesView);
return coordinatesView[1] >= coordinatesToolbar[1];
}
return false;
}
@NativeMethods
interface Natives {
void restartStatsUpdater();
+2
View File
@@ -98,4 +98,6 @@
<!-- Quick Action Search Widget -->
<dimen name="quick_action_search_widget_small_margin_vertical">12dp</dimen>
<dimen name="toolbar_hairline_height">0dp</dimen>
</resources>
@@ -27,7 +27,6 @@
<ignore regexp="The resource `R.layout.logo_view_layout` appears to be unused" />
<ignore regexp="The resource `R.style.*_BrowserUI_Switch_Incognito` appears to be unused" />
<ignore regexp="The resource `R.style.CardTransparentForDark` appears to be unused" />
<ignore regexp="The resource `R.dimen.toolbar_hairline_height` appears to be unused" />
<ignore
regexp="The resource `R.style.TextAppearance_IncognitoNewTabLearnMoreLinkModern` appears to be unused" />
<ignore regexp="The resource `R.dimen.quick_action_search_widget_.*` appears to be unused"/>
@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2021 The Brave Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@macro/divider_line_bg_color"/>
<size android:height="0dp"/>
</shape>