Merge "Fixed a crash when the transformed view was updated while dragging" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c4e70467f7
@@ -56,15 +56,6 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
private final Rect mClipBounds = new Rect();
|
private final Rect mClipBounds = new Rect();
|
||||||
private final int mMinContractedHeight;
|
private final int mMinContractedHeight;
|
||||||
private final int mNotificationContentMarginEnd;
|
private final int mNotificationContentMarginEnd;
|
||||||
private final OnLayoutChangeListener mLayoutUpdater = new OnLayoutChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onLayoutChange(View v, int left, int top, int right, int bottom,
|
|
||||||
int oldLeft,
|
|
||||||
int oldTop, int oldRight, int oldBottom) {
|
|
||||||
selectLayout(false /* animate */, false /* force */);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
private View mContractedChild;
|
private View mContractedChild;
|
||||||
private View mExpandedChild;
|
private View mExpandedChild;
|
||||||
@@ -119,6 +110,7 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
private int mTransformationStartVisibleType;
|
private int mTransformationStartVisibleType;
|
||||||
private boolean mUserExpanding;
|
private boolean mUserExpanding;
|
||||||
private int mSingleLineWidthIndention;
|
private int mSingleLineWidthIndention;
|
||||||
|
private boolean mForceSelectNextLayout = true;
|
||||||
private PendingIntent mPreviousExpandedRemoteInputIntent;
|
private PendingIntent mPreviousExpandedRemoteInputIntent;
|
||||||
private PendingIntent mPreviousHeadsUpRemoteInputIntent;
|
private PendingIntent mPreviousHeadsUpRemoteInputIntent;
|
||||||
|
|
||||||
@@ -270,6 +262,8 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
super.onLayout(changed, left, top, right, bottom);
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
updateClipping();
|
updateClipping();
|
||||||
invalidateOutline();
|
invalidateOutline();
|
||||||
|
selectLayout(false /* animate */, mForceSelectNextLayout /* force */);
|
||||||
|
mForceSelectNextLayout = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -317,44 +311,35 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
public void setContractedChild(View child) {
|
public void setContractedChild(View child) {
|
||||||
if (mContractedChild != null) {
|
if (mContractedChild != null) {
|
||||||
mContractedChild.animate().cancel();
|
mContractedChild.animate().cancel();
|
||||||
mContractedChild.removeOnLayoutChangeListener(mLayoutUpdater);
|
|
||||||
removeView(mContractedChild);
|
removeView(mContractedChild);
|
||||||
}
|
}
|
||||||
addView(child);
|
addView(child);
|
||||||
mContractedChild = child;
|
mContractedChild = child;
|
||||||
mContractedChild.addOnLayoutChangeListener(mLayoutUpdater);
|
|
||||||
mContractedWrapper = NotificationViewWrapper.wrap(getContext(), child,
|
mContractedWrapper = NotificationViewWrapper.wrap(getContext(), child,
|
||||||
mContainingNotification);
|
mContainingNotification);
|
||||||
selectLayout(false /* animate */, true /* force */);
|
|
||||||
mContractedWrapper.setDark(mDark, false /* animate */, 0 /* delay */);
|
mContractedWrapper.setDark(mDark, false /* animate */, 0 /* delay */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExpandedChild(View child) {
|
public void setExpandedChild(View child) {
|
||||||
if (mExpandedChild != null) {
|
if (mExpandedChild != null) {
|
||||||
mExpandedChild.animate().cancel();
|
mExpandedChild.animate().cancel();
|
||||||
mExpandedChild.removeOnLayoutChangeListener(mLayoutUpdater);
|
|
||||||
removeView(mExpandedChild);
|
removeView(mExpandedChild);
|
||||||
}
|
}
|
||||||
addView(child);
|
addView(child);
|
||||||
mExpandedChild = child;
|
mExpandedChild = child;
|
||||||
mExpandedChild.addOnLayoutChangeListener(mLayoutUpdater);
|
|
||||||
mExpandedWrapper = NotificationViewWrapper.wrap(getContext(), child,
|
mExpandedWrapper = NotificationViewWrapper.wrap(getContext(), child,
|
||||||
mContainingNotification);
|
mContainingNotification);
|
||||||
selectLayout(false /* animate */, true /* force */);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHeadsUpChild(View child) {
|
public void setHeadsUpChild(View child) {
|
||||||
if (mHeadsUpChild != null) {
|
if (mHeadsUpChild != null) {
|
||||||
mHeadsUpChild.animate().cancel();
|
mHeadsUpChild.animate().cancel();
|
||||||
mHeadsUpChild.removeOnLayoutChangeListener(mLayoutUpdater);
|
|
||||||
removeView(mHeadsUpChild);
|
removeView(mHeadsUpChild);
|
||||||
}
|
}
|
||||||
addView(child);
|
addView(child);
|
||||||
mHeadsUpChild = child;
|
mHeadsUpChild = child;
|
||||||
mHeadsUpChild.addOnLayoutChangeListener(mLayoutUpdater);
|
|
||||||
mHeadsUpWrapper = NotificationViewWrapper.wrap(getContext(), child,
|
mHeadsUpWrapper = NotificationViewWrapper.wrap(getContext(), child,
|
||||||
mContainingNotification);
|
mContainingNotification);
|
||||||
selectLayout(false /* animate */, true /* force */);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -408,7 +393,8 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
updateBackgroundColor(true /* animate */);
|
updateBackgroundColor(true /* animate */);
|
||||||
}
|
}
|
||||||
if (mTransformationStartVisibleType != UNDEFINED
|
if (mTransformationStartVisibleType != UNDEFINED
|
||||||
&& mVisibleType != mTransformationStartVisibleType) {
|
&& mVisibleType != mTransformationStartVisibleType
|
||||||
|
&& getViewForVisibleType(mTransformationStartVisibleType) != null) {
|
||||||
final TransformableView shownView = getTransformableViewForVisibleType(mVisibleType);
|
final TransformableView shownView = getTransformableViewForVisibleType(mVisibleType);
|
||||||
final TransformableView hiddenView = getTransformableViewForVisibleType(
|
final TransformableView hiddenView = getTransformableViewForVisibleType(
|
||||||
mTransformationStartVisibleType);
|
mTransformationStartVisibleType);
|
||||||
@@ -501,8 +487,7 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
if (mUserExpanding) {
|
if (mUserExpanding) {
|
||||||
updateContentTransformation();
|
updateContentTransformation();
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
int visibleType = calculateVisibleType();
|
int visibleType = calculateVisibleType();
|
||||||
if (visibleType != mVisibleType || force) {
|
if (visibleType != mVisibleType || force) {
|
||||||
View visibleView = getViewForVisibleType(visibleType);
|
View visibleView = getViewForVisibleType(visibleType);
|
||||||
@@ -523,6 +508,47 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
updateBackgroundColor(animate);
|
updateBackgroundColor(animate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mForceSelectNextLayout) {
|
||||||
|
forceUpdateVisibilities();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forceUpdateVisibilities() {
|
||||||
|
boolean contractedVisible = mVisibleType == VISIBLE_TYPE_CONTRACTED
|
||||||
|
|| mTransformationStartVisibleType == VISIBLE_TYPE_CONTRACTED;
|
||||||
|
boolean expandedVisible = mVisibleType == VISIBLE_TYPE_EXPANDED
|
||||||
|
|| mTransformationStartVisibleType == VISIBLE_TYPE_EXPANDED;
|
||||||
|
boolean headsUpVisible = mVisibleType == VISIBLE_TYPE_HEADSUP
|
||||||
|
|| mTransformationStartVisibleType == VISIBLE_TYPE_HEADSUP;
|
||||||
|
boolean singleLineVisible = mVisibleType == VISIBLE_TYPE_SINGLELINE
|
||||||
|
|| mTransformationStartVisibleType == VISIBLE_TYPE_SINGLELINE;
|
||||||
|
if (!contractedVisible) {
|
||||||
|
mContractedChild.setVisibility(View.INVISIBLE);
|
||||||
|
} else {
|
||||||
|
mContractedWrapper.setVisible(true);
|
||||||
|
}
|
||||||
|
if (mExpandedChild != null) {
|
||||||
|
if (!expandedVisible) {
|
||||||
|
mExpandedChild.setVisibility(View.INVISIBLE);
|
||||||
|
} else {
|
||||||
|
mExpandedWrapper.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mHeadsUpChild != null) {
|
||||||
|
if (!headsUpVisible) {
|
||||||
|
mHeadsUpChild.setVisibility(View.INVISIBLE);
|
||||||
|
} else {
|
||||||
|
mHeadsUpWrapper.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mSingleLineView != null) {
|
||||||
|
if (!singleLineVisible) {
|
||||||
|
mSingleLineView.setVisibility(View.INVISIBLE);
|
||||||
|
} else {
|
||||||
|
mSingleLineView.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateBackgroundColor(boolean animate) {
|
public void updateBackgroundColor(boolean animate) {
|
||||||
int customBackgroundColor = getBackgroundColor(mVisibleType);
|
int customBackgroundColor = getBackgroundColor(mVisibleType);
|
||||||
@@ -558,7 +584,7 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
private void animateToVisibleType(int visibleType) {
|
private void animateToVisibleType(int visibleType) {
|
||||||
final TransformableView shownView = getTransformableViewForVisibleType(visibleType);
|
final TransformableView shownView = getTransformableViewForVisibleType(visibleType);
|
||||||
final TransformableView hiddenView = getTransformableViewForVisibleType(mVisibleType);
|
final TransformableView hiddenView = getTransformableViewForVisibleType(mVisibleType);
|
||||||
if (shownView == hiddenView) {
|
if (shownView == hiddenView || hiddenView == null) {
|
||||||
shownView.setVisible(true);
|
shownView.setVisible(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -647,8 +673,9 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
height = mContentHeight;
|
height = mContentHeight;
|
||||||
}
|
}
|
||||||
int expandedVisualType = getVisualTypeForHeight(height);
|
int expandedVisualType = getVisualTypeForHeight(height);
|
||||||
int collapsedVisualType = getVisualTypeForHeight(
|
int collapsedVisualType = mIsChildInGroup && !isGroupExpanded()
|
||||||
mContainingNotification.getCollapsedHeight());
|
? VISIBLE_TYPE_SINGLELINE
|
||||||
|
: getVisualTypeForHeight(mContainingNotification.getCollapsedHeight());
|
||||||
return mTransformationStartVisibleType == collapsedVisualType
|
return mTransformationStartVisibleType == collapsedVisualType
|
||||||
? expandedVisualType
|
? expandedVisualType
|
||||||
: collapsedVisualType;
|
: collapsedVisualType;
|
||||||
@@ -762,7 +789,7 @@ public class NotificationContentView extends FrameLayout {
|
|||||||
mHeadsUpWrapper.notifyContentUpdated(entry.notification);
|
mHeadsUpWrapper.notifyContentUpdated(entry.notification);
|
||||||
}
|
}
|
||||||
updateShowingLegacyBackground();
|
updateShowingLegacyBackground();
|
||||||
selectLayout(false /* animate */, true /* force */);
|
mForceSelectNextLayout = true;
|
||||||
setDark(mDark, false /* animate */, 0 /* delay */);
|
setDark(mDark, false /* animate */, 0 /* delay */);
|
||||||
mPreviousExpandedRemoteInputIntent = null;
|
mPreviousExpandedRemoteInputIntent = null;
|
||||||
mPreviousHeadsUpRemoteInputIntent = null;
|
mPreviousHeadsUpRemoteInputIntent = null;
|
||||||
|
|||||||
@@ -100,8 +100,17 @@ public class TransformState {
|
|||||||
boolean transformY = (transformationFlags & TRANSOFORM_Y) != 0;
|
boolean transformY = (transformationFlags & TRANSOFORM_Y) != 0;
|
||||||
boolean transformScale = transformScale();
|
boolean transformScale = transformScale();
|
||||||
// lets animate the positions correctly
|
// lets animate the positions correctly
|
||||||
if (transformationAmount == 0.0f) {
|
if (transformationAmount == 0.0f
|
||||||
int[] otherPosition = otherState.getLocationOnScreen();
|
|| transformX && getTransformationStartX() == UNDEFINED
|
||||||
|
|| transformY && getTransformationStartY() == UNDEFINED
|
||||||
|
|| transformScale && getTransformationStartScaleX() == UNDEFINED
|
||||||
|
|| transformScale && getTransformationStartScaleY() == UNDEFINED) {
|
||||||
|
int[] otherPosition;
|
||||||
|
if (transformationAmount != 0.0f) {
|
||||||
|
otherPosition = otherState.getLaidOutLocationOnScreen();
|
||||||
|
} else {
|
||||||
|
otherPosition = otherState.getLocationOnScreen();
|
||||||
|
}
|
||||||
int[] ownStablePosition = getLaidOutLocationOnScreen();
|
int[] ownStablePosition = getLaidOutLocationOnScreen();
|
||||||
if (customTransformation == null
|
if (customTransformation == null
|
||||||
|| !customTransformation.initTransformation(this, otherState)) {
|
|| !customTransformation.initTransformation(this, otherState)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user