Merge "Fixed a bug where the notification content could become empty" into nyc-dev

This commit is contained in:
Selim Cinek
2016-03-03 22:32:07 +00:00
committed by Android (Google) Code Review
4 changed files with 37 additions and 70 deletions

View File

@@ -105,7 +105,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
private boolean mClearable;
private ExpansionLogger mLogger;
private String mLoggingKey;
private boolean mWasReset;
private NotificationSettingsIconRow mSettingsIconRow;
private NotificationGuts mGuts;
private NotificationData.Entry mEntry;
@@ -615,20 +614,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
mShowingPublicInitialized = false;
mIsSystemExpanded = false;
mOnKeyguard = false;
mPublicLayout.reset(mIsHeadsUp);
mPrivateLayout.reset(mIsHeadsUp);
mPublicLayout.reset();
mPrivateLayout.reset();
resetHeight();
resetTranslation();
logExpansionEvent(false, wasExpanded);
}
public void resetHeight() {
if (mIsHeadsUp) {
resetActualHeight();
}
mMaxExpandHeight = 0;
mHeadsUpHeight = 0;
mWasReset = true;
onHeightReset();
requestLayout();
}
@@ -964,18 +959,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
return mStatusBarNotification != null && mStatusBarNotification.isClearable();
}
/**
* Apply an expansion state to the layout.
*/
public void applyExpansionToLayout() {
boolean expand = isExpanded();
if (expand && mExpandable) {
setActualHeight(mMaxExpandHeight);
} else {
setActualHeight(getMinHeight());
}
}
@Override
public int getIntrinsicHeight() {
if (isUserLocked()) {
@@ -1057,12 +1040,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
boolean updateExpandHeight = mMaxExpandHeight == 0 && !mWasReset;
updateMaxHeights();
if (updateExpandHeight) {
applyExpansionToLayout();
}
mWasReset = false;
}
private void updateMaxHeights() {

View File

@@ -36,7 +36,6 @@ public abstract class ExpandableView extends FrameLayout {
protected OnHeightChangedListener mOnHeightChangedListener;
private int mActualHeight;
protected int mClipTopAmount;
private boolean mActualHeightInitialized;
private boolean mDark;
private ArrayList<View> mMatchParentViews = new ArrayList<View>();
private int mClipTopOptimization;
@@ -99,28 +98,9 @@ public abstract class ExpandableView extends FrameLayout {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (!mActualHeightInitialized && mActualHeight == 0) {
int initialHeight = getInitialHeight();
if (initialHeight != 0) {
setActualHeight(initialHeight);
}
}
updateClipping();
}
/**
* Resets the height of the view on the next layout pass
*/
protected void resetActualHeight() {
mActualHeight = 0;
mActualHeightInitialized = false;
requestLayout();
}
protected int getInitialHeight() {
return getHeight();
}
@Override
public boolean pointInView(float localX, float localY, float slop) {
float top = mClipTopAmount;
@@ -137,7 +117,6 @@ public abstract class ExpandableView extends FrameLayout {
* @param notifyListeners Whether the listener should be informed about the change.
*/
public void setActualHeight(int actualHeight, boolean notifyListeners) {
mActualHeightInitialized = true;
mActualHeight = actualHeight;
updateClipping();
if (notifyListeners) {

View File

@@ -120,7 +120,7 @@ public class NotificationContentView extends FrameLayout {
R.dimen.min_notification_layout_height);
mNotificationContentMarginEnd = getResources().getDimensionPixelSize(
com.android.internal.R.dimen.notification_content_margin_end);
reset(true);
reset();
}
public void setHeights(int smallHeight, int headsUpMaxHeight, int maxHeight) {
@@ -255,7 +255,7 @@ public class NotificationContentView extends FrameLayout {
updateVisibility();
}
public void reset(boolean resetActualHeight) {
public void reset() {
if (mContractedChild != null) {
mContractedChild.animate().cancel();
removeView(mContractedChild);
@@ -271,10 +271,6 @@ public class NotificationContentView extends FrameLayout {
mContractedChild = null;
mExpandedChild = null;
mHeadsUpChild = null;
mVisibleType = VISIBLE_TYPE_CONTRACTED;
if (resetActualHeight) {
mContentHeight = mSmallHeight;
}
}
public View getContractedChild() {
@@ -484,12 +480,18 @@ public class NotificationContentView extends FrameLayout {
private void animateToVisibleType(int visibleType) {
final TransformableView shownView = getTransformableViewForVisibleType(visibleType);
final TransformableView hiddenView = getTransformableViewForVisibleType(mVisibleType);
if (shownView == hiddenView) {
shownView.setVisible(true);
return;
}
shownView.transformFrom(hiddenView);
getViewForVisibleType(visibleType).setVisibility(View.VISIBLE);
hiddenView.transformTo(shownView, new Runnable() {
@Override
public void run() {
hiddenView.setVisible(false);
if (hiddenView != getTransformableViewForVisibleType(mVisibleType)) {
hiddenView.setVisible(false);
}
}
});
}
@@ -550,6 +552,9 @@ public class NotificationContentView extends FrameLayout {
|| mContainingNotification.isExpanded()
? mContainingNotification.getMaxContentHeight()
: mContainingNotification.getShowingLayout().getMinHeight();
if (height == 0) {
height = mContentHeight;
}
int expandedVisualType = getVisualTypeForHeight(height);
int collapsedVisualType = getVisualTypeForHeight(
mContainingNotification.getMinExpandHeight());
@@ -557,7 +562,12 @@ public class NotificationContentView extends FrameLayout {
? expandedVisualType
: collapsedVisualType;
}
int viewHeight = Math.min(mContentHeight, mContainingNotification.getIntrinsicHeight());
int intrinsicHeight = mContainingNotification.getIntrinsicHeight();
int viewHeight = mContentHeight;
if (intrinsicHeight != 0) {
// the intrinsicHeight might be 0 because it was just reset.
viewHeight = Math.min(mContentHeight, intrinsicHeight);
}
return getVisualTypeForHeight(viewHeight);
}
@@ -638,7 +648,6 @@ public class NotificationContentView extends FrameLayout {
mBeforeN = entry.targetSdk < Build.VERSION_CODES.N;
updateSingleLineView();
applyRemoteInput(entry);
selectLayout(false /* animate */, true /* force */);
if (mContractedChild != null) {
mContractedWrapper.notifyContentUpdated(entry.notification);
}
@@ -648,6 +657,7 @@ public class NotificationContentView extends FrameLayout {
if (mHeadsUpChild != null) {
mHeadsUpWrapper.notifyContentUpdated(entry.notification);
}
selectLayout(false /* animate */, true /* force */);
setDark(mDark, false /* animate */, 0 /* delay */);
}

View File

@@ -76,26 +76,26 @@ public class ViewTransformationHelper implements TransformableView {
});
mViewTransformationAnimation.setInterpolator(Interpolators.LINEAR);
mViewTransformationAnimation.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
if (endRunnable != null) {
mViewTransformationAnimation.addListener(new AnimatorListenerAdapter() {
public boolean mCancelled;
mViewTransformationAnimation.addListener(new AnimatorListenerAdapter() {
public boolean mCancelled;
@Override
public void onAnimationEnd(Animator animation) {
endRunnable.run();
if (!mCancelled) {
setVisible(false);
} else {
abortTransformations();
@Override
public void onAnimationEnd(Animator animation) {
if (!mCancelled) {
if (endRunnable != null) {
endRunnable.run();
}
setVisible(false);
} else {
abortTransformations();
}
}
@Override
public void onAnimationCancel(Animator animation) {
mCancelled = true;
}
});
}
@Override
public void onAnimationCancel(Animator animation) {
mCancelled = true;
}
});
mViewTransformationAnimation.start();
}