Merge "Fix tv edu text drawer not closing completely" into udc-dev

This commit is contained in:
Galia Peycheva
2023-04-18 12:36:22 +00:00
committed by Android (Google) Code Review
2 changed files with 33 additions and 8 deletions

View File

@@ -23,6 +23,7 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE;
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.drawable.Drawable;
@@ -115,6 +116,10 @@ class TvPipMenuEduTextDrawer extends FrameLayout {
scheduleLifecycleEvents();
}
int getEduTextDrawerHeight() {
return getVisibility() == GONE ? 0 : getHeight();
}
private void scheduleLifecycleEvents() {
final int startScrollDelay = mContext.getResources().getInteger(
R.integer.pip_edu_text_start_scroll_delay);
@@ -226,22 +231,42 @@ class TvPipMenuEduTextDrawer extends FrameLayout {
.start();
// Start animation to close the drawer by animating its height to 0
final ValueAnimator heightAnimation = ValueAnimator.ofInt(getHeight(), 0);
heightAnimation.setDuration(eduTextSlideExitAnimationDuration);
heightAnimation.setInterpolator(TvPipInterpolators.BROWSE);
heightAnimation.addUpdateListener(animator -> {
final ValueAnimator heightAnimator = ValueAnimator.ofInt(getHeight(), 0);
heightAnimator.setDuration(eduTextSlideExitAnimationDuration);
heightAnimator.setInterpolator(TvPipInterpolators.BROWSE);
heightAnimator.addUpdateListener(animator -> {
final ViewGroup.LayoutParams params = getLayoutParams();
params.height = (int) animator.getAnimatedValue();
setLayoutParams(params);
if (params.height == 0) {
setVisibility(GONE);
});
heightAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(@NonNull Animator animator) {
}
@Override
public void onAnimationEnd(@NonNull Animator animator) {
onCloseEduTextAnimationEnd();
}
@Override
public void onAnimationCancel(@NonNull Animator animator) {
onCloseEduTextAnimationEnd();
}
@Override
public void onAnimationRepeat(@NonNull Animator animator) {
}
});
heightAnimation.start();
heightAnimator.start();
mListener.onCloseEduText();
}
public void onCloseEduTextAnimationEnd() {
setVisibility(GONE);
}
/**
* Creates the educational text that will be displayed to the user. Here we replace the
* HOME annotation in the String with an icon

View File

@@ -262,7 +262,7 @@ public class TvPipMenuView extends FrameLayout implements TvPipActionsProvider.L
Rect getPipMenuContainerBounds(Rect pipBounds) {
final Rect menuUiBounds = new Rect(pipBounds);
menuUiBounds.inset(-mPipMenuOuterSpace, -mPipMenuOuterSpace);
menuUiBounds.bottom += mEduTextDrawer.getHeight();
menuUiBounds.bottom += mEduTextDrawer.getEduTextDrawerHeight();
return menuUiBounds;
}