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

Commit cae18cfd authored by Matt Pietal's avatar Matt Pietal Committed by Automerger Merge Worker
Browse files

Merge "Controls UI - Global actions enter/exit animations" into rvc-dev am:...

Merge "Controls UI - Global actions enter/exit animations" into rvc-dev am: 7405357b am: 7b32a595

Change-Id: Ib15af1335ec24f9ec2d16444823d71da668f6cf7
parents 40d9b35d 7b32a595
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -31,6 +31,13 @@ interface ControlsUiController {

    fun show(parent: ViewGroup, dismissGlobalActions: Runnable)
    fun hide()

    /**
     * Request all open dialogs be closed. Set [immediately] to true to dismiss without
     * animations.
     */
    fun closeDialogs(immediately: Boolean)

    fun onRefreshState(componentName: ComponentName, controls: List<Control>)
    fun onActionResponse(
        componentName: ComponentName,
+13 −4
Original line number Diff line number Diff line
@@ -503,15 +503,24 @@ class ControlsUiControllerImpl @Inject constructor (
        }
    }

    override fun hide() {
        Log.d(ControlsUiController.TAG, "hide()")
        hidden = true
    override fun closeDialogs(immediately: Boolean) {
        if (immediately) {
            popup?.dismissImmediate()
        } else {
            popup?.dismiss()
        }
        popup = null

        controlViewsById.forEach {
            it.value.dismiss()
        }
        controlActionCoordinator.closeDialogs()
    }

    override fun hide() {
        hidden = true

        closeDialogs(true)
        controlsController.get().unsubscribe()

        parent.removeAllViews()
+59 −35
Original line number Diff line number Diff line
@@ -23,6 +23,10 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOM
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.Dialog;
@@ -2174,24 +2178,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
            mShowing = true;
            mHadTopUi = mNotificationShadeWindowController.getForceHasTopUi();
            mNotificationShadeWindowController.setForceHasTopUi(true);
            mBackgroundDrawable.setAlpha(0);
            mContainer.setTranslationX(mGlobalActionsLayout.getAnimationOffsetX());
            mContainer.setTranslationY(mGlobalActionsLayout.getAnimationOffsetY());
            mContainer.setAlpha(0);
            mContainer.animate()
                    .alpha(1)
                    .translationX(0)
                    .translationY(0)
                    .setDuration(450)
                    .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
                    .setUpdateListener(animation -> {
                        float animatedValue = animation.getAnimatedFraction();
                        int alpha = (int) (animatedValue * mScrimAlpha * 255);
                        mBackgroundDrawable.setAlpha(alpha);
                        mDepthController.updateGlobalDialogVisibility(animatedValue,
                                mGlobalActionsLayout);
                    })
                    .start();

            ViewGroup root = (ViewGroup) mGlobalActionsLayout.getRootView();
            root.setOnApplyWindowInsetsListener((v, windowInsets) -> {
                if (mUseControlsLayout) {
@@ -2205,29 +2192,66 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
            if (mControlsUiController != null) {
                mControlsUiController.show(mControlsView, this::dismissForControlsActivity);
            }

            mBackgroundDrawable.setAlpha(0);
            float xOffset = mGlobalActionsLayout.getAnimationOffsetX();
            ObjectAnimator alphaAnimator =
                    ObjectAnimator.ofFloat(mContainer, "transitionAlpha", 0f, 1f);
            alphaAnimator.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN);
            alphaAnimator.setDuration(183);
            alphaAnimator.addUpdateListener((animation) -> {
                float animatedValue = animation.getAnimatedFraction();
                int alpha = (int) (animatedValue * mScrimAlpha * 255);
                mBackgroundDrawable.setAlpha(alpha);
                mDepthController.updateGlobalDialogVisibility(animatedValue,
                        mGlobalActionsLayout);
            });

            ObjectAnimator xAnimator =
                    ObjectAnimator.ofFloat(mContainer, "translationX", xOffset, 0f);
            alphaAnimator.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN);
            alphaAnimator.setDuration(350);

            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(alphaAnimator, xAnimator);
            animatorSet.start();
        }

        @Override
        public void dismiss() {
            dismissWithAnimation(() -> {
                mContainer.setTranslationX(0);
                mContainer.setTranslationY(0);
                mContainer.setAlpha(1);
                mContainer.animate()
                        .alpha(0)
                        .translationX(mGlobalActionsLayout.getAnimationOffsetX())
                        .translationY(mGlobalActionsLayout.getAnimationOffsetY())
                        .setDuration(450)
                        .withEndAction(this::completeDismiss)
                        .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
                        .setUpdateListener(animation -> {
                ObjectAnimator alphaAnimator =
                        ObjectAnimator.ofFloat(mContainer, "transitionAlpha", 1f, 0f);
                alphaAnimator.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
                alphaAnimator.setDuration(233);
                alphaAnimator.addUpdateListener((animation) -> {
                    float animatedValue = 1f - animation.getAnimatedFraction();
                    int alpha = (int) (animatedValue * mScrimAlpha * 255);
                    mBackgroundDrawable.setAlpha(alpha);
                    mDepthController.updateGlobalDialogVisibility(animatedValue,
                            mGlobalActionsLayout);
                        })
                        .start();
                });

                float xOffset = mGlobalActionsLayout.getAnimationOffsetX();
                ObjectAnimator xAnimator =
                        ObjectAnimator.ofFloat(mContainer, "translationX", 0f, xOffset);
                alphaAnimator.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
                alphaAnimator.setDuration(350);

                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.playTogether(alphaAnimator, xAnimator);
                animatorSet.addListener(new AnimatorListenerAdapter() {
                    public void onAnimationEnd(Animator animation) {
                        completeDismiss();
                    }
                });

                animatorSet.start();

                // close first, as popup windows will not fade during the animation
                dismissOverflow(false);
                if (mControlsUiController != null) mControlsUiController.closeDialogs(false);
            });
        }

+2 −2
Original line number Diff line number Diff line
@@ -90,11 +90,11 @@ public class GlobalActionsFlatLayout extends GlobalActionsLayout {

    @Override
    public float getAnimationOffsetX() {
        return 0;
        return getAnimationDistance();
    }

    @Override
    public float getAnimationOffsetY() {
        return -getAnimationDistance();
        return 0f;
    }
}