From cde90e504ea57f8129fb70d0f8418483136b3527 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Thu, 22 Dec 2016 21:01:49 +0100 Subject: [PATCH] Improved the behavior with the empty shade view The empty shade view is now properly appearing Test: expand panel without notifications, observe smooth transitions Bug: 33652489 Change-Id: Idedb79121434b974ff221eefd4417c40b100a317 --- .../systemui/statusbar/EmptyShadeView.java | 14 ++++++++++--- .../stack/NotificationStackScrollLayout.java | 20 +++++++++++-------- .../statusbar/stack/StackScrollAlgorithm.java | 6 ++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/EmptyShadeView.java b/packages/SystemUI/src/com/android/systemui/statusbar/EmptyShadeView.java index 19b32af8b9197..92b0890a5d2bc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/EmptyShadeView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/EmptyShadeView.java @@ -28,6 +28,8 @@ import com.android.systemui.statusbar.stack.StackScrollState; public class EmptyShadeView extends StackScrollerDecorView { + private TextView mEmptyText; + public EmptyShadeView(Context context, AttributeSet attrs) { super(context, attrs); } @@ -35,7 +37,7 @@ public class EmptyShadeView extends StackScrollerDecorView { @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); - ((TextView) findViewById(R.id.no_notifications)).setText(R.string.empty_shade_text); + mEmptyText.setText(R.string.empty_shade_text); } @Override @@ -43,18 +45,24 @@ public class EmptyShadeView extends StackScrollerDecorView { return findViewById(R.id.no_notifications); } + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + mEmptyText = (TextView) findContentView(); + } + @Override public ExpandableViewState createNewViewState(StackScrollState stackScrollState) { return new EmptyShadeViewState(); } - public static class EmptyShadeViewState extends ExpandableViewState { + public class EmptyShadeViewState extends ExpandableViewState { @Override public void applyToView(View view) { super.applyToView(view); if (view instanceof EmptyShadeView) { EmptyShadeView emptyShadeView = (EmptyShadeView) view; - boolean visible = this.clipTopAmount <= 0; + boolean visible = this.clipTopAmount <= mEmptyText.getPaddingTop() * 0.6f; emptyShadeView.performVisibilityAnimation( visible && !emptyShadeView.willBeGone()); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 1e9c838ecc267..e7c2507dbf187 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -768,15 +768,19 @@ public class NotificationStackScrollLayout extends ViewGroup */ private float getAppearEndPosition() { int appearPosition; - int minNotificationsForShelf = 1; - if (mTrackingHeadsUp || mHeadsUpManager.hasPinnedHeadsUp()) { - appearPosition = mHeadsUpManager.getTopHeadsUpPinnedHeight(); - minNotificationsForShelf = 2; + if (mEmptyShadeView.getVisibility() == GONE) { + int minNotificationsForShelf = 1; + if (mTrackingHeadsUp || mHeadsUpManager.hasPinnedHeadsUp()) { + appearPosition = mHeadsUpManager.getTopHeadsUpPinnedHeight(); + minNotificationsForShelf = 2; + } else { + appearPosition = 0; + } + if (getNotGoneChildCount() >= minNotificationsForShelf) { + appearPosition += mShelf.getIntrinsicHeight(); + } } else { - appearPosition = 0; - } - if (getNotGoneChildCount() >= minNotificationsForShelf) { - appearPosition += mShelf.getIntrinsicHeight(); + appearPosition = mEmptyShadeView.getHeight(); } return appearPosition + (onKeyguard() ? mTopPadding : mIntrinsicPadding); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java index 50b6d70f437c2..7ff100081677f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java @@ -23,9 +23,11 @@ import android.view.ViewGroup; import com.android.systemui.R; import com.android.systemui.statusbar.DismissView; +import com.android.systemui.statusbar.EmptyShadeView; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.ExpandableView; import com.android.systemui.statusbar.NotificationShelf; +import com.android.systemui.statusbar.StackScrollerDecorView; import com.android.systemui.statusbar.notification.NotificationUtils; import java.util.ArrayList; @@ -324,11 +326,15 @@ public class StackScrollAlgorithm { int childHeight = getMaxAllowedChildHeight(child); childViewState.yTranslation = currentYPosition; boolean isDismissView = child instanceof DismissView; + boolean isEmptyShadeView = child instanceof EmptyShadeView; childViewState.location = ExpandableViewState.LOCATION_MAIN_AREA; if (isDismissView) { childViewState.yTranslation = Math.min(childViewState.yTranslation, ambientState.getInnerHeight() - childHeight); + } else if (isEmptyShadeView) { + childViewState.yTranslation = ambientState.getInnerHeight() - childHeight + + ambientState.getStackTranslation() * 0.25f; } else { clampPositionToShelf(childViewState, ambientState); }