Commit 8202db3f authored by Sinan Sahin's avatar Sinan Sahin Committed by Commit Bot

[Offline indicator v2] Fix text fade in animation in fullscreen

When the status indicator is shown in fullscreen mode, the text wouldn't
fade-in. The animation would run, but the frames wouldn't be presented
to the screen even though they are drawn.

To work around that, this CL adds a #requestLayout() call at the start
of the animation.

Bug: 1083461
Change-Id: If816b2882b77e41a7b00d8b863548e8629aff248
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216281Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Sinan Sahin <sinansahin@google.com>
Cr-Commit-Position: refs/heads/master@{#771944}
parent 9b9a8159
......@@ -83,10 +83,11 @@ public class StatusIndicatorCoordinator {
root.getResourceAdapter().invalidate(null);
requestRender.onResult(callback);
};
Runnable requestLayout = () -> root.requestLayout();
mMediator = new StatusIndicatorMediator(model, fullscreenManager,
statusBarColorWithoutStatusIndicatorSupplier, canAnimateNativeBrowserControls,
invalidateCompositorView);
invalidateCompositorView, requestLayout);
resourceManager.getDynamicResourceLoader().registerResource(
root.getId(), root.getResourceAdapter());
root.addOnLayoutChangeListener(mMediator);
......
......@@ -39,6 +39,7 @@ class StatusIndicatorMediator
private Runnable mOnCompositorShowAnimationEnd;
private Supplier<Boolean> mCanAnimateNativeBrowserControls;
private Callback<Runnable> mInvalidateCompositorView;
private Runnable mRequestLayout;
private int mIndicatorHeight;
private int mJavaLayoutHeight;
......@@ -57,17 +58,19 @@ class StatusIndicatorMediator
* where we can't have a reliable cc::BCOM instance, e.g.
* tab switcher.
* @param invalidateCompositorView Callback to invalidate the compositor texture.
* @param requestLayout Runnable to request layout for the view.
*/
StatusIndicatorMediator(PropertyModel model,
BrowserControlsStateProvider browserControlsStateProvider,
Supplier<Integer> statusBarWithoutIndicatorColorSupplier,
Supplier<Boolean> canAnimateNativeBrowserControls,
Callback<Runnable> invalidateCompositorView) {
Callback<Runnable> invalidateCompositorView, Runnable requestLayout) {
mModel = model;
mBrowserControlsStateProvider = browserControlsStateProvider;
mStatusBarWithoutIndicatorColorSupplier = statusBarWithoutIndicatorColorSupplier;
mCanAnimateNativeBrowserControls = canAnimateNativeBrowserControls;
mInvalidateCompositorView = invalidateCompositorView;
mRequestLayout = requestLayout;
}
@Override
......@@ -171,6 +174,12 @@ class StatusIndicatorMediator
final float currentAlpha = (float) anim.getAnimatedValue();
mModel.set(StatusIndicatorProperties.TEXT_ALPHA, currentAlpha);
}));
animation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mRequestLayout.run();
}
});
animation.start();
}
......
......@@ -41,18 +41,16 @@ public class StatusIndicatorMediatorTest {
@Mock
BrowserControlsStateProvider mBrowserControlsStateProvider;
@Mock
View mStatusIndicatorView;
@Mock
StatusIndicatorCoordinator.StatusIndicatorObserver mObserver;
@Mock
Supplier<Boolean> mCanAnimateNativeBrowserControls;
@Mock
Callback<Runnable> mInvalidateCompositorView;
@Mock
Runnable mRequestLayout;
private PropertyModel mModel;
private StatusIndicatorMediator mMediator;
......@@ -62,12 +60,14 @@ public class StatusIndicatorMediatorTest {
MockitoAnnotations.initMocks(this);
when(mCanAnimateNativeBrowserControls.get()).thenReturn(true);
doNothing().when(mInvalidateCompositorView).onResult(any(Runnable.class));
doNothing().when(mRequestLayout).run();
mModel = new PropertyModel.Builder(StatusIndicatorProperties.ALL_KEYS)
.with(StatusIndicatorProperties.ANDROID_VIEW_VISIBILITY, View.GONE)
.with(StatusIndicatorProperties.COMPOSITED_VIEW_VISIBLE, false)
.build();
mMediator = new StatusIndicatorMediator(mModel, mBrowserControlsStateProvider,
() -> Color.WHITE, mCanAnimateNativeBrowserControls, mInvalidateCompositorView);
() -> Color.WHITE, mCanAnimateNativeBrowserControls, mInvalidateCompositorView,
mRequestLayout);
}
@Test
......
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