Loading packages/SystemUI/res/layout/status_bar_no_notifications.xml +1 −2 Original line number Diff line number Diff line Loading @@ -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> packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java +9 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +1 −0 Original line number Diff line number Diff line Loading @@ -1110,6 +1110,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); } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +9 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -60,6 +61,7 @@ public class StackScrollAlgorithm { @VisibleForTesting float mHeadsUpInset; private int mPinnedZTranslationExtra; private float mNotificationScrimPadding; private int mCloseHandleUnderlapHeight; public StackScrollAlgorithm( Context context, Loading @@ -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); } /** Loading Loading @@ -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; Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt +22 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) } } Loading
packages/SystemUI/res/layout/status_bar_no_notifications.xml +1 −2 Original line number Diff line number Diff line Loading @@ -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>
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java +9 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +1 −0 Original line number Diff line number Diff line Loading @@ -1110,6 +1110,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); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +9 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -60,6 +61,7 @@ public class StackScrollAlgorithm { @VisibleForTesting float mHeadsUpInset; private int mPinnedZTranslationExtra; private float mNotificationScrimPadding; private int mCloseHandleUnderlapHeight; public StackScrollAlgorithm( Context context, Loading @@ -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); } /** Loading Loading @@ -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; Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt +22 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) } }