Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c96cb2c authored by Galia Peycheva's avatar Galia Peycheva Committed by Automerger Merge Worker
Browse files

Merge "Fix tv edu text drawer not closing completely" into udc-dev am: 17c8bbca am: 2a288c7e

parents a4fbc783 2a288c7e
Loading
Loading
Loading
Loading
+32 −7
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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;
    }