Commit 80437d34 authored by Theresa's avatar Theresa Committed by Commit Bot

[EoC] Fix tab switcher overlay in RTL

The EoC toolbar button used to be wrapped in a FrameLayout. Removing the
FrameLayout broke the tab switcher overlay in RTL. This CL mirrors the
tab switcher button drawing logic for the experimental button.

This also updates when we capture a new texture with or without the
experimental button to wait until animations are finished.

BUG=898441

Change-Id: I42759ffb3a836ec4a74ec996c070607902517324
Reviewed-on: https://chromium-review.googlesource.com/c/1297978Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602461}
parent 056bd4f2
...@@ -1321,12 +1321,26 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -1321,12 +1321,26 @@ public class ToolbarPhone extends ToolbarLayout
// Draw the experimental button if necessary. // Draw the experimental button if necessary.
if (mExperimentalButton != null && mExperimentalButton.getVisibility() != View.GONE) { if (mExperimentalButton != null && mExperimentalButton.getVisibility() != View.GONE) {
canvas.save(); canvas.save();
Drawable expButton = mExperimentalButton.getDrawable();
translateCanvasToView(mToolbarButtonsContainer, mExperimentalButton, canvas); translateCanvasToView(mToolbarButtonsContainer, mExperimentalButton, canvas);
previousAlpha = mExperimentalButton.getAlpha(); int backgroundWidth = mExperimentalButton.getDrawable().getIntrinsicWidth();
mExperimentalButton.setAlpha(previousAlpha * floatAlpha); int backgroundHeight = mExperimentalButton.getDrawable().getIntrinsicHeight();
drawChild(canvas, mExperimentalButton, SystemClock.uptimeMillis()); int backgroundLeft =
mExperimentalButton.setAlpha(previousAlpha); (mExperimentalButton.getWidth() - mExperimentalButton.getPaddingLeft()
- mExperimentalButton.getPaddingRight() - backgroundWidth)
/ 2;
backgroundLeft += mExperimentalButton.getPaddingLeft();
int backgroundTop =
(mExperimentalButton.getHeight() - mExperimentalButton.getPaddingTop()
- mExperimentalButton.getPaddingBottom() - backgroundHeight)
/ 2;
backgroundTop += mExperimentalButton.getPaddingTop();
canvas.translate(backgroundLeft, backgroundTop);
expButton.setAlpha(rgbAlpha);
expButton.draw(canvas);
canvas.restore(); canvas.restore();
} }
...@@ -2673,6 +2687,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2673,6 +2687,7 @@ public class ToolbarPhone extends ToolbarLayout
ApiCompatibilityUtils.setImageTintList( ApiCompatibilityUtils.setImageTintList(
mExperimentalButton, mUseLightToolbarDrawables ? mLightModeTint : mDarkModeTint); mExperimentalButton, mUseLightToolbarDrawables ? mLightModeTint : mDarkModeTint);
mExperimentalButtonLayoutListener = () -> requestLayoutHostUpdateForExperimentalButton();
if (mTabSwitcherState == STATIC_TAB) { if (mTabSwitcherState == STATIC_TAB) {
if (!mUrlFocusChangeInProgress && !urlHasFocus()) { if (!mUrlFocusChangeInProgress && !urlHasFocus()) {
runShowExperimentalButtonAnimation(); runShowExperimentalButtonAnimation();
...@@ -2681,10 +2696,8 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2681,10 +2696,8 @@ public class ToolbarPhone extends ToolbarLayout
} }
} else { } else {
mExperimentalButton.setVisibility(View.INVISIBLE); mExperimentalButton.setVisibility(View.INVISIBLE);
getViewTreeObserver().addOnGlobalLayoutListener(mExperimentalButtonLayoutListener);
} }
mExperimentalButtonLayoutListener = () -> requestLayoutHostUpdateForExperimentalButton();
getViewTreeObserver().addOnGlobalLayoutListener(mExperimentalButtonLayoutListener);
} }
@Override @Override
...@@ -2702,11 +2715,10 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2702,11 +2715,10 @@ public class ToolbarPhone extends ToolbarLayout
runHideExperimentalButtonsAnimators(); runHideExperimentalButtonsAnimators();
} else { } else {
mExperimentalButton.setVisibility(View.GONE); mExperimentalButton.setVisibility(View.GONE);
getViewTreeObserver().addOnGlobalLayoutListener(mExperimentalButtonLayoutListener);
} }
mBrowsingModeViews.remove(mExperimentalButton); mBrowsingModeViews.remove(mExperimentalButton);
getViewTreeObserver().addOnGlobalLayoutListener(mExperimentalButtonLayoutListener);
} }
/** /**
...@@ -2768,6 +2780,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2768,6 +2780,7 @@ public class ToolbarPhone extends ToolbarLayout
onExperimentalButtonAnimationEnd(); onExperimentalButtonAnimationEnd();
mDisableLocationBarRelayout = false; mDisableLocationBarRelayout = false;
mExperimentalButtonAnimationRunning = false; mExperimentalButtonAnimationRunning = false;
getViewTreeObserver().addOnGlobalLayoutListener(mExperimentalButtonLayoutListener);
requestLayout(); requestLayout();
} }
}); });
...@@ -2820,6 +2833,7 @@ public class ToolbarPhone extends ToolbarLayout ...@@ -2820,6 +2833,7 @@ public class ToolbarPhone extends ToolbarLayout
mExperimentalButton.setVisibility(View.GONE); mExperimentalButton.setVisibility(View.GONE);
mLayoutLocationBarWithoutExtraButton = false; mLayoutLocationBarWithoutExtraButton = false;
mExperimentalButtonAnimationRunning = false; mExperimentalButtonAnimationRunning = false;
getViewTreeObserver().addOnGlobalLayoutListener(mExperimentalButtonLayoutListener);
} }
}); });
mExperimentalButtonAnimator.playTogether(animators); mExperimentalButtonAnimator.playTogether(animators);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment