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

Commit 3aed78db authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Fix bottom margin of footer actions" into tm-dev

parents 151849de 971e7cc3
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
package com.android.systemui.statusbar.phone

import android.view.WindowInsets
import com.android.systemui.R
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.navigationbar.NavigationModeController
@@ -41,6 +42,7 @@ class NotificationsQSContainerController @Inject constructor(
    private var isQSCustomizerAnimating = false

    private var notificationsBottomMargin = 0
    private var scrimShadeBottomMargin = 0
    private var bottomStableInsets = 0
    private var bottomCutoutInsets = 0

@@ -67,17 +69,36 @@ class NotificationsQSContainerController @Inject constructor(

    public override fun onViewAttached() {
        updateMargins()
        updateResources()
        overviewProxyService.addCallback(taskbarVisibilityListener)
        mView.setInsetsChangedListener(windowInsetsListener)
        mView.setQSFragmentAttachedListener { qs: QS -> qs.setContainerController(this) }
        mView.setConfigurationChangedListener { updateResources() }
    }

    override fun onViewDetached() {
        overviewProxyService.removeCallback(taskbarVisibilityListener)
        mView.removeOnInsetsChangedListener()
        mView.removeQSFragmentAttachedListener()
        mView.setConfigurationChangedListener(null)
    }

    private fun updateResources() {
        val previousScrimShadeBottomMargin = scrimShadeBottomMargin
        scrimShadeBottomMargin = resources.getDimensionPixelSize(
            R.dimen.split_shade_notifications_scrim_margin_bottom
        )

        if (previousScrimShadeBottomMargin != scrimShadeBottomMargin) {
            updateBottomSpacing()
        }
    }

    /**
     * Update the notification bottom margin.
     *
     * Will not call updateBottomSpacing
     */
    fun updateMargins() {
        notificationsBottomMargin = mView.defaultNotificationsMarginBottom
    }
@@ -111,7 +132,11 @@ class NotificationsQSContainerController @Inject constructor(
            qsScrollPaddingBottom = bottomStableInsets
        } else if (newFooter && !(isQSCustomizing || isQSDetailShowing)) {
            // With the new footer, we also want this padding in the bottom in these cases
            qsScrollPaddingBottom = bottomStableInsets
            qsScrollPaddingBottom = if (splitShadeEnabled) {
                notificationsMargin - scrimShadeBottomMargin
            } else {
                bottomStableInsets
            }
        }
        mView.setPadding(0, 0, 0, containerPadding)
        mView.setNotificationsMarginBottom(notificationsMargin)
+17 −0
Original line number Diff line number Diff line
@@ -18,11 +18,13 @@ package com.android.systemui.statusbar.phone;

import android.app.Fragment;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;
import android.view.WindowInsets;

import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.android.systemui.R;
@@ -54,6 +56,9 @@ public class NotificationsQuickSettingsContainer extends ConstraintLayout
    private View mQSScrollView;
    private View mQSContainer;

    @Nullable
    private Consumer<Configuration> mConfigurationChangedListener;

    public NotificationsQuickSettingsContainer(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
@@ -79,6 +84,18 @@ public class NotificationsQuickSettingsContainer extends ConstraintLayout
        invalidate();
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (mConfigurationChangedListener != null) {
            mConfigurationChangedListener.accept(newConfig);
        }
    }

    public void setConfigurationChangedListener(Consumer<Configuration> listener) {
        mConfigurationChangedListener = listener;
    }

    public void setNotificationsMarginBottom(int margin) {
        LayoutParams params = (LayoutParams) mStackScroller.getLayoutParams();
        params.bottomMargin = margin;
+16 −6
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import android.testing.TestableLooper
import android.view.WindowInsets
import android.view.WindowManagerPolicyConstants
import androidx.test.filters.SmallTest
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
@@ -40,6 +41,7 @@ class NotificationQSContainerControllerTest : SysuiTestCase() {
        const val GESTURES_NAVIGATION = WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL
        const val BUTTONS_NAVIGATION = WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON
        const val NOTIFICATIONS_MARGIN = 50
        const val SCRIM_MARGIN = 10
    }

    @Mock
@@ -65,12 +67,18 @@ class NotificationQSContainerControllerTest : SysuiTestCase() {
    @Before
    fun setup() {
        MockitoAnnotations.initMocks(this)
        mContext.ensureTestableResources()
        whenever(notificationsQSContainer.resources).thenReturn(mContext.resources)
        notificationsQSContainerController = NotificationsQSContainerController(
                notificationsQSContainer,
                navigationModeController,
                overviewProxyService,
                featureFlags
        )

        mContext.orCreateTestableResources
            .addOverride(R.dimen.split_shade_notifications_scrim_margin_bottom, SCRIM_MARGIN)

        whenever(notificationsQSContainer.defaultNotificationsMarginBottom)
                .thenReturn(NOTIFICATIONS_MARGIN)
        whenever(navigationModeController.addListener(navigationModeCaptor.capture()))
@@ -115,14 +123,14 @@ class NotificationQSContainerControllerTest : SysuiTestCase() {
                insets = windowInsets().withStableBottom())
        then(expectedContainerPadding = 0, // taskbar should disappear when shade is expanded
                expectedNotificationsMargin = NOTIFICATIONS_MARGIN,
                expectedQsPadding = STABLE_INSET_BOTTOM)
                expectedQsPadding = NOTIFICATIONS_MARGIN - SCRIM_MARGIN)

        given(taskbarVisible = true,
                navigationMode = BUTTONS_NAVIGATION,
                insets = windowInsets().withStableBottom())
        then(expectedContainerPadding = STABLE_INSET_BOTTOM,
                expectedNotificationsMargin = NOTIFICATIONS_MARGIN,
                expectedQsPadding = STABLE_INSET_BOTTOM)
                expectedQsPadding = NOTIFICATIONS_MARGIN - SCRIM_MARGIN)
    }

    @Test
@@ -153,14 +161,14 @@ class NotificationQSContainerControllerTest : SysuiTestCase() {
                navigationMode = GESTURES_NAVIGATION,
                insets = windowInsets().withStableBottom())
        then(expectedContainerPadding = 0,
                expectedQsPadding = STABLE_INSET_BOTTOM)
                expectedQsPadding = NOTIFICATIONS_MARGIN - SCRIM_MARGIN)

        given(taskbarVisible = false,
                navigationMode = BUTTONS_NAVIGATION,
                insets = windowInsets().withStableBottom())
        then(expectedContainerPadding = 0, // qs goes full height as it's not obscuring nav buttons
                expectedNotificationsMargin = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN,
                expectedQsPadding = STABLE_INSET_BOTTOM)
                expectedQsPadding = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN - SCRIM_MARGIN)
    }

    @Test
@@ -188,14 +196,15 @@ class NotificationQSContainerControllerTest : SysuiTestCase() {
        given(taskbarVisible = false,
                navigationMode = GESTURES_NAVIGATION,
                insets = windowInsets().withCutout())
        then(expectedContainerPadding = CUTOUT_HEIGHT)
        then(expectedContainerPadding = CUTOUT_HEIGHT,
            expectedQsPadding = NOTIFICATIONS_MARGIN - SCRIM_MARGIN)

        given(taskbarVisible = false,
                navigationMode = BUTTONS_NAVIGATION,
                insets = windowInsets().withCutout().withStableBottom())
        then(expectedContainerPadding = 0,
                expectedNotificationsMargin = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN,
                expectedQsPadding = STABLE_INSET_BOTTOM)
                expectedQsPadding = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN - SCRIM_MARGIN)
    }

    @Test
@@ -392,6 +401,7 @@ class NotificationQSContainerControllerTest : SysuiTestCase() {

    @Test
    fun testNotificationsMarginBottomIsUpdated() {
        Mockito.clearInvocations(notificationsQSContainer)
        notificationsQSContainerController.splitShadeEnabled = true
        verify(notificationsQSContainer).setNotificationsMarginBottom(NOTIFICATIONS_MARGIN)