Commit 93642db2 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Animation effect for 'Open In a New Tab' button for Preview Tab

This CL gives animation (alpha) effect to the 'Open in a New Tab' button
on preview tab header when sliding up/down the panel.

Bug: 1047889
Change-Id: I28504f8fd89d8cfe67d5523bdd5e2f186000cbd1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032458
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: default avatarDonn Denman <donnd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737687}
parent e45e9280
......@@ -81,7 +81,6 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
@Override
public void onSheetStateChanged(int newState) {
if (mSheetContent == null) return;
mSheetContent.showOpenInNewTabButton(newState == SheetState.FULL);
switch (newState) {
case SheetState.PEEK:
mMetrics.recordMetricsForPeeked();
......@@ -101,9 +100,9 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
@Override
public void onSheetOffsetChanged(float heightFraction, float offsetPx) {
if (heightFraction == 0.0f) {
mMetrics.recordMetricsForClosed(mCloseReason);
}
if (mSheetContent == null) return;
if (heightFraction == 0.0f) mMetrics.recordMetricsForClosed(mCloseReason);
mSheetContent.showOpenInNewTabButton(heightFraction);
}
});
}
......
......@@ -191,10 +191,19 @@ public class EphemeralTabSheetContent implements BottomSheetContent {
progressBar.setVisibility(visible ? View.VISIBLE : View.GONE);
}
/** Called to show or hide the open in new tab button. */
public void showOpenInNewTabButton(boolean show) {
View openInNewTabButton = mToolbarView.findViewById(R.id.open_in_new_tab);
openInNewTabButton.setVisibility(show ? View.VISIBLE : View.GONE);
/**
* Called to show (with alpha) or hide the open in new tab button.
* @param fraction Alpha for the button when visible.
*/
public void showOpenInNewTabButton(float fraction) {
View button = mToolbarView.findViewById(R.id.open_in_new_tab);
// Start showing the button about halfway toward the full state.
if (fraction <= 0.5f) {
if (button.getVisibility() != View.GONE) button.setVisibility(View.GONE);
} else {
if (button.getVisibility() != View.VISIBLE) button.setVisibility(View.VISIBLE);
button.setAlpha((fraction - 0.5f) * 2.0f);
}
}
@Override
......
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