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

Commit ef7e7d60 authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Update heights when QQS height changes

When the height of QQS changes (usually due to media changes), trigger a
callback in QuickSettingsControllerImpl to trigger update on the
heights.

With this, we don't need to react specially in the media visibility
callback.

Test: manual, add and remove media, observe notif stack
Test: atest QuickSettingsControllerImpl
Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Fixes: 409702452
Change-Id: I41f12d4082d0fea53a767b3bc7cb438650cd6797
parent 120da50d
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -205,6 +205,8 @@ public interface QS extends FragmentBase {

    default void setPanelExpanded(boolean panelExpanded) {}

    default void setQqsHeightListener(QqsHeightListener listener) {}

    /**
     * Callback for when QSPanel container is scrolled
     */
@@ -220,4 +222,10 @@ public interface QS extends FragmentBase {
        void onQsHeightChanged();
    }

    @ProvidesInterface(version = HeightListener.VERSION)
    interface QqsHeightListener {
        int VERSION = 1;
        void onQqsHeightChanged();
    }

}
+10 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ constructor(
    private val collapsedMediaVisibilityChangedListener =
        MutableStateFlow<(Consumer<Boolean>)?>(null)
    private val heightListener = MutableStateFlow<QS.HeightListener?>(null)
    private val qqsHeightListener = MutableStateFlow<QS.QqsHeightListener?>(null)
    private val qsContainerController = MutableStateFlow<QSContainerController?>(null)

    private lateinit var viewModel: QSFragmentComposeViewModel
@@ -406,6 +407,10 @@ constructor(
        heightListener.value = notificationPanelView
    }

    override fun setQqsHeightListener(listener: QS.QqsHeightListener?) {
        qqsHeightListener.value = listener
    }

    override fun hideImmediately() {
        //        view?.animate()?.cancel()
        //        view?.y = -qsMinExpansionHeight.toFloat()
@@ -616,9 +621,14 @@ constructor(
    private fun setListenerCollections() {
        lifecycleScope.launch {
            lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
                var lastQqsHeight = -1
                this@QSFragmentCompose.view?.setSnapshotBinding {
                    scrollListener.value?.onQsPanelScrollChanged(scrollState.value)
                    collapsedMediaVisibilityChangedListener.value?.accept(viewModel.qqsMediaVisible)
                    if (lastQqsHeight != viewModel.qqsHeight) {
                        lastQqsHeight = viewModel.qqsHeight
                        qqsHeightListener.value?.onQqsHeightChanged()
                    }
                }
                launch {
                    setListenerJob(
+10 −6
Original line number Diff line number Diff line
@@ -297,6 +297,13 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
    private FlingQsWithoutClickListener mFlingQsWithoutClickListener;
    private ExpansionHeightSetToMaxListener mExpansionHeightSetToMaxListener;
    private final QS.HeightListener mQsHeightListener = this::onHeightChanged;
    private final QS.QqsHeightListener mQqsHeightListener = new QS.QqsHeightListener() {
        @Override
        public void onQqsHeightChanged() {
            updateHeightsOnShadeLayoutChange();
            mPanelViewControllerLazy.get().positionClockAndNotifications();
        }
    };
    private final Runnable mQsCollapseExpandAction = this::collapseOrExpandQs;
    private final QS.ScrollListener mQsScrollListener = this::onScroll;

@@ -2177,7 +2184,6 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum

    /** */
    public final class QsFragmentListener implements FragmentHostManager.FragmentListener {
        private boolean mPreviouslyVisibleMedia = false;

        /** */
        @Override
@@ -2189,6 +2195,9 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
            mQs.setOverscrolling(mStackScrollerOverscrolling);
            mQs.setInSplitShade(mSplitShadeEnabled);
            mQs.setIsNotificationPanelFullWidth(mIsFullWidth);
            if (QSComposeFragment.isEnabled()) {
                mQs.setQqsHeightListener(mQqsHeightListener);
            }

            // recompute internal state when qspanel height changes
            mQs.getView().addOnLayoutChangeListener(
@@ -2204,12 +2213,7 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
                    setAnimateNextNotificationBounds(
                            StackStateAnimator.ANIMATION_DURATION_STANDARD, 0);
                    mNotificationStackScrollLayoutController.animateNextTopPaddingChange();
                    if (QSComposeFragment.isEnabled() && mPreviouslyVisibleMedia != visible) {
                        updateHeightsOnShadeLayoutChange();
                        mPanelViewControllerLazy.get().positionClockAndNotifications();
                    }
                }
                mPreviouslyVisibleMedia = visible;
            });
            mLockscreenShadeTransitionController.setQS(mQs);
            if (QSComposeFragment.isEnabled()) {