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

Commit 99259430 authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Automerger Merge Worker
Browse files

Merge "Clip UMO in overlay and animate FooterActions" into tm-dev am: e36790c5

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17224246

Change-Id: Ifbbe0dd3dcc6a0889627c3f70f29a0f2dc627996
parents c0f25021 e36790c5
Loading
Loading
Loading
Loading
+29 −3
Original line number Diff line number Diff line
@@ -98,6 +98,10 @@ class MediaHierarchyManager @Inject constructor(
    private var currentBounds = Rect()
    private var animationStartBounds: Rect = Rect()

    private var animationStartClipping = Rect()
    private var currentClipping = Rect()
    private var targetClipping = Rect()

    /**
     * The cross fade progress at the start of the animation. 0.5f means it's just switching between
     * the start and the end location and the content is fully faded, while 0.75f means that we're
@@ -144,7 +148,8 @@ class MediaHierarchyManager @Inject constructor(
            }
            interpolateBounds(animationStartBounds, targetBounds, boundsProgress,
                    result = currentBounds)
            applyState(currentBounds, currentAlpha)
            resolveClipping(currentClipping)
            applyState(currentBounds, currentAlpha, clipBounds = currentClipping)
        }
        addListener(object : AnimatorListenerAdapter() {
            private var cancelled: Boolean = false
@@ -169,6 +174,12 @@ class MediaHierarchyManager @Inject constructor(
        })
    }

    private fun resolveClipping(result: Rect) {
        if (animationStartClipping.isEmpty) result.set(targetClipping)
        else if (targetClipping.isEmpty) result.set(animationStartClipping)
        else result.setIntersect(animationStartClipping, targetClipping)
    }

    private val mediaHosts = arrayOfNulls<MediaHost>(LOCATION_DREAM_OVERLAY + 1)
    /**
     * The last location where this view was at before going to the desired location. This is
@@ -629,10 +640,12 @@ class MediaHierarchyManager @Inject constructor(
                // We also go in here in case the view was detached, since the bounds wouldn't
                // be correct anymore
                animationStartBounds.set(currentBounds)
                animationStartClipping.set(currentClipping)
            } else {
                // otherwise, let's take the freshest state, since the current one could
                // be outdated
                animationStartBounds.set(previousHost.currentBounds)
                animationStartClipping.set(previousHost.currentClipping)
            }
            val transformationType = calculateTransformationType()
            var needsCrossFade = transformationType == TRANSFORMATION_TYPE_FADE
@@ -745,7 +758,7 @@ class MediaHierarchyManager @Inject constructor(
            // Let's immediately apply the target state (which is interpolated) if there is
            // no animation running. Otherwise the animation update will already update
            // the location
            applyState(targetBounds, carouselAlpha)
            applyState(targetBounds, carouselAlpha, clipBounds = targetClipping)
        }
    }

@@ -769,9 +782,11 @@ class MediaHierarchyManager @Inject constructor(
            val newBounds = endHost.currentBounds
            val previousBounds = starthost.currentBounds
            targetBounds = interpolateBounds(previousBounds, newBounds, progress)
            targetClipping = endHost.currentClipping
        } else if (endHost != null) {
            val bounds = endHost.currentBounds
            targetBounds.set(bounds)
            targetClipping = endHost.currentClipping
        }
    }

@@ -879,8 +894,14 @@ class MediaHierarchyManager @Inject constructor(
    /**
     * Apply the current state to the view, updating it's bounds and desired state
     */
    private fun applyState(bounds: Rect, alpha: Float, immediately: Boolean = false) {
    private fun applyState(
        bounds: Rect,
        alpha: Float,
        immediately: Boolean = false,
        clipBounds: Rect = EMPTY_RECT
    ) {
        currentBounds.set(bounds)
        currentClipping = clipBounds
        carouselAlpha = if (isCurrentlyFading()) alpha else 1.0f
        val onlyUseEndState = !isCurrentlyInGuidedTransformation() || isCurrentlyFading()
        val startLocation = if (onlyUseEndState) -1 else previousLocation
@@ -889,6 +910,10 @@ class MediaHierarchyManager @Inject constructor(
        mediaCarouselController.setCurrentState(startLocation, endLocation, progress, immediately)
        updateHostAttachment()
        if (currentAttachmentLocation == IN_OVERLAY) {
            // Setting the clipping on the hierarchy of `mediaFrame` does not work
            if (!currentClipping.isEmpty) {
                currentBounds.intersect(currentClipping)
            }
            mediaFrame.setLeftTopRightBottom(
                    currentBounds.left,
                    currentBounds.top,
@@ -1113,6 +1138,7 @@ class MediaHierarchyManager @Inject constructor(
        const val TRANSFORMATION_TYPE_FADE = 1
    }
}
private val EMPTY_RECT = Rect()

@IntDef(prefix = ["TRANSFORMATION_TYPE_"], value = [
    MediaHierarchyManager.TRANSFORMATION_TYPE_TRANSITION,
+7 −0
Original line number Diff line number Diff line
@@ -55,6 +55,13 @@ class MediaHost constructor(
            return field
        }

    /**
     * Set the clipping that this host should use, based on its parent's bounds.
     *
     * Use [Rect.set].
     */
    val currentClipping = Rect()

    private val listener = object : MediaDataManager.Listener {
        override fun onMediaDataLoaded(
            key: String,
+1 −12
Original line number Diff line number Diff line
@@ -247,19 +247,8 @@ internal class FooterActionsController @Inject constructor(
    }

    fun setExpansion(headerExpansionFraction: Float) {
        if (featureFlags.isEnabled(Flags.NEW_FOOTER)) {
            if (headerExpansionFraction != lastExpansion) {
                if (headerExpansionFraction >= 1f) {
                    mView.animate().alpha(1f).setDuration(500L).start()
                } else if (lastExpansion >= 1f && headerExpansionFraction < 1f) {
                    mView.animate().alpha(0f).setDuration(250L).start()
                }
                lastExpansion = headerExpansionFraction
            }
        } else {
        alphaAnimator.setPosition(headerExpansionFraction)
    }
    }

    fun setKeyguardShowing(showing: Boolean) {
        setExpansion(lastExpansion)
+7 −3
Original line number Diff line number Diff line
@@ -139,13 +139,17 @@ public class QSContainerImpl extends FrameLayout implements Dumpable {
    }

    void updateResources(QSPanelController qsPanelController,
            QuickStatusBarHeaderController quickStatusBarHeaderController) {
            QuickStatusBarHeaderController quickStatusBarHeaderController,
            boolean newFooter) {
        int bottomPadding = 0;
        if (newFooter) {
            bottomPadding = getResources().getDimensionPixelSize(R.dimen.qs_panel_padding_bottom);
        }
        mQSPanelContainer.setPaddingRelative(
                mQSPanelContainer.getPaddingStart(),
                Utils.getQsHeaderSystemIconsAreaHeight(mContext),
                mQSPanelContainer.getPaddingEnd(),
                mQSPanelContainer.getPaddingBottom()
        );
                bottomPadding);

        int sideMargins = getResources().getDimensionPixelSize(R.dimen.notification_side_paddings);
        int padding = getResources().getDimensionPixelSize(
+8 −3
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.qs;

import android.content.res.Configuration;

import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.qs.dagger.QSScope;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.ViewController;
@@ -30,23 +32,26 @@ public class QSContainerImplController extends ViewController<QSContainerImpl> {
    private final QSPanelController mQsPanelController;
    private final QuickStatusBarHeaderController mQuickStatusBarHeaderController;
    private final ConfigurationController mConfigurationController;
    private final boolean mNewFooter;

    private final ConfigurationController.ConfigurationListener mConfigurationListener =
            new ConfigurationController.ConfigurationListener() {
        @Override
        public void onConfigChanged(Configuration newConfig) {
            mView.updateResources(mQsPanelController, mQuickStatusBarHeaderController);
            mView.updateResources(mQsPanelController, mQuickStatusBarHeaderController, mNewFooter);
        }
    };

    @Inject
    QSContainerImplController(QSContainerImpl view, QSPanelController qsPanelController,
            QuickStatusBarHeaderController quickStatusBarHeaderController,
            ConfigurationController configurationController) {
            ConfigurationController configurationController,
            FeatureFlags featureFlags) {
        super(view);
        mQsPanelController = qsPanelController;
        mQuickStatusBarHeaderController = quickStatusBarHeaderController;
        mConfigurationController = configurationController;
        mNewFooter = featureFlags.isEnabled(Flags.NEW_FOOTER);
    }

    @Override
@@ -60,7 +65,7 @@ public class QSContainerImplController extends ViewController<QSContainerImpl> {

    @Override
    protected void onViewAttached() {
        mView.updateResources(mQsPanelController, mQuickStatusBarHeaderController);
        mView.updateResources(mQsPanelController, mQuickStatusBarHeaderController, mNewFooter);
        mConfigurationController.addCallback(mConfigurationListener);
    }

Loading