Merge "Improved the behavior with the empty shade view"

This commit is contained in:
Selim Cinek
2016-12-29 12:26:40 +00:00
committed by Android (Google) Code Review
3 changed files with 29 additions and 11 deletions

View File

@@ -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());
}

View File

@@ -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);
}

View File

@@ -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);
}