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

Commit 2e3d6bce authored by Christian Göllner's avatar Christian Göllner Committed by Automerger Merge Worker
Browse files

Merge "Center EmptyShadeView vertically and horizontally." into sc-v2-dev am:...

Merge "Center EmptyShadeView vertically and horizontally." into sc-v2-dev am: 910a49a9 am: 668c88f8

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

Change-Id: If11d9215d726192a14efcd26d22c33fede98cbd5
parents 4e43e66a 668c88f8
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -26,8 +26,7 @@
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="64dp"
            android:paddingTop="12dp"
            android:textAppearance="?android:attr/textAppearanceButton"
            android:gravity="top|center_horizontal"
            android:gravity="center"
            android:text="@string/empty_shade_text"/>
</com.android.systemui.statusbar.EmptyShadeView>
+9 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ public class AmbientState {
    private float mMaxHeadsUpTranslation;
    private boolean mDismissAllInProgress;
    private int mLayoutMinHeight;
    private int mLayoutMaxHeight;
    private NotificationShelf mShelf;
    private int mZDistanceBetweenElements;
    private int mBaseZHeight;
@@ -326,6 +327,14 @@ public class AmbientState {
        mLayoutHeight = layoutHeight;
    }

    public void setLayoutMaxHeight(int maxLayoutHeight) {
        mLayoutMaxHeight = maxLayoutHeight;
    }

    public int getLayoutMaxHeight() {
        return mLayoutMaxHeight;
    }

    public float getTopPadding() {
        return mTopPadding;
    }
+1 −0
Original line number Diff line number Diff line
@@ -1111,6 +1111,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM)
    private void updateAlgorithmHeightAndPadding() {
        mAmbientState.setLayoutHeight(getLayoutHeight());
        mAmbientState.setLayoutMaxHeight(mMaxLayoutHeight);
        updateAlgorithmLayoutMinHeight();
        mAmbientState.setTopPadding(mTopPadding);
    }
+9 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.R;
import com.android.systemui.animation.ShadeInterpolation;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
@@ -60,6 +61,7 @@ public class StackScrollAlgorithm {
    @VisibleForTesting float mHeadsUpInset;
    private int mPinnedZTranslationExtra;
    private float mNotificationScrimPadding;
    private int mCloseHandleUnderlapHeight;

    public StackScrollAlgorithm(
            Context context,
@@ -85,6 +87,7 @@ public class StackScrollAlgorithm {
                R.dimen.heads_up_pinned_elevation);
        mGapHeight = res.getDimensionPixelSize(R.dimen.notification_section_divider_height);
        mNotificationScrimPadding = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
        mCloseHandleUnderlapHeight = res.getDimensionPixelSize(R.dimen.close_handle_underlap);
    }

    /**
@@ -459,7 +462,11 @@ public class StackScrollAlgorithm {
                                && !hasOngoingNotifs(algorithmState));
            }
        } else {
            if (view != ambientState.getTrackedHeadsUpRow()) {
            if (view instanceof EmptyShadeView) {
                float fullHeight = ambientState.getLayoutMaxHeight() + mCloseHandleUnderlapHeight
                        - ambientState.getStackY();
                viewState.yTranslation = (fullHeight - getMaxAllowedChildHeight(view)) / 2f;
            } else if (view != ambientState.getTrackedHeadsUpRow()) {
                if (ambientState.isExpansionChanging()) {
                    // We later update shelf state, then hide views below the shelf.
                    viewState.hidden = false;
+22 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import android.widget.FrameLayout
import androidx.test.filters.SmallTest
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.EmptyShadeView
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.BypassController
import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.SectionProvider
@@ -55,4 +56,24 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
        // top margin presence should decrease heads up translation up to minHeadsUpTranslation
        assertThat(expandableViewState.yTranslation).isEqualTo(minHeadsUpTranslation)
    }

    @Test
    fun resetViewStates_childIsEmptyShadeView_viewIsCenteredVertically() {
        stackScrollAlgorithm.initView(context)
        val emptyShadeView = EmptyShadeView(context, /* attrs= */ null).apply {
            layout(/* l= */ 0, /* t= */ 0, /* r= */ 100, /* b= */ 100)
        }
        hostView.removeAllViews()
        hostView.addView(emptyShadeView)
        ambientState.layoutMaxHeight = 1280

        stackScrollAlgorithm.resetViewStates(ambientState, /* speedBumpIndex= */ 0)

        val closeHandleUnderlapHeight =
            context.resources.getDimensionPixelSize(R.dimen.close_handle_underlap)
        val fullHeight =
            ambientState.layoutMaxHeight + closeHandleUnderlapHeight - ambientState.stackY
        val centeredY = ambientState.stackY + fullHeight / 2f - emptyShadeView.height / 2f
        assertThat(emptyShadeView.viewState?.yTranslation).isEqualTo(centeredY)
    }
}