Skip to content

Commit

Permalink
[EoC] Fix tabswitcher overlay when EoC and incognito buttons shown
Browse files Browse the repository at this point in the history
Fix the tabswitcher overlay when both the EoC and incognito toolbar
buttons are shown. Previously, when the incognito toggle button was
shown in the toolbar button container the EoC button was incorrectly
offset in the tabswitcher animation overlay.

The two buttons are now contained in a single FrameLayout and the
tabswitcher animation overlay draw logic is adjusted to properly
translate to the experimental button.

BUG=863819

Change-Id: I4a60f6f15b516f2a7933c3cde4e7a4a23831b0f7
Reviewed-on: https://chromium-review.googlesource.com/1148585
Reviewed-by: Ted Choc <[email protected]>
Commit-Queue: Theresa <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#577599}(cherry picked from commit b4c9587)
Reviewed-on: https://chromium-review.googlesource.com/1150544
Reviewed-by: Theresa <[email protected]>
Cr-Commit-Position: refs/branch-heads/3497@{#110}
Cr-Branched-From: 271eaf5-refs/heads/master@{#576753}
  • Loading branch information
Theresa committed Jul 26, 2018
1 parent e146987 commit 0227fab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
36 changes: 20 additions & 16 deletions chrome/android/java/res/layout/toolbar_phone_common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,27 @@
android:layout_width="4dp"
android:layout_height="match_parent" />

<ViewStub
android:id="@+id/experimental_button_stub"
android:inflatedId="@+id/experimental_toolbar_button"
android:layout="@layout/experimental_toolbar_button"
style="@style/ToolbarButton"
android:paddingStart="8dp"
android:layout_gravity="top"
android:visibility="gone" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top" >

<ViewStub
android:id="@+id/incognito_button_stub"
android:inflatedId="@+id/incognito_button"
android:layout="@layout/toolbar_phone_incognito_button"
style="@style/ToolbarButton"
android:layout_gravity="top"
android:contentDescription="@string/accessibility_tabstrip_btn_incognito_toggle_standard"
android:visibility="gone" />
<ViewStub
android:id="@+id/experimental_button_stub"
android:inflatedId="@+id/experimental_toolbar_button"
android:layout="@layout/experimental_toolbar_button"
style="@style/ToolbarButton"
android:paddingStart="8dp"
android:visibility="gone" />

<ViewStub
android:id="@+id/incognito_button_stub"
android:inflatedId="@+id/incognito_button"
android:layout="@layout/toolbar_phone_incognito_button"
style="@style/ToolbarButton"
android:contentDescription="@string/accessibility_tabstrip_btn_incognito_toggle_standard"
android:visibility="gone" />
</FrameLayout>

<ImageButton android:id="@+id/tab_switcher_button"
style="@style/ToolbarButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,12 @@ protected int getBoundsAfterAccountingForRightButtons() {
// We set the incognito toggle button's visibility from GONE to VISIBLE when the tab
// switcher starts to open, but we don't want this to affect the Omnibox's size during the
// animation, so we have to make an adjustment here.
// However, if the experimental button is showing it sits in a FrameLayout with the
// incognito button and the omnibox will be appropriately sized without an explicit
// adjustment.
int incognitoButtonWidth = 0;
if (mIncognitoToggleButton != null && mIncognitoToggleButton.getVisibility() == VISIBLE) {
if (mIncognitoToggleButton != null && mIncognitoToggleButton.getVisibility() == VISIBLE
&& (mExperimentalButton == null || mExperimentalButton.getVisibility() == GONE)) {
incognitoButtonWidth += mIncognitoToggleButton.getMeasuredWidth();
}
return Math.max(mToolbarSidePadding,
Expand Down Expand Up @@ -1392,10 +1396,15 @@ protected void drawTabSwitcherAnimationOverlay(Canvas canvas, float animationPro

// Draw the experimental button if necessary.
if (mExperimentalButton != null && mExperimentalButton.getVisibility() != View.GONE) {
canvas.save();
translateCanvasToView(mToolbarButtonsContainer, mExperimentalButton, canvas);

previousAlpha = mExperimentalButton.getAlpha();
mExperimentalButton.setAlpha(previousAlpha * floatAlpha);
drawChild(canvas, mExperimentalButton, SystemClock.uptimeMillis());
mExperimentalButton.setAlpha(previousAlpha);

canvas.restore();
}

// Draw the tab stack button and associated text.
Expand Down

0 comments on commit 0227fab

Please sign in to comment.