diff options
author | Jon Miranda <jonmiranda@google.com> | 2017-04-06 14:53:52 -0700 |
---|---|---|
committer | Jonathan Miranda <jonmiranda@google.com> | 2017-05-01 19:07:56 +0000 |
commit | bdb5424fae0efb7bd2c4d148dffac5aa9ee7fc90 (patch) | |
tree | 3589bae4a27a6b83d60eb90f1174360bfc526de7 | |
parent | d9125d84ba89938c4d2ea133c3c8a11baff76f1e (diff) | |
download | android_packages_apps_Trebuchet-bdb5424fae0efb7bd2c4d148dffac5aa9ee7fc90.tar.gz android_packages_apps_Trebuchet-bdb5424fae0efb7bd2c4d148dffac5aa9ee7fc90.tar.bz2 android_packages_apps_Trebuchet-bdb5424fae0efb7bd2c4d148dffac5aa9ee7fc90.zip |
Fade in the FolderIcon stroke after Folder animates closed.
When the Folder animates closed, it hides itself the same
time as the FolderIcon becomes visible. Because the Folder
does not have the white stroke outline, there is a visual
jump between the closed Folder and the FolderIcon.
This change is a subtle and easy step towards reducing
the visual jump.
Bug: 35064148
Change-Id: I8aeeed873e7144499d19f3b01c85bfa8a792097f
-rw-r--r-- | src/com/android/launcher3/folder/Folder.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/folder/FolderIcon.java | 34 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index a0ceb49d7..1601edb44 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -783,6 +783,7 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC if (mFolderIcon != null) { mFolderIcon.setVisibility(View.VISIBLE); if (wasAnimated) { + mFolderIcon.mBackground.animateBackgroundStroke(); mFolderIcon.requestFocus(); } } diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index 6989a5273..1680f0bd7 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -547,6 +547,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { private float mScale = 1f; private float mColorMultiplier = 1f; private float mStrokeWidth; + private int mStrokeAlpha = MAX_BG_OPACITY; private View mInvalidateDelegate; public int previewSize; @@ -572,6 +573,21 @@ public class FolderIcon extends FrameLayout implements FolderListener { private static final int SHADOW_OPACITY = 40; ValueAnimator mScaleAnimator; + ObjectAnimator mStrokeAlphaAnimator; + + private static final Property<PreviewBackground, Integer> STROKE_ALPHA = + new Property<PreviewBackground, Integer>(Integer.class, "strokeAlpha") { + @Override + public Integer get(PreviewBackground previewBackground) { + return previewBackground.mStrokeAlpha; + } + + @Override + public void set(PreviewBackground previewBackground, Integer alpha) { + previewBackground.mStrokeAlpha = alpha; + previewBackground.invalidate(); + } + }; public void setup(DisplayMetrics dm, DeviceProfile grid, View invalidateDelegate, int availableSpace, int topPadding) { @@ -681,8 +697,24 @@ public class FolderIcon extends FrameLayout implements FolderListener { canvas.restoreToCount(saveCount); } + public void animateBackgroundStroke() { + if (mStrokeAlphaAnimator != null) { + mStrokeAlphaAnimator.cancel(); + } + mStrokeAlphaAnimator = ObjectAnimator + .ofArgb(this, STROKE_ALPHA, MAX_BG_OPACITY / 2, MAX_BG_OPACITY) + .setDuration(100); + mStrokeAlphaAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mStrokeAlphaAnimator = null; + } + }); + mStrokeAlphaAnimator.start(); + } + public void drawBackgroundStroke(Canvas canvas) { - mPaint.setColor(Color.argb(255, BG_INTENSITY, BG_INTENSITY, BG_INTENSITY)); + mPaint.setColor(Color.argb(mStrokeAlpha, BG_INTENSITY, BG_INTENSITY, BG_INTENSITY)); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(mStrokeWidth); drawCircle(canvas, 1 /* deltaRadius */); |