Fixed the appearance of the shelf on the lockscreen

Previously the shelf algorithm wasn't applied properly
on the lockscreen.

Test: Add notifications, observe shelf on the lockscreen when collapsing
Bug: 32437839
Change-Id: I7c768e1450a86b5a8731c998ef58212550dfb4bc
This commit is contained in:
Selim Cinek
2016-10-18 17:09:15 -07:00
parent 281c202784
commit ad7fac0659
6 changed files with 54 additions and 28 deletions

View File

@@ -2196,10 +2196,11 @@ public abstract class BaseStatusBar extends SystemUI implements
int visibleNotifications = 0;
boolean onKeyguard = mState == StatusBarState.KEYGUARD;
int maxNotifications = 0;
int maxNotifications = -1;
if (onKeyguard) {
maxNotifications = getMaxKeyguardNotifications(true /* recompute */);
}
mStackScroller.setMaxDisplayedNotifications(maxNotifications);
for (int i = 0; i < N; i++) {
NotificationData.Entry entry = activeNotifications.get(i);
boolean childNotification = mGroupManager.isChildInGroupWithSummary(entry.notification);
@@ -2218,8 +2219,7 @@ public abstract class BaseStatusBar extends SystemUI implements
boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification);
if (suppressedSummary
|| (isLockscreenPublicMode(userId) && !mShowLockscreenNotifications)
|| (onKeyguard && !childWithVisibleSummary
&& (visibleNotifications >= maxNotifications || !showOnKeyguard))) {
|| (onKeyguard && !showOnKeyguard)) {
entry.row.setVisibility(View.GONE);
} else {
boolean wasGone = entry.row.getVisibility() == View.GONE;

View File

@@ -97,15 +97,23 @@ public abstract class ExpandableOutlineView extends ExpandableView {
if (mCustomOutline) {
return;
}
boolean hasOutline = true;
if (isChildInGroup()) {
hasOutline = isGroupExpanded() && !isGroupExpansionChanging();
} else if (isSummaryWithChildren()) {
hasOutline = !isGroupExpanded() || isGroupExpansionChanging();
}
boolean hasOutline = needsOutline();
setOutlineProvider(hasOutline ? mProvider : null);
}
/**
* @return whether the view currently needs an outline. This is usually false in case it doesn't
* have a background.
*/
protected boolean needsOutline() {
if (isChildInGroup()) {
return isGroupExpanded() && !isGroupExpansionChanging();
} else if (isSummaryWithChildren()) {
return !isGroupExpanded() || isGroupExpansionChanging();
}
return true;
}
public boolean isOutlineShowing() {
ViewOutlineProvider op = getOutlineProvider();
return op != null;

View File

@@ -112,10 +112,7 @@ public class NotificationShelf extends ActivatableNotificationView {
public void updateState(StackScrollState resultState,
StackScrollAlgorithm.StackScrollAlgorithmState algorithmState,
AmbientState ambientState) {
int shelfIndex = ambientState.getShelfIndex();
shelfIndex = shelfIndex == -1
? algorithmState.visibleChildren.size() - 1
: shelfIndex - 1;
int shelfIndex = ambientState.getShelfIndex() - 1;
if (shelfIndex != -1) {
float maxShelfEnd = ambientState.getInnerHeight() + ambientState.getTopPadding()
+ ambientState.getStackTranslation();
@@ -134,7 +131,7 @@ public class NotificationShelf extends ActivatableNotificationView {
mShelfState.isBottomClipped = false;
mShelfState.hideSensitive = false;
mShelfState.resetState();
mShelfState.resetIcons();
float numIconsInShelf = 0.0f;
float viewStart;
float maxShelfStart = maxShelfEnd - mShelfState.height;
@@ -240,6 +237,12 @@ public class NotificationShelf extends ActivatableNotificationView {
private void setHideBackground(boolean hideBackground) {
mHideBackground = hideBackground;
updateBackground();
updateOutline();
}
@Override
protected boolean needsOutline() {
return !mHideBackground && super.needsOutline();
}
@Override
@@ -258,7 +261,7 @@ public class NotificationShelf extends ActivatableNotificationView {
setHideBackground(hideBackground);
}
public void resetState() {
public void resetIcons() {
mNotificationIconContainer.resetViewStates(iconStates);
}
}

View File

@@ -2005,6 +2005,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
currentIndex++;
}
if (shelfIndex == -1) {
shelfIndex = currentIndex;
}
mStackScroller.updateShelfIndex(shelfIndex);
}

View File

@@ -354,6 +354,7 @@ public class NotificationStackScrollLayout extends ViewGroup
private boolean mForwardScrollable;
private boolean mBackwardScrollable;
private NotificationShelf mShelf;
private int mMaxDisplayedNotifications = -1;
public NotificationStackScrollLayout(Context context) {
this(context, null);
@@ -533,8 +534,7 @@ public class NotificationStackScrollLayout extends ViewGroup
public void updateShelfIndex(int newIndex) {
mAmbientState.setShelfIndex(newIndex);
int iconIndex = newIndex == -1 ? getChildCount() - 3 : newIndex;
changeViewPosition(mShelf, iconIndex);
changeViewPosition(mShelf, newIndex);
}
public void setChildLocationsChangedListener(OnChildLocationsChangedListener listener) {
@@ -1847,10 +1847,17 @@ public class NotificationStackScrollLayout extends ViewGroup
private void updateContentHeight() {
int height = 0;
float previousIncreasedAmount = 0.0f;
int numShownItems = 0;
boolean finish = false;
for (int i = 0; i < getChildCount(); i++) {
ExpandableView expandableView = (ExpandableView) getChildAt(i);
if (expandableView.getVisibility() != View.GONE
&& !expandableView.hasNoContentHeight()) {
if (mMaxDisplayedNotifications != -1
&& numShownItems >= mMaxDisplayedNotifications) {
expandableView = mShelf;
finish = true;
}
float increasedPaddingAmount = expandableView.getIncreasedPaddingAmount();
if (height != 0) {
height += (int) NotificationUtils.interpolate(
@@ -1860,6 +1867,10 @@ public class NotificationStackScrollLayout extends ViewGroup
}
previousIncreasedAmount = increasedPaddingAmount;
height += expandableView.getIntrinsicHeight();
numShownItems++;
if (finish) {
break;
}
}
}
mContentHeight = height + mTopPadding;
@@ -3083,16 +3094,10 @@ public class NotificationStackScrollLayout extends ViewGroup
}
public int getEmptyBottomMargin() {
int emptyMargin = mMaxLayoutHeight - mContentHeight - mBottomStackPeekSize
- mBottomStackSlowDownHeight;
int emptyMargin = mMaxLayoutHeight - mContentHeight;
return Math.max(emptyMargin, 0);
}
public float getKeyguardBottomStackSize() {
return mBottomStackPeekSize + getResources().getDimensionPixelSize(
R.dimen.bottom_stack_slow_down_length);
}
public void onExpansionStarted() {
mIsExpansionChanging = true;
}
@@ -3756,7 +3761,7 @@ public class NotificationStackScrollLayout extends ViewGroup
// fall through
case android.R.id.accessibilityActionScrollUp:
final int viewportHeight = getHeight() - mPaddingBottom - mTopPadding - mPaddingTop
- mBottomStackPeekSize - mBottomStackSlowDownHeight;
- mShelf.getIntrinsicHeight();
final int targetScrollY = Math.max(0,
Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange()));
if (targetScrollY != mOwnScrollY) {
@@ -3925,6 +3930,14 @@ public class NotificationStackScrollLayout extends ViewGroup
return mShelf;
}
public void setMaxDisplayedNotifications(int maxDisplayedNotifications) {
if (mMaxDisplayedNotifications != maxDisplayedNotifications) {
mMaxDisplayedNotifications = maxDisplayedNotifications;
updateContentHeight();
notifyHeightChangeListener(mShelf);
}
}
/**
* A listener that is notified when some child locations might have changed.
*/

View File

@@ -129,7 +129,7 @@ public class StackScrollAlgorithm {
// The speed bump can also be gone, so equality needs to be taken when comparing
// indices.
childViewState.belowShelf = shelfIndex != -1 && i >= shelfIndex;
childViewState.belowShelf = i >= shelfIndex;
}
NotificationShelf shelf = ambientState.getShelf();
shelf.updateState(resultState, algorithmState, ambientState);
@@ -347,8 +347,7 @@ public class StackScrollAlgorithm {
if (i == 0) {
updateFirstChildHeight(child, childViewState, childHeight, ambientState);
}
int shelfIndex = ambientState.getShelfIndex();
boolean belowShelf = shelfIndex != -1 && i >= shelfIndex;
boolean belowShelf = i >= ambientState.getShelfIndex();
// The y position after this element
float nextYPosition = currentYPosition + childHeight +