Swipe up to home into FolderIcon animation bug fixes.

- Fixes clipping issues.
- Fixes badge being shifted.

Bug: 124510042
Change-Id: I2520d963fb2041a049650c2b8c12ddb3de7b8d87
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 8d9c520..0a9bc72 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -203,6 +203,10 @@
         mBackground.getBounds(outBounds);
     }
 
+    public float getBackgroundStrokeWidth() {
+        return mBackground.getStrokeWidth();
+    }
+
     public Folder getFolder() {
         return mFolder;
     }
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index e5c75c3..a9e8f17 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -259,8 +259,6 @@
                 mFgSpringX.animateToFinalPosition(diffX);
                 mFgSpringY.animateToFinalPosition(diffY);
             }
-
-
         }
         invalidate();
         invalidateOutline();
@@ -368,10 +366,13 @@
                 drawable = v.getBackground();
             }
         } else {
+            boolean isFolderIcon = v instanceof FolderIcon;
+            int width = isFolderIcon ? v.getWidth() : lp.width;
+            int height = isFolderIcon ? v.getHeight() : lp.height;
             if (supportsAdaptiveIcons) {
-                drawable = Utilities.getFullDrawable(mLauncher, info, lp.width, lp.height,
-                        false, sTmpObjArray);
-                if ((drawable instanceof AdaptiveIconDrawable)) {
+                drawable = Utilities.getFullDrawable(mLauncher, info, width, height, false,
+                        sTmpObjArray);
+                if (drawable instanceof AdaptiveIconDrawable) {
                     mBadge = getBadge(mLauncher, info, sTmpObjArray[0]);
                 } else {
                     // The drawable we get back is not an adaptive icon, so we need to use the
@@ -383,8 +384,8 @@
                     // Similar to DragView, we simply use the BubbleTextView icon here.
                     drawable = btvIcon;
                 } else {
-                    drawable = Utilities.getFullDrawable(mLauncher, info, lp.width, lp.height,
-                            false, sTmpObjArray);
+                    drawable = Utilities.getFullDrawable(mLauncher, info, width, height, false,
+                            sTmpObjArray);
                 }
             }
         }
@@ -412,13 +413,6 @@
                 }
                 mForeground = foreground;
 
-                if (mForeground instanceof ShiftedBitmapDrawable && v instanceof FolderIcon) {
-                    ShiftedBitmapDrawable sbd = (ShiftedBitmapDrawable) mForeground;
-                    ((FolderIcon) v).getPreviewBounds(sTmpRect);
-                    sbd.setShiftX(sbd.getShiftX() - sTmpRect.left);
-                    sbd.setShiftY(sbd.getShiftY() - sTmpRect.top);
-                }
-
                 final int originalHeight = lp.height;
                 final int originalWidth = lp.width;
 
@@ -434,13 +428,25 @@
 
                 if (mBadge != null) {
                     mBadge.setBounds(mStartRevealRect);
-                    if (!isOpening) {
+                    if (!isOpening && !isFolderIcon) {
                         DRAWABLE_ALPHA.set(mBadge, 0);
                     }
-
                 }
 
-                if (!isFolderIcon) {
+                if (isFolderIcon) {
+                    ((FolderIcon) v).getPreviewBounds(sTmpRect);
+                    float bgStroke = ((FolderIcon) v).getBackgroundStrokeWidth();
+                    if (mForeground instanceof ShiftedBitmapDrawable) {
+                        ShiftedBitmapDrawable sbd = (ShiftedBitmapDrawable) mForeground;
+                        sbd.setShiftX(sbd.getShiftX() - sTmpRect.left - bgStroke);
+                        sbd.setShiftY(sbd.getShiftY() - sTmpRect.top - bgStroke);
+                    }
+                    if (mBadge instanceof ShiftedBitmapDrawable) {
+                        ShiftedBitmapDrawable sbd = (ShiftedBitmapDrawable) mBadge;
+                        sbd.setShiftX(sbd.getShiftX() - sTmpRect.left - bgStroke);
+                        sbd.setShiftY(sbd.getShiftY() - sTmpRect.top - bgStroke);
+                    }
+                } else {
                     Utilities.scaleRectAboutCenter(mStartRevealRect,
                             IconShape.getNormalizationScale());
                 }
@@ -665,7 +671,7 @@
             }
         });
 
-        if (mBadge != null) {
+        if (mBadge != null && !(mOriginalIcon instanceof FolderIcon)) {
             ObjectAnimator badgeFade = ObjectAnimator.ofInt(mBadge, DRAWABLE_ALPHA, 255);
             badgeFade.addUpdateListener(valueAnimator -> invalidate());
             fade.play(badgeFade);
@@ -691,7 +697,6 @@
                 @Override
                 public void onAnimationEnd(Animator animation) {
                     folderIcon.setBackgroundVisible(true);
-                    folderIcon.animateBgShadowAndStroke();
                     if (folderIcon.hasDot()) {
                         folderIcon.animateDotScale(0, 1f);
                     }