Fixed a bug where group expansion size calculation was wrong

On the lockscreen, the minheight was always based on the intrinsic
height and not actually the minHeight of the children. Because
children were userlocked, they were now reporting their small size
instead of the single line size.
This meant that the expand motion on the lockscreen wasn't following
the finger at all.

Bug: 27418617
Change-Id: I81daaf87887de1adc014cb4c6d46f4ef118061e5
This commit is contained in:
Selim Cinek
2016-02-29 16:14:25 -08:00
parent d1bb54b80e
commit 2c58461daf
3 changed files with 31 additions and 9 deletions

View File

@@ -169,21 +169,23 @@ public class DragDownHelper implements Gefingerpoken {
? RUBBERBAND_FACTOR_EXPANDABLE ? RUBBERBAND_FACTOR_EXPANDABLE
: RUBBERBAND_FACTOR_STATIC; : RUBBERBAND_FACTOR_STATIC;
float rubberband = heightDelta * rubberbandFactor; float rubberband = heightDelta * rubberbandFactor;
if (expandable && (rubberband + child.getMinHeight()) > child.getMaxContentHeight()) { if (expandable
float overshoot = (rubberband + child.getMinHeight()) - child.getMaxContentHeight(); && (rubberband + child.getMinExpandHeight()) > child.getMaxContentHeight()) {
float overshoot =
(rubberband + child.getMinExpandHeight()) - child.getMaxContentHeight();
overshoot *= (1 - RUBBERBAND_FACTOR_STATIC); overshoot *= (1 - RUBBERBAND_FACTOR_STATIC);
rubberband -= overshoot; rubberband -= overshoot;
} }
child.setActualHeight((int) (child.getMinHeight() + rubberband)); child.setActualHeight((int) (child.getMinExpandHeight() + rubberband));
} }
private void cancelExpansion(final ExpandableView child) { private void cancelExpansion(final ExpandableView child) {
if (child.getActualHeight() == child.getMinHeight()) { if (child.getActualHeight() == child.getMinExpandHeight()) {
mCallback.setUserLockedChild(child, false); mCallback.setUserLockedChild(child, false);
return; return;
} }
ObjectAnimator anim = ObjectAnimator.ofInt(child, "actualHeight", ObjectAnimator anim = ObjectAnimator.ofInt(child, "actualHeight",
child.getActualHeight(), child.getMinHeight()); child.getActualHeight(), child.getMinExpandHeight());
anim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); anim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
anim.setDuration(SPRING_BACK_ANIMATION_LENGTH_MS); anim.setDuration(SPRING_BACK_ANIMATION_LENGTH_MS);
anim.addListener(new AnimatorListenerAdapter() { anim.addListener(new AnimatorListenerAdapter() {

View File

@@ -1221,8 +1221,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
@Override @Override
public int getMinExpandHeight() { public int getMinExpandHeight() {
if (mIsSummaryWithChildren && !mOnKeyguard) { if (mIsSummaryWithChildren && !mShowingPublic) {
return mChildrenContainer.getMinExpandHeight(); return mChildrenContainer.getMinExpandHeight(mOnKeyguard);
} }
return getMinHeight(); return getMinHeight();
} }

View File

@@ -566,8 +566,28 @@ public class NotificationChildrenContainer extends ViewGroup {
return getIntrinsicHeight(NUMBER_OF_CHILDREN_WHEN_COLLAPSED); return getIntrinsicHeight(NUMBER_OF_CHILDREN_WHEN_COLLAPSED);
} }
public int getMinExpandHeight() { public int getMinExpandHeight(boolean onKeyguard) {
return getIntrinsicHeight(getMaxAllowedVisibleChildren(true /* forceCollapsed */)); int maxAllowedVisibleChildren = onKeyguard ? NUMBER_OF_CHILDREN_WHEN_COLLAPSED
: getMaxAllowedVisibleChildren(true /* forceCollapsed */);
int minExpandHeight = mNotificationHeaderHeight;
int visibleChildren = 0;
boolean firstChild = true;
int childCount = mChildren.size();
for (int i = 0; i < childCount; i++) {
if (visibleChildren >= maxAllowedVisibleChildren) {
break;
}
if (!firstChild) {
minExpandHeight += mChildPadding;
} else {
firstChild = false;
}
ExpandableNotificationRow child = mChildren.get(i);
minExpandHeight += child.getMinHeight();
visibleChildren++;
}
minExpandHeight += mCollapsedBottompadding;
return minExpandHeight;
} }
public void setDark(boolean dark, boolean fade, long delay) { public void setDark(boolean dark, boolean fade, long delay) {