Merge "Center EmptyShadeView vertically and horizontally." into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
910a49a936
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,13 +462,17 @@ 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;
|
||||
viewState.inShelf = algorithmState.firstViewInShelf != null
|
||||
&& i >= algorithmState.visibleChildren.indexOf(
|
||||
algorithmState.firstViewInShelf);
|
||||
algorithmState.firstViewInShelf);
|
||||
} else if (ambientState.getShelf() != null) {
|
||||
// When pulsing (incoming notification on AOD), innerHeight is 0; clamp all
|
||||
// to shelf start, thereby hiding all notifications (except the first one, which
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user