Merge "Fixed the transformation for MessagingStyle" into qt-dev
am: 6ce6892440
Change-Id: Ibdd781671cf17d794a7e0a97eca764513eea94c0
This commit is contained in:
@@ -97,7 +97,6 @@ public class MessagingLayoutTransformState extends TransformState {
|
|||||||
HashMap<MessagingGroup, MessagingGroup> pairs = findPairs(ownGroups, otherGroups);
|
HashMap<MessagingGroup, MessagingGroup> pairs = findPairs(ownGroups, otherGroups);
|
||||||
MessagingGroup lastPairedGroup = null;
|
MessagingGroup lastPairedGroup = null;
|
||||||
float currentTranslation = 0;
|
float currentTranslation = 0;
|
||||||
float transformationDistanceRemaining = 0;
|
|
||||||
for (int i = ownGroups.size() - 1; i >= 0; i--) {
|
for (int i = ownGroups.size() - 1; i >= 0; i--) {
|
||||||
MessagingGroup ownGroup = ownGroups.get(i);
|
MessagingGroup ownGroup = ownGroups.get(i);
|
||||||
MessagingGroup matchingGroup = pairs.get(ownGroup);
|
MessagingGroup matchingGroup = pairs.get(ownGroup);
|
||||||
@@ -108,13 +107,10 @@ public class MessagingLayoutTransformState extends TransformState {
|
|||||||
lastPairedGroup = ownGroup;
|
lastPairedGroup = ownGroup;
|
||||||
if (to){
|
if (to){
|
||||||
float totalTranslation = ownGroup.getTop() - matchingGroup.getTop();
|
float totalTranslation = ownGroup.getTop() - matchingGroup.getTop();
|
||||||
transformationDistanceRemaining
|
currentTranslation = matchingGroup.getAvatar().getTranslationY()
|
||||||
= matchingGroup.getAvatar().getTranslationY();
|
- totalTranslation;
|
||||||
currentTranslation = transformationDistanceRemaining - totalTranslation;
|
|
||||||
} else {
|
} else {
|
||||||
float totalTranslation = matchingGroup.getTop() - ownGroup.getTop();
|
|
||||||
currentTranslation = ownGroup.getAvatar().getTranslationY();
|
currentTranslation = ownGroup.getAvatar().getTranslationY();
|
||||||
transformationDistanceRemaining = currentTranslation - totalTranslation;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -122,14 +118,20 @@ public class MessagingLayoutTransformState extends TransformState {
|
|||||||
if (lastPairedGroup != null) {
|
if (lastPairedGroup != null) {
|
||||||
adaptGroupAppear(ownGroup, transformationAmount, currentTranslation,
|
adaptGroupAppear(ownGroup, transformationAmount, currentTranslation,
|
||||||
to);
|
to);
|
||||||
int distance = lastPairedGroup.getTop() - ownGroup.getTop();
|
float newPosition = ownGroup.getTop() + currentTranslation;
|
||||||
float transformationDistance = mTransformInfo.isAnimating()
|
|
||||||
? distance
|
if (!mTransformInfo.isAnimating()) {
|
||||||
: ownGroup.getHeight() * 0.75f;
|
// We fade the group away as soon as 1/2 of it is translated away on top
|
||||||
float translationProgress = transformationDistanceRemaining
|
float fadeStart = -ownGroup.getHeight() * 0.5f;
|
||||||
- (distance - transformationDistance);
|
groupTransformationAmount = (newPosition - fadeStart)
|
||||||
groupTransformationAmount =
|
/ Math.abs(fadeStart);
|
||||||
translationProgress / transformationDistance;
|
} else {
|
||||||
|
float fadeStart = -ownGroup.getHeight() * 0.75f;
|
||||||
|
// We want to fade out as soon as the animation starts, let's add the
|
||||||
|
// complete top in addition
|
||||||
|
groupTransformationAmount = (newPosition - fadeStart)
|
||||||
|
/ (Math.abs(fadeStart) + ownGroup.getTop());
|
||||||
|
}
|
||||||
groupTransformationAmount = Math.max(0.0f, Math.min(1.0f,
|
groupTransformationAmount = Math.max(0.0f, Math.min(1.0f,
|
||||||
groupTransformationAmount));
|
groupTransformationAmount));
|
||||||
if (to) {
|
if (to) {
|
||||||
@@ -175,7 +177,8 @@ public class MessagingLayoutTransformState extends TransformState {
|
|||||||
relativeOffset *= 0.5f;
|
relativeOffset *= 0.5f;
|
||||||
}
|
}
|
||||||
ownGroup.getMessageContainer().setTranslationY(relativeOffset);
|
ownGroup.getMessageContainer().setTranslationY(relativeOffset);
|
||||||
ownGroup.setTranslationY(overallTranslation * 0.85f);
|
ownGroup.getSenderView().setTranslationY(relativeOffset);
|
||||||
|
ownGroup.setTranslationY(overallTranslation * 0.9f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disappear(MessagingGroup ownGroup, float transformationAmount) {
|
private void disappear(MessagingGroup ownGroup, float transformationAmount) {
|
||||||
@@ -256,6 +259,9 @@ public class MessagingLayoutTransformState extends TransformState {
|
|||||||
float distanceToTop = child.getTop() + child.getHeight() + previousTranslation;
|
float distanceToTop = child.getTop() + child.getHeight() + previousTranslation;
|
||||||
transformationAmount = distanceToTop / child.getHeight();
|
transformationAmount = distanceToTop / child.getHeight();
|
||||||
transformationAmount = Math.max(0.0f, Math.min(1.0f, transformationAmount));
|
transformationAmount = Math.max(0.0f, Math.min(1.0f, transformationAmount));
|
||||||
|
if (to) {
|
||||||
|
transformationAmount = 1.0f - transformationAmount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
transformView(transformationAmount, to, child, otherChild, false, /* sameAsAny */
|
transformView(transformationAmount, to, child, otherChild, false, /* sameAsAny */
|
||||||
useLinearTransformation);
|
useLinearTransformation);
|
||||||
@@ -400,6 +406,7 @@ public class MessagingLayoutTransformState extends TransformState {
|
|||||||
setClippingDeactivated(ownGroup.getSenderView(), false);
|
setClippingDeactivated(ownGroup.getSenderView(), false);
|
||||||
ownGroup.setTranslationY(0);
|
ownGroup.setTranslationY(0);
|
||||||
ownGroup.getMessageContainer().setTranslationY(0);
|
ownGroup.getMessageContainer().setTranslationY(0);
|
||||||
|
ownGroup.getSenderView().setTranslationY(0);
|
||||||
}
|
}
|
||||||
ownGroup.setTransformingImages(false);
|
ownGroup.setTransformingImages(false);
|
||||||
ownGroup.updateClipRect();
|
ownGroup.updateClipRect();
|
||||||
|
|||||||
Reference in New Issue
Block a user