diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuEduTextDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuEduTextDrawer.java index 6eef22562caa6..dca246b566ffe 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuEduTextDrawer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuEduTextDrawer.java @@ -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 diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java index 6eb719ba60a36..235d07b56b7ff 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipMenuView.java @@ -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; }