Merge "Fix shadow problems with Folder animation." into ub-launcher3-dorval-polish

This commit is contained in:
TreeHugger Robot
2017-06-20 17:59:22 +00:00
committed by Android (Google) Code Review
4 changed files with 45 additions and 3 deletions
@@ -56,7 +56,7 @@ public class RoundedRectRevealOutlineProvider extends RevealOutlineAnimation {
@Override
public boolean shouldRemoveElevationDuringAnimation() {
return false;
return true;
}
@Override
+4 -1
View File
@@ -791,8 +791,11 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
mDragController.removeDropTarget(this);
clearFocus();
if (mFolderIcon != null) {
mFolderIcon.setBackgroundVisible(true);
mFolderIcon.setVisibility(View.VISIBLE);
if (FeatureFlags.LAUNCHER3_NEW_FOLDER_ANIMATION) {
mFolderIcon.setBackgroundVisible(true);
mFolderIcon.mBackground.fadeInBackgroundShadow();
}
if (wasAnimated) {
mFolderIcon.mBackground.animateBackgroundStroke();
if (mFolderIcon.hasBadge()) {
@@ -221,6 +221,12 @@ public class FolderAnimationManager {
mFolder.setTranslationY(0.0f);
mFolder.setScaleX(1f);
mFolder.setScaleY(1f);
if (mIsOpening) {
getAnimator(mFolder, View.TRANSLATION_Z, -mFolder.getElevation(), 0)
.setDuration(150)
.start();
}
}
});
@@ -555,6 +555,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
private int mBgColor;
private float mStrokeWidth;
private int mStrokeAlpha = MAX_BG_OPACITY;
private int mShadowAlpha = 255;
private View mInvalidateDelegate;
public int previewSize;
@@ -580,6 +581,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
ValueAnimator mScaleAnimator;
ObjectAnimator mStrokeAlphaAnimator;
ObjectAnimator mShadowAnimator;
private static final Property<PreviewBackground, Integer> STROKE_ALPHA =
new Property<PreviewBackground, Integer>(Integer.class, "strokeAlpha") {
@@ -595,6 +597,20 @@ public class FolderIcon extends FrameLayout implements FolderListener {
}
};
private static final Property<PreviewBackground, Integer> SHADOW_ALPHA =
new Property<PreviewBackground, Integer>(Integer.class, "shadowAlpha") {
@Override
public Integer get(PreviewBackground previewBackground) {
return previewBackground.mShadowAlpha;
}
@Override
public void set(PreviewBackground previewBackground, Integer alpha) {
previewBackground.mShadowAlpha = alpha;
previewBackground.invalidate();
}
};
public void setup(Launcher launcher, View invalidateDelegate,
int availableSpace, int topPadding) {
mInvalidateDelegate = invalidateDelegate;
@@ -692,10 +708,11 @@ public class FolderIcon extends FrameLayout implements FolderListener {
mShaderMatrix.setScale(shadowRadius, shadowRadius);
mShaderMatrix.postTranslate(radius + offsetX, shadowRadius + offsetY);
mShadowShader.setLocalMatrix(mShaderMatrix);
mPaint.setAlpha(mShadowAlpha);
mPaint.setShader(mShadowShader);
canvas.drawPaint(mPaint);
mPaint.setAlpha(255);
mPaint.setShader(null);
if (canvas.isHardwareAccelerated()) {
mPaint.setXfermode(mShadowPorterDuffXfermode);
canvas.drawCircle(radius + offsetX, radius + offsetY, radius, mPaint);
@@ -705,6 +722,22 @@ public class FolderIcon extends FrameLayout implements FolderListener {
canvas.restoreToCount(saveCount);
}
public void fadeInBackgroundShadow() {
if (mShadowAnimator != null) {
mShadowAnimator.cancel();
}
mShadowAnimator = ObjectAnimator
.ofInt(this, SHADOW_ALPHA, 0, 255)
.setDuration(100);
mShadowAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mShadowAnimator = null;
}
});
mShadowAnimator.start();
}
public void animateBackgroundStroke() {
if (mStrokeAlphaAnimator != null) {
mStrokeAlphaAnimator.cancel();